From 3c4d01aa9308224bd17616f91db8b4ad6e9bf783 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 24 Apr 2012 12:59:07 -0400 Subject: [PATCH] CC-3675: Playlist -> the files from Disconnected Mediafolder can still be previewed (played) - done --- .../controllers/AudiopreviewController.php | 4 ++-- .../controllers/ScheduleController.php | 2 +- airtime_mvc/application/models/Playlist.php | 20 +++++++++++++------ .../airtime/audiopreview/preview_jplayer.js | 7 ++++++- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/airtime_mvc/application/controllers/AudiopreviewController.php b/airtime_mvc/application/controllers/AudiopreviewController.php index 607d39dd8..efb14b7e4 100644 --- a/airtime_mvc/application/controllers/AudiopreviewController.php +++ b/airtime_mvc/application/controllers/AudiopreviewController.php @@ -98,7 +98,7 @@ class AudiopreviewController extends Zend_Controller_Action $pl = new Application_Model_Playlist($playlistID); $result = Array(); - foreach ( $pl->getContents() as $track ){ + foreach ( $pl->getContents(true) as $track ){ $elementMap = array( 'element_title' => isset($track['CcFiles']['track_title'])?$track['CcFiles']['track_title']:"", 'element_artist' => isset($track['CcFiles']['artist_name'])?$track['CcFiles']['artist_name']:"", @@ -115,7 +115,7 @@ class AudiopreviewController extends Zend_Controller_Action } $result[] = $elementMap; } - + $this->_helper->json($result); } diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index c71794a83..c5acd6ef3 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -373,7 +373,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->switch_status = $switch_status; $this->view->entries = $range; - $this->view->show_name = $show[0]["name"]; + $this->view->show_name = isset($show[0])?$show[0]["name"]:""; } public function removeGroupAction() diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index bc48bb2d0..63d33409a 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -140,18 +140,26 @@ class Application_Model_Playlist { /** * Get the entire playlist as a two dimentional array, sorted in order of play. + * @param boolean $filterFiles if this is true, it will only return files that has + * file_exists flag set to true * @return array */ - public function getContents() { + public function getContents($filterFiles=false) { Logging::log("Getting contents for playlist {$this->id}"); $files = array(); - $rows = CcPlaylistcontentsQuery::create() - ->joinWith('CcFiles') - ->orderByDbPosition() - ->filterByDbPlaylistId($this->id) - ->find($this->con); + $query = CcPlaylistcontentsQuery::create() + ->filterByDbPlaylistId($this->id); + + if($filterFiles){ + $query->useCcFilesQuery() + ->filterByDbFileExists(true) + ->endUse(); + } + $query->orderByDbPosition() + ->leftJoinWith('CcFiles'); + $rows = $query->find($this->con); $i = 0; $offset = 0; diff --git a/airtime_mvc/public/js/airtime/audiopreview/preview_jplayer.js b/airtime_mvc/public/js/airtime/audiopreview/preview_jplayer.js index 6d4975f25..cfcbe2c86 100644 --- a/airtime_mvc/public/js/airtime/audiopreview/preview_jplayer.js +++ b/airtime_mvc/public/js/airtime/audiopreview/preview_jplayer.js @@ -114,7 +114,9 @@ function buildplaylist(p_url, p_playIndex) { } myPlaylist[index] = media; - _idToPostionLookUp[data[index]['element_id']] = data[index]['element_position']; + // we should create a map according to the new position in the player itself + // total is the index on the player + _idToPostionLookUp[data[index]['element_id']] = total; total++; } @@ -135,6 +137,9 @@ function buildplaylist(p_url, p_playIndex) { */ function play(p_playlistIndex){ playlistIndex = _idToPostionLookUp[p_playlistIndex]; + if(playlistIndex == undefined){ + playlistIndex = 0 + } //_playlist_jplayer.select(playlistIndex); _playlist_jplayer.play(playlistIndex); }