diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index b64189b99..dc67546f6 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -31,7 +31,7 @@ class PlaylistController extends Zend_Controller_Action { $pl = null; - if (isset($this->pl_sess->id)) { + if (isset($this->pl_sess->id)) { $pl = new Application_Model_Playlist($this->pl_sess->id); $modified = $this->_getParam('modified', null); @@ -205,11 +205,7 @@ class PlaylistController extends Zend_Controller_Action $audioFileTitle = $this->_getParam('audioFileTitle'); $playlistIndex = $this->_getParam('playlistIndex'); $playlistID = $this->_getParam('playlistID'); - Logging::log($audioFileID); - Logging::log($audioFileArtist); - Logging::log($audioFileTitle); - Logging::log($playlistIndex); - Logging::log($playlistID); + $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); @@ -226,7 +222,7 @@ class PlaylistController extends Zend_Controller_Action } else { $this->view->logo = "$baseUrl/css/images/airtime_logo_jp.png"; } - Logging::log("The play list index is $playlistIndex"); + $this->view->audioFileID = $audioFileID; $this->view->audioFileArtist = $audioFileArtist; $this->view->audioFileTitle = $audioFileTitle; @@ -251,12 +247,20 @@ class PlaylistController extends Zend_Controller_Action $result = Array(); foreach ( $pl->getContents() as $track ){ + $trackMap = array( 'title' => isset($track['CcFiles']['track_title'])?$track['CcFiles']['track_title']:"", 'artist' => isset($track['CcFiles']['artist_name'])?$track['CcFiles']['artist_name']:"", - 'mp3' => '/api/get-media/fileID/'.$track['CcFiles']['gunid'].'.'.pathinfo($track['CcFiles']['filepath'], PATHINFO_EXTENSION), 'id' => isset($track['id'])?$track['id']:"", 'position' => isset($track['position'])?$track['position']:"", ); + $fileExtension = pathinfo($track['CcFiles']['filepath'], PATHINFO_EXTENSION); + if ($fileExtension === 'mp3'){ + $trackMap['mp3'] = $track['CcFiles']['gunid'].'.'.$fileExtension; + } else if( $fileExtension === 'ogg') { + $trackMap['oga'] = $track['CcFiles']['gunid'].'.'.$fileExtension; + } else { + //the media was neither mp3 or ogg + } $result[] = $trackMap; } diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 1c3e39934..a18e701e2 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -652,9 +652,15 @@ function addQtipToSCIcons(){ } }); } - + +/** + *handle to the jplayer window + */ var preview_window = null; +/** + *Gets the info from the view when menu action play choosen and opens the jplayer window. + */ function openAudioPreview(event) { event.stopPropagation(); @@ -665,12 +671,21 @@ function openAudioPreview(event) { open_playlist_preview(audioFileID, "", "", playlistID, playlistIndex); } - + +/** + *Opens a jPlayer window for the specified info, for either an audio file or playlist. + *If audioFile, audioFileTitle, audioFileArtist is supplied the jplayer opens for one file + *Otherwise the playlistID and playlistIndex was supplied and a playlist is played starting with the + *given index. + */ function open_playlist_preview(audioFileID, audioFileTitle, audioFileArtist, playlistID, playlistIndex) { - if (playlistIndex != undefined) + if (playlistIndex != undefined) { + if (playlistIndex == undefined) //Use a resonable default. + playlistIndex = 0; url = 'Playlist/playlist-preview/audioFileID/'+audioFileID+'/playlistIndex/'+playlistIndex+'/playlistID/'+playlistID; - else + } else { url = 'Playlist/playlist-preview/audioFileID/'+audioFileID+'/audioFileArtist/'+audioFileArtist+'/audioFileTitle/'+audioFileTitle; + } //$.post(baseUri+'Playlist/audio-preview-player', {fileName: fileName, cueIn: cueIn, cueOut: cueOut, fadeIn: fadeIn, fadeInFileName: fadeInFileName, fadeOut: fadeOut, fadeOutFileName: fadeOutFileName}) if (preview_window == null || preview_window.closed || playlistIndex === undefined){ preview_window = window.open(url, 'Audio Player', 'width=450,height=800'); @@ -681,5 +696,6 @@ function open_playlist_preview(audioFileID, audioFileTitle, audioFileArtist, pla //var elemID = "spl_"+elemIndexString; //$('#'+elemID+' div.list-item-container a span').attr("class", "ui-icon ui-icon-pause"); + preview_window.focus(); return false; } diff --git a/airtime_mvc/public/js/jplayer/preview_jplayer.js b/airtime_mvc/public/js/jplayer/preview_jplayer.js index c62dbe9f9..00ca8f255 100644 --- a/airtime_mvc/public/js/jplayer/preview_jplayer.js +++ b/airtime_mvc/public/js/jplayer/preview_jplayer.js @@ -5,7 +5,6 @@ $(document).ready(function(){ var audioFileID = $('.audioFileID').text(); var playlistID = $('.playlistID').text(); var playlistIndex = $('.playlistIndex').text(); - console.log('in the ready'); playlist_jplayer = new jPlayerPlaylist({ jPlayer: "#jquery_jplayer_1", cssSelectorAncestor: "#jp_container_1" @@ -42,18 +41,21 @@ function playAll(playlistID, playlistIndex) { var myPlaylist = new Array(); var media; var index; + for(index in data){ - if (data[index]['mp3'] != 'undefined'){ + console.log(data[index]); + if (data[index]['mp3'] != undefined){ media = {title: data[index]['title'], artist: data[index]['artist'], - mp3:data[index]['mp3'] + mp3:"/api/get-media/fileID/"+data[index]['mp3'] }; - }else if (data[index]['ogg'] != 'undefined') { + }else if (data[index]['oga'] != undefined) { media = {title: data[index]['title'], artist: data[index]['artist'], - oga:data[index]['ogg'] + oga:"/api/get-media/fileID/"+data[index]['oga'] }; } + console.log(media); myPlaylist[index] = media; idToPostionLookUp[data[index]['id']] = data[index]['position']; @@ -85,9 +87,10 @@ function playOne(audioFileID) { oga:"/api/get-media/fileID/"+audioFileID }; } - playlist[0] = media; - - playlist_jplayer.setPlaylist(playlist); playlist_jplayer.option("autoPlay", true); + + playlist[0] = media; + //playlist_jplayer.setPlaylist(playlist); --if I use this the player will call _init on the setPlaylist and on the ready + playlist_jplayer._initPlaylist(playlist); playlist_jplayer.play(0); } \ No newline at end of file