diff options
-rw-r--r-- | config/ampache.cfg.php.dist | 7 | ||||
-rwxr-xr-x | docs/CHANGELOG | 4 | ||||
-rw-r--r-- | lib/class/song.class.php | 39 | ||||
-rw-r--r-- | lib/stream.lib.php | 2 | ||||
-rw-r--r-- | play/index.php | 4 |
5 files changed, 52 insertions, 4 deletions
diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist index bfee16ed..ce39f31d 100644 --- a/config/ampache.cfg.php.dist +++ b/config/ampache.cfg.php.dist @@ -338,6 +338,13 @@ search_type = fuzzy downsample_cmd = mp3splt -qnf "%FILE%" %OFFSET% %EOF% -o - | lame --mp3input -q 3 -b %SAMPLE% -S - - ####################################################### +# These are commands used to transcode non-streaming +# formats to mp3 for streaming. Very similar to +# downsampling, but requires something that can play +# the various file formats. +stream_cmd_m4a = faad -f 2 -w "%FILE%" | lame -r -b %SAMPLE% -S - - + +####################################################### # These options control the "local play" feature. This requires # a playlist manager such as moosic, winamp, xmms etc which # can be controlled via command line. diff --git a/docs/CHANGELOG b/docs/CHANGELOG index b292aebf..cfa30072 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,8 +4,10 @@ -------------------------------------------------------------------------- v.3.3.2-Alpha3 + - Added transcoding of m4a files so they stream properly + (Thx Rosensama) - Fixed problem where Add to Playlist from mpd.php only works for - file method + file method (Thx Rosensama) - Added 'Simple' Genre Bar (Thx sigger) - Added initial TV page for viewing of nowplaying and additional information (Thx sigger) diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 0ef69bbd..b104a4e2 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -674,6 +674,45 @@ class Song { return stripslashes($matches[1]); } // get_info_from_filename + + /*! + @function native_stream + @discussion returns true if the $song->type streams ok, false if it must be transcoded to stream + */ + function native_stream() { + $return = true; + + switch ($this->type) { + //TODO: fill out these cases once we have it working for m4a + case "m4a": + $return = false; + break; + default: + break; + } // end switch + + return $return; + } // end native_stream + + /*! + @function stream_cmd + @discussion test if the song type streams natively and if not returns a transcoding command from the config + */ + function stream_cmd() { + $return = NULL; + if (!$this->native_stream()) { + switch ($this->type) { + case "m4a": + $return = "stream_cmd_m4a"; + break; + default: + $return = "downsample_cmd"; + break; + } // end switch + } // end if not native_stream + + return $return; + } // end stream_cmd } //end of song class diff --git a/lib/stream.lib.php b/lib/stream.lib.php index 18b4562f..50e9f22f 100644 --- a/lib/stream.lib.php +++ b/lib/stream.lib.php @@ -236,7 +236,7 @@ function start_downsample($song,$now_playing_id=0,$song_name=0) { /* Replace Variables */ - $downsample_command = conf('downsample_cmd'); + $downsample_command = conf($song->stream_cmd()); $downsample_command = str_replace("%FILE%",$song->file,$downsample_command); $downsample_command = str_replace("%OFFSET%",$offset,$downsample_command); $downsample_command = str_replace("%EOF%",$eof,$downsample_command); diff --git a/play/index.php b/play/index.php index 61366aa1..b869901a 100644 --- a/play/index.php +++ b/play/index.php @@ -204,7 +204,7 @@ else { // Prevent the script from timing out set_time_limit(0); - if ($user->prefs['play_type'] == 'downsample') { + if ($user->prefs['play_type'] == 'downsample' || !$song->native_stream()) { $fp = start_downsample($song,$lastid,$song_name); @@ -247,7 +247,7 @@ else { delete_now_playing($lastid); /* Clean up any open ends */ - if ($user->prefs['play_type'] == 'downsample') { + if ($user->prefs['play_type'] == 'downsample' || !$song->native_stream()) { @pclose($fp); } else { |