diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index d32f2ad30..5a0d53cd9 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -150,8 +150,11 @@ class ApiController extends Zend_Controller_Action //user clicks play button for track and downloads it. header('Content-Disposition: inline; filename="'.$file_base_name.'"'); } - - $this->smartReadFile($filepath, 'audio/'.$ext); + if ($ext === 'mp3'){ + $this->smartReadFile($filepath, 'audio/mpeg'); + } else { + $this->smartReadFile($filepath, 'audio/'.$ext); + } exit; }else{ header ("HTTP/1.1 404 Not Found"); diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index b924ee4c0..2fe7b576f 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -64,14 +64,16 @@ class Application_Model_Schedule { $utcTimeNow = $date->getUtcTimestamp(); $shows = Application_Model_Show::getPrevCurrentNext($utcTimeNow); + $previousShowID = count($shows['previousShow'])>0?$shows['previousShow'][0]['id']:null; $currentShowID = count($shows['currentShow'])>0?$shows['currentShow'][0]['id']:null; - $results = Application_Model_Schedule::GetPrevCurrentNext($currentShowID, $utcTimeNow); + $nextShowID = count($shows['nextShow'])>0?$shows['nextShow'][0]['id']:null; + $results = Application_Model_Schedule::GetPrevCurrentNext($previousShowID, $currentShowID, $nextShowID, $utcTimeNow); $range = array("env"=>APPLICATION_ENV, "schedulerTime"=>$timeNow, - "previous"=>isset($results['previous'])?$results['previous']:(count($shows['previousShow'])>0?$shows['previousShow'][0]:null), - "current"=>isset($results['current'])?$results['current']:null, - "next"=> isset($results['next'])?$results['next']:(count($shows['nextShow'])>0?$shows['nextShow'][0]:null), + "previous"=>$results['previous'] !=null?$results['previous']:(count($shows['previousShow'])>0?$shows['previousShow'][0]:null), + "current"=>$results['current'] !=null?$results['current']:null, + "next"=> $results['next'] !=null?$results['next']:(count($shows['nextShow'])>0?$shows['nextShow'][0]:null), "currentShow"=>$shows['currentShow'], "nextShow"=>$shows['nextShow'], "timezone"=> date("T"), @@ -88,19 +90,39 @@ class Application_Model_Schedule { * show types are not found through this mechanism a call is made to the old way of querying * the database to find the track info. **/ - public static function GetPrevCurrentNext($p_currentShowID, $p_timeNow) + public static function GetPrevCurrentNext($p_previousShowID, $p_currentShowID, $p_nextShowID, $p_timeNow) { + if ($p_previousShowID == null && $p_currentShowID == null && $p_nextShowID == null) + return; + global $CC_CONFIG, $CC_DBC; - - if (!isset($p_currentShowID)) { - return array(); - } - $sql = "Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played + $sql = 'Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id - WHERE st.instance_id = '$p_currentShowID' AND st.playout_status > 0 - ORDER BY st.starts"; + WHERE '; + + if (isset($p_previousShowID)){ + if (isset($p_nextShowID) || isset($p_currentShowID)) + $sql .= '('; + $sql .= 'st.instance_id = '.$p_previousShowID; + } + if ($p_currentShowID != null){ + if ($p_previousShowID != null) + $sql .= ' OR '; + else if($p_nextShowID != null) + $sql .= '('; + $sql .= 'st.instance_id = '.$p_currentShowID; + } + if ($p_nextShowID != null) { + if ($p_previousShowID != null || $p_currentShowID != null) + $sql .= ' OR '; + $sql .= 'st.instance_id = '.$p_nextShowID; + if($p_previousShowID != null || $p_currentShowID != null) + $sql .= ')'; + } else if($p_previousShowID != null && $p_currentShowID != null) + $sql .= ')'; + + $sql .= ' AND st.playout_status > 0 ORDER BY st.starts'; - //Logging::log($sql); $rows = $CC_DBC->GetAll($sql); $numberOfRows = count($rows); diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index afd9255b7..60549df7a 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1762,7 +1762,9 @@ class Application_Model_Show { //Find the show that is within the current time. if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) >= $timeNowAsMillis)){ if ( $i - 1 >= 0){ - $results['previousShow'][0] = array("name"=>$rows[$i-1]['name'], + $results['previousShow'][0] = array( + "id"=>$rows[$i-1]['id'], + "name"=>$rows[$i-1]['name'], "start_timestamp"=>$rows[$i-1]['start_timestamp'], "end_timestamp"=>$rows[$i-1]['end_timestamp'], "starts"=>$rows[$i-1]['starts'], @@ -1772,7 +1774,9 @@ class Application_Model_Show { $results['currentShow'][0] = $rows[$i]; if ( isset($rows[$i+1])){ - $results['nextShow'][0] = array("name"=>$rows[$i+1]['name'], + $results['nextShow'][0] = array( + "id"=>$rows[$i+1]['id'], + "name"=>$rows[$i+1]['name'], "start_timestamp"=>$rows[$i+1]['start_timestamp'], "end_timestamp"=>$rows[$i+1]['end_timestamp'], "starts"=>$rows[$i+1]['starts'], @@ -1787,7 +1791,9 @@ class Application_Model_Show { } //if we hit this we know we've gone to far and can stop looping. if (strtotime($rows[$i]['starts']) > $timeNowAsMillis) { - $results['nextShow'][0] = array("name"=>$rows[$i]['name'], + $results['nextShow'][0] = array( + "id"=>$rows[$i]['id'], + "name"=>$rows[$i]['name'], "start_timestamp"=>$rows[$i]['start_timestamp'], "end_timestamp"=>$rows[$i]['end_timestamp'], "starts"=>$rows[$i]['starts'], @@ -1798,7 +1804,9 @@ class Application_Model_Show { //If we didn't find a a current show because the time didn't fit we may still have //found a previous show so use it. if (count($results['previousShow']) == 0 && isset($previousShowIndex)) { - $results['previousShow'][0] = array("name"=>$rows[$previousShowIndex]['name'], + $results['previousShow'][0] = array( + "id"=>$rows[$previousShowIndex]['id'], + "name"=>$rows[$previousShowIndex]['name'], "start_timestamp"=>$rows[$previousShowIndex]['start_timestamp'], "end_timestamp"=>$rows[$previousShowIndex]['end_timestamp'], "starts"=>$rows[$previousShowIndex]['starts'], diff --git a/airtime_mvc/public/js/jplayer/preview_jplayer.js b/airtime_mvc/public/js/jplayer/preview_jplayer.js index 2f6c2bd6f..e954a74b5 100644 --- a/airtime_mvc/public/js/jplayer/preview_jplayer.js +++ b/airtime_mvc/public/js/jplayer/preview_jplayer.js @@ -8,16 +8,22 @@ var _idToPostionLookUp; */ $(document).ready(function(){ + if (useFlash()) + mySupplied = "oga, mp3, m4v"; + else + mySupplied = "oga, mp3"; + _playlist_jplayer = new jPlayerPlaylist({ jPlayer: "#jquery_jplayer_1", cssSelectorAncestor: "#jp_container_1" },[], //array of songs will be filled with below's json call { swfPath: "/js/jplayer", - //supplied: "mp3,oga", + supplied:mySupplied, wmode: "window" }); + $.jPlayer.timeFormat.showHour = true; var audioFileID = $('.audioFileID').text(); @@ -35,6 +41,10 @@ $(document).ready(function(){ } }); +function useFlash() { + console.log(navigator.userAgent); + return navigator.userAgent.toLowerCase().match('firefox'); +} /** * Sets up the jPlayerPlaylist to play. * - Get the playlist info based on the playlistID give. @@ -122,7 +132,7 @@ function play(p_playlistIndex){ function playOne(p_audioFileID) { var playlist = new Array(); var fileExtensioin = p_audioFileID.split('.').pop(); - + console.log(p_audioFileID); if (fileExtensioin === 'mp3') { media = {title: $('.audioFileTitle').text() !== 'null' ?$('.audioFileTitle').text():"", artist: $('.audioFileArtist').text() !== 'null' ?$('.audioFileArtist').text():"", @@ -135,7 +145,7 @@ function playOne(p_audioFileID) { }; } _playlist_jplayer.option("autoPlay", true); - + console.log(media); 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); diff --git a/dev_tools/fabric/fab_liquidsoap_compile.cfg b/dev_tools/fabric/fab_liquidsoap_compile.cfg new file mode 100644 index 000000000..bf6d462d8 --- /dev/null +++ b/dev_tools/fabric/fab_liquidsoap_compile.cfg @@ -0,0 +1,2 @@ +[main] +liquidsoap_tar_url = http://dl.dropbox.com/u/256410/airtime/liquidsoap.tar.gz diff --git a/dev_tools/fabric/fab_liquidsoap_compile.py b/dev_tools/fabric/fab_liquidsoap_compile.py index 68064395d..06ca05730 100644 --- a/dev_tools/fabric/fab_liquidsoap_compile.py +++ b/dev_tools/fabric/fab_liquidsoap_compile.py @@ -10,6 +10,8 @@ import sys from fabric.api import * from fabric.contrib.files import comment, sed, append +from ConfigParser import ConfigParser + from xml.dom.minidom import parse from xml.dom.minidom import Node from xml.dom.minidom import Element @@ -157,7 +159,13 @@ def debian_squeeze_64(fresh_os=True): def compile_liquidsoap(filename="liquidsoap"): - + + config = ConfigParser() + config.readfp(open('fab_liquidsoap_compile.cfg')) + url = config.get('main', 'liquidsoap_tar_url') + + print "Will get liquidsoap from " + url + do_sudo('apt-get update') do_sudo('apt-get upgrade -y --force-yes') do_sudo('apt-get install -y --force-yes ocaml-findlib libao-ocaml-dev libportaudio-ocaml-dev ' + \ @@ -171,14 +179,15 @@ def compile_liquidsoap(filename="liquidsoap"): do_run('mkdir -p %s' % root) tmpPath = do_local("mktemp", capture=True) - do_run('wget %s -O %s' % ('https://downloads.sourceforge.net/project/savonet/liquidsoap/1.0.0/liquidsoap-1.0.0-full.tar.bz2', tmpPath)) - do_run('mv %s %s/liquidsoap-1.0.0-full.tar.bz2' % (tmpPath, root)) - do_run('cd %s && bunzip2 liquidsoap-1.0.0-full.tar.bz2 && tar xf liquidsoap-1.0.0-full.tar' % root) + do_run('wget %s -O %s' % (url, tmpPath)) + do_run('mv %s %s/liquidsoap.tar.gz' % (tmpPath, root)) + do_run('cd %s && tar xzf liquidsoap.tar.gz' % root) - do_run('cd %s/liquidsoap-1.0.0-full && cp PACKAGES.minimal PACKAGES' % root) - sed('%s/liquidsoap-1.0.0-full/PACKAGES' % root, '#ocaml-portaudio', 'ocaml-portaudio') - sed('%s/liquidsoap-1.0.0-full/PACKAGES' % root, '#ocaml-alsa', 'ocaml-alsa') - sed('%s/liquidsoap-1.0.0-full/PACKAGES' % root, '#ocaml-pulseaudio', 'ocaml-pulseaudio') - do_run('cd %s/liquidsoap-1.0.0-full && ./configure' % root) - do_run('cd %s/liquidsoap-1.0.0-full && make' % root) - get('%s/liquidsoap-1.0.0-full/liquidsoap-1.0.0/src/liquidsoap' % root, filename) + do_run('cd %s/savonet && cp PACKAGES.minimal PACKAGES' % root) + sed('%s/savonet/PACKAGES' % root, '#ocaml-portaudio', 'ocaml-portaudio') + sed('%s/savonet/PACKAGES' % root, '#ocaml-alsa', 'ocaml-alsa') + sed('%s/savonet/PACKAGES' % root, '#ocaml-pulseaudio', 'ocaml-pulseaudio') + do_run('cd %s/savonet && ./bootstrap' % root) + do_run('cd %s/savonet && ./configure' % root) + do_run('cd %s/savonet && make' % root) + get('%s/savonet/liquidsoap/src/liquidsoap' % root, filename)