Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
275fc7f987
6 changed files with 87 additions and 33 deletions
|
@ -150,8 +150,11 @@ class ApiController extends Zend_Controller_Action
|
||||||
//user clicks play button for track and downloads it.
|
//user clicks play button for track and downloads it.
|
||||||
header('Content-Disposition: inline; filename="'.$file_base_name.'"');
|
header('Content-Disposition: inline; filename="'.$file_base_name.'"');
|
||||||
}
|
}
|
||||||
|
if ($ext === 'mp3'){
|
||||||
$this->smartReadFile($filepath, 'audio/'.$ext);
|
$this->smartReadFile($filepath, 'audio/mpeg');
|
||||||
|
} else {
|
||||||
|
$this->smartReadFile($filepath, 'audio/'.$ext);
|
||||||
|
}
|
||||||
exit;
|
exit;
|
||||||
}else{
|
}else{
|
||||||
header ("HTTP/1.1 404 Not Found");
|
header ("HTTP/1.1 404 Not Found");
|
||||||
|
|
|
@ -64,14 +64,16 @@ class Application_Model_Schedule {
|
||||||
$utcTimeNow = $date->getUtcTimestamp();
|
$utcTimeNow = $date->getUtcTimestamp();
|
||||||
|
|
||||||
$shows = Application_Model_Show::getPrevCurrentNext($utcTimeNow);
|
$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;
|
$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,
|
$range = array("env"=>APPLICATION_ENV,
|
||||||
"schedulerTime"=>$timeNow,
|
"schedulerTime"=>$timeNow,
|
||||||
"previous"=>isset($results['previous'])?$results['previous']:(count($shows['previousShow'])>0?$shows['previousShow'][0]:null),
|
"previous"=>$results['previous'] !=null?$results['previous']:(count($shows['previousShow'])>0?$shows['previousShow'][0]:null),
|
||||||
"current"=>isset($results['current'])?$results['current']:null,
|
"current"=>$results['current'] !=null?$results['current']:null,
|
||||||
"next"=> isset($results['next'])?$results['next']:(count($shows['nextShow'])>0?$shows['nextShow'][0]:null),
|
"next"=> $results['next'] !=null?$results['next']:(count($shows['nextShow'])>0?$shows['nextShow'][0]:null),
|
||||||
"currentShow"=>$shows['currentShow'],
|
"currentShow"=>$shows['currentShow'],
|
||||||
"nextShow"=>$shows['nextShow'],
|
"nextShow"=>$shows['nextShow'],
|
||||||
"timezone"=> date("T"),
|
"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
|
* 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.
|
* 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;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
$sql = 'Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played
|
||||||
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
|
|
||||||
FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id
|
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
|
WHERE ';
|
||||||
ORDER BY st.starts";
|
|
||||||
|
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);
|
$rows = $CC_DBC->GetAll($sql);
|
||||||
$numberOfRows = count($rows);
|
$numberOfRows = count($rows);
|
||||||
|
|
||||||
|
|
|
@ -1762,7 +1762,9 @@ class Application_Model_Show {
|
||||||
//Find the show that is within the current time.
|
//Find the show that is within the current time.
|
||||||
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) >= $timeNowAsMillis)){
|
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) >= $timeNowAsMillis)){
|
||||||
if ( $i - 1 >= 0){
|
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'],
|
"start_timestamp"=>$rows[$i-1]['start_timestamp'],
|
||||||
"end_timestamp"=>$rows[$i-1]['end_timestamp'],
|
"end_timestamp"=>$rows[$i-1]['end_timestamp'],
|
||||||
"starts"=>$rows[$i-1]['starts'],
|
"starts"=>$rows[$i-1]['starts'],
|
||||||
|
@ -1772,7 +1774,9 @@ class Application_Model_Show {
|
||||||
$results['currentShow'][0] = $rows[$i];
|
$results['currentShow'][0] = $rows[$i];
|
||||||
|
|
||||||
if ( isset($rows[$i+1])){
|
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'],
|
"start_timestamp"=>$rows[$i+1]['start_timestamp'],
|
||||||
"end_timestamp"=>$rows[$i+1]['end_timestamp'],
|
"end_timestamp"=>$rows[$i+1]['end_timestamp'],
|
||||||
"starts"=>$rows[$i+1]['starts'],
|
"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 we hit this we know we've gone to far and can stop looping.
|
||||||
if (strtotime($rows[$i]['starts']) > $timeNowAsMillis) {
|
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'],
|
"start_timestamp"=>$rows[$i]['start_timestamp'],
|
||||||
"end_timestamp"=>$rows[$i]['end_timestamp'],
|
"end_timestamp"=>$rows[$i]['end_timestamp'],
|
||||||
"starts"=>$rows[$i]['starts'],
|
"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
|
//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.
|
//found a previous show so use it.
|
||||||
if (count($results['previousShow']) == 0 && isset($previousShowIndex)) {
|
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'],
|
"start_timestamp"=>$rows[$previousShowIndex]['start_timestamp'],
|
||||||
"end_timestamp"=>$rows[$previousShowIndex]['end_timestamp'],
|
"end_timestamp"=>$rows[$previousShowIndex]['end_timestamp'],
|
||||||
"starts"=>$rows[$previousShowIndex]['starts'],
|
"starts"=>$rows[$previousShowIndex]['starts'],
|
||||||
|
|
|
@ -8,16 +8,22 @@ var _idToPostionLookUp;
|
||||||
*/
|
*/
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
if (useFlash())
|
||||||
|
mySupplied = "oga, mp3, m4v";
|
||||||
|
else
|
||||||
|
mySupplied = "oga, mp3";
|
||||||
|
|
||||||
_playlist_jplayer = new jPlayerPlaylist({
|
_playlist_jplayer = new jPlayerPlaylist({
|
||||||
jPlayer: "#jquery_jplayer_1",
|
jPlayer: "#jquery_jplayer_1",
|
||||||
cssSelectorAncestor: "#jp_container_1"
|
cssSelectorAncestor: "#jp_container_1"
|
||||||
},[], //array of songs will be filled with below's json call
|
},[], //array of songs will be filled with below's json call
|
||||||
{
|
{
|
||||||
swfPath: "/js/jplayer",
|
swfPath: "/js/jplayer",
|
||||||
//supplied: "mp3,oga",
|
supplied:mySupplied,
|
||||||
wmode: "window"
|
wmode: "window"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$.jPlayer.timeFormat.showHour = true;
|
$.jPlayer.timeFormat.showHour = true;
|
||||||
|
|
||||||
var audioFileID = $('.audioFileID').text();
|
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.
|
* Sets up the jPlayerPlaylist to play.
|
||||||
* - Get the playlist info based on the playlistID give.
|
* - Get the playlist info based on the playlistID give.
|
||||||
|
@ -122,7 +132,7 @@ function play(p_playlistIndex){
|
||||||
function playOne(p_audioFileID) {
|
function playOne(p_audioFileID) {
|
||||||
var playlist = new Array();
|
var playlist = new Array();
|
||||||
var fileExtensioin = p_audioFileID.split('.').pop();
|
var fileExtensioin = p_audioFileID.split('.').pop();
|
||||||
|
console.log(p_audioFileID);
|
||||||
if (fileExtensioin === 'mp3') {
|
if (fileExtensioin === 'mp3') {
|
||||||
media = {title: $('.audioFileTitle').text() !== 'null' ?$('.audioFileTitle').text():"",
|
media = {title: $('.audioFileTitle').text() !== 'null' ?$('.audioFileTitle').text():"",
|
||||||
artist: $('.audioFileArtist').text() !== 'null' ?$('.audioFileArtist').text():"",
|
artist: $('.audioFileArtist').text() !== 'null' ?$('.audioFileArtist').text():"",
|
||||||
|
@ -135,7 +145,7 @@ function playOne(p_audioFileID) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
_playlist_jplayer.option("autoPlay", true);
|
_playlist_jplayer.option("autoPlay", true);
|
||||||
|
console.log(media);
|
||||||
playlist[0] = 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.setPlaylist(playlist); --if I use this the player will call _init on the setPlaylist and on the ready
|
||||||
_playlist_jplayer._initPlaylist(playlist);
|
_playlist_jplayer._initPlaylist(playlist);
|
||||||
|
|
2
dev_tools/fabric/fab_liquidsoap_compile.cfg
Normal file
2
dev_tools/fabric/fab_liquidsoap_compile.cfg
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[main]
|
||||||
|
liquidsoap_tar_url = http://dl.dropbox.com/u/256410/airtime/liquidsoap.tar.gz
|
|
@ -10,6 +10,8 @@ import sys
|
||||||
from fabric.api import *
|
from fabric.api import *
|
||||||
from fabric.contrib.files import comment, sed, append
|
from fabric.contrib.files import comment, sed, append
|
||||||
|
|
||||||
|
from ConfigParser import ConfigParser
|
||||||
|
|
||||||
from xml.dom.minidom import parse
|
from xml.dom.minidom import parse
|
||||||
from xml.dom.minidom import Node
|
from xml.dom.minidom import Node
|
||||||
from xml.dom.minidom import Element
|
from xml.dom.minidom import Element
|
||||||
|
@ -157,7 +159,13 @@ def debian_squeeze_64(fresh_os=True):
|
||||||
|
|
||||||
|
|
||||||
def compile_liquidsoap(filename="liquidsoap"):
|
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 update')
|
||||||
do_sudo('apt-get upgrade -y --force-yes')
|
do_sudo('apt-get upgrade -y --force-yes')
|
||||||
do_sudo('apt-get install -y --force-yes ocaml-findlib libao-ocaml-dev libportaudio-ocaml-dev ' + \
|
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)
|
do_run('mkdir -p %s' % root)
|
||||||
|
|
||||||
tmpPath = do_local("mktemp", capture=True)
|
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('wget %s -O %s' % (url, tmpPath))
|
||||||
do_run('mv %s %s/liquidsoap-1.0.0-full.tar.bz2' % (tmpPath, root))
|
do_run('mv %s %s/liquidsoap.tar.gz' % (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('cd %s && tar xzf liquidsoap.tar.gz' % root)
|
||||||
|
|
||||||
do_run('cd %s/liquidsoap-1.0.0-full && cp PACKAGES.minimal PACKAGES' % root)
|
do_run('cd %s/savonet && cp PACKAGES.minimal PACKAGES' % root)
|
||||||
sed('%s/liquidsoap-1.0.0-full/PACKAGES' % root, '#ocaml-portaudio', 'ocaml-portaudio')
|
sed('%s/savonet/PACKAGES' % root, '#ocaml-portaudio', 'ocaml-portaudio')
|
||||||
sed('%s/liquidsoap-1.0.0-full/PACKAGES' % root, '#ocaml-alsa', 'ocaml-alsa')
|
sed('%s/savonet/PACKAGES' % root, '#ocaml-alsa', 'ocaml-alsa')
|
||||||
sed('%s/liquidsoap-1.0.0-full/PACKAGES' % root, '#ocaml-pulseaudio', 'ocaml-pulseaudio')
|
sed('%s/savonet/PACKAGES' % root, '#ocaml-pulseaudio', 'ocaml-pulseaudio')
|
||||||
do_run('cd %s/liquidsoap-1.0.0-full && ./configure' % root)
|
do_run('cd %s/savonet && ./bootstrap' % root)
|
||||||
do_run('cd %s/liquidsoap-1.0.0-full && make' % root)
|
do_run('cd %s/savonet && ./configure' % root)
|
||||||
get('%s/liquidsoap-1.0.0-full/liquidsoap-1.0.0/src/liquidsoap' % root, filename)
|
do_run('cd %s/savonet && make' % root)
|
||||||
|
get('%s/savonet/liquidsoap/src/liquidsoap' % root, filename)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue