From 4eefc0536664418d61ddb73c675d14a80fd37dc3 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 13 Mar 2012 14:34:48 -0400 Subject: [PATCH] CC-3427: Live Stream: Ability to switch off Scheduled Play - done --- .../controllers/ScheduleController.php | 3 + .../application/layouts/scripts/builder.phtml | 3 +- .../application/layouts/scripts/layout.phtml | 3 +- .../application/layouts/scripts/library.phtml | 3 +- .../views/helpers/SourceSwitchStatus.php | 4 +- .../views/scripts/partialviews/header.phtml | 6 +- airtime_mvc/public/css/styles.css | 15 ++++ .../public/js/airtime/dashboard/playlist.js | 90 ++++++++----------- .../pypo/liquidsoap_scripts/ls_lib.liq | 14 --- .../pypo/liquidsoap_scripts/ls_script.liq | 23 ++++- python_apps/pypo/pypofetch.py | 6 +- 11 files changed, 91 insertions(+), 79 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 7d21795e8..57c285835 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -326,6 +326,8 @@ class ScheduleController extends Zend_Controller_Action $switch_status = array(); $live_dj = Application_Model_Preference::GetSourceStatus("live_dj"); $master_dj = Application_Model_Preference::GetSourceStatus("master_dj"); + + $scheduled_play_switch = Application_Model_Preference::GetSourceSwitchStatus("scheduled_play"); $live_dj_switch = Application_Model_Preference::GetSourceSwitchStatus("live_dj"); $master_dj_switch = Application_Model_Preference::GetSourceSwitchStatus("master_dj"); @@ -336,6 +338,7 @@ class ScheduleController extends Zend_Controller_Action $switch_status['live_dj_source'] = $live_dj_switch; $switch_status['master_dj_source'] = $master_dj_switch; + $switch_status['scheduled_play'] = $scheduled_play_switch; $this->view->switch_status = $switch_status; $this->view->entries = $range; diff --git a/airtime_mvc/application/layouts/scripts/builder.phtml b/airtime_mvc/application/layouts/scripts/builder.phtml index ad1bbe74d..782681d50 100644 --- a/airtime_mvc/application/layouts/scripts/builder.phtml +++ b/airtime_mvc/application/layouts/scripts/builder.phtml @@ -14,7 +14,8 @@ $sss = $this->SourceSwitchStatus(); $scs = $this->SourceConnectionStatus();?> partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), - "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'])) ?> + "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], + "scheduled_play_switch"=>$sss['scheduled_play'])) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/layouts/scripts/layout.phtml b/airtime_mvc/application/layouts/scripts/layout.phtml index cc6aa9ac1..39afbc8a9 100644 --- a/airtime_mvc/application/layouts/scripts/layout.phtml +++ b/airtime_mvc/application/layouts/scripts/layout.phtml @@ -16,7 +16,8 @@ $scs = $this->SourceConnectionStatus(); ?> partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), - "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'])) ?> + "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], + "scheduled_play_switch"=>$sss['scheduled_play'])) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/layouts/scripts/library.phtml b/airtime_mvc/application/layouts/scripts/library.phtml index 9a2400624..2fa4a1d42 100644 --- a/airtime_mvc/application/layouts/scripts/library.phtml +++ b/airtime_mvc/application/layouts/scripts/library.phtml @@ -15,7 +15,8 @@ $sss = $this->SourceSwitchStatus(); $scs = $this->SourceConnectionStatus(); ?> partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), - "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'])) ?> + "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], + "scheduled_play_switch"=>$sss['scheduled_play'])) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/views/helpers/SourceSwitchStatus.php b/airtime_mvc/application/views/helpers/SourceSwitchStatus.php index 2a8366aa0..86ca01707 100644 --- a/airtime_mvc/application/views/helpers/SourceSwitchStatus.php +++ b/airtime_mvc/application/views/helpers/SourceSwitchStatus.php @@ -2,7 +2,9 @@ class Airtime_View_Helper_SourceSwitchStatus extends Zend_View_Helper_Abstract{ public function SourceSwitchStatus(){ - $status = array("live_dj"=>Application_Model_Preference::GetSourceSwitchStatus("live_dj"), "master_dj"=>Application_Model_Preference::GetSourceSwitchStatus("master_dj")); + $status = array("live_dj"=>Application_Model_Preference::GetSourceSwitchStatus("live_dj"), + "master_dj"=>Application_Model_Preference::GetSourceSwitchStatus("master_dj"), + "scheduled_play"=>Application_Model_Preference::GetSourceSwitchStatus("scheduled_play")); return $status; } } \ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/partialviews/header.phtml b/airtime_mvc/application/views/scripts/partialviews/header.phtml index f58419750..1099c3871 100644 --- a/airtime_mvc/application/views/scripts/partialviews/header.phtml +++ b/airtime_mvc/application/views/scripts/partialviews/header.phtml @@ -23,9 +23,9 @@
diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index b6b11cd88..604cae66d 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -438,18 +438,33 @@ select { height:6px; border:1px solid #242424; border-width:1px 1px 0 1px; + margin-left: 5px; +} + +.line-to-switch.off{ background:#FFFFFF } +.line-to-switch.on{ + background:#D40000 +} + .line-to-on-air { float: right; height:6px; border:1px solid #242424; border-width:1px 1px 0 1px; width: 10px; +} + +.line-to-on-air.off{ background:#FFFFFF } +.line-to-on-air.on{ + background:#D$0000 +} + /* END Master Panel */ diff --git a/airtime_mvc/public/js/airtime/dashboard/playlist.js b/airtime_mvc/public/js/airtime/dashboard/playlist.js index ce25acc6e..11fd12517 100644 --- a/airtime_mvc/public/js/airtime/dashboard/playlist.js +++ b/airtime_mvc/public/js/airtime/dashboard/playlist.js @@ -15,7 +15,7 @@ var uiUpdateInterval = 200; var master_dj_on_air = false; var live_dj_on_air = false; -var airtime_on_air = false; +var scheduled_play_on_air = false; //var timezoneOffset = 0; @@ -80,22 +80,20 @@ function updateProgressBarValue(){ songPercentDone = 0; currentSong = null; } else { - var airtime_connection = $("#airtime_connection") + var scheduled_play_connection = $("#scheduled_play_connection").parent().find(".line-to-switch") if (currentSong.media_item_played == "t" && currentShow.length > 0){ - //$('#on-air-info').attr("class", "on-air-info on"); - airtime_connection.attr("class", "source-connection on"); - airtime_on_air = true; + scheduled_play_connection.attr("class", "line-to-switch on"); + //scheduled_play_on_air = true; } else{ - //$('#on-air-info').attr("class", "on-air-info off"); - airtime_on_air = false; - airtime_connection.attr("class", "source-connection off"); + //scheduled_play_on_air = false; + scheduled_play_connection.attr("class", "line-to-switch off"); } $('#progress-show').attr("class", "progress-show"); } } else { $('#on-air-info').attr("class", "on-air-info off"); - $("#airtime_connection").attr("class", "source-connection off"); + $("#scheduled_play_connection").parent().find(".line-to-switch").attr("class", "line-to-switch off"); $('#progress-show').attr("class", "progress-show-error"); } $('#progress-bar').attr("style", "width:"+songPercentDone+"%"); @@ -232,38 +230,20 @@ function parseItems(obj){ localRemoteTimeOffset = date.getTime() - schedulePosixTime; } -function changeLineToWhite(div){ - div.css("background", "#FFFFFF") -} - -function changeLineToRed(div){ - div.css("background", "#D40000") -} - -function ColorOnSourceConnection(div){ - div.attr("class", "source-connection on"); - changeLineToRed(div.parent().find(".line-to-switch")) -} - -function ColorOnSourceDisconnection(div){ - div.attr("class", "source-connection off"); - changeLineToWhite(div.parent().find(".line-to-switch")) -} - function parseSourceStatus(obj){ - var live_div = $("#live_dj_connection") - var master_div = $("#master_dj_connection") + var live_div = $("#live_dj_connection").parent().find(".line-to-switch") + var master_div = $("#master_dj_connection").parent().find(".line-to-switch") if(obj.live_dj_source == false){ - ColorOnSourceDisconnection(live_div) + live_div.attr("class", "line-to-switch off") }else{ - ColorOnSourceConnection(live_div) + live_div.attr("class", "line-to-switch on") } if(obj.master_dj_source == false){ - ColorOnSourceDisconnection(master_div) + master_div.attr("class", "line-to-switch off") }else{ - ColorOnSourceConnection(master_div) + master_div.attr("class", "line-to-switch on") } } @@ -272,26 +252,30 @@ function parseSwitchStatus(obj){ var master_div = $("#master_dj_connection") if(obj.live_dj_source == "on" && obj.master_dj_source == "off"){ - //changeLineToRed(live_div.parent().find(".line-to-on-air")) live_dj_on_air = true; }else{ - //changeLineToWhite(live_div.parent().find(".line-to-on-air")) live_dj_on_air = false; } if(obj.master_dj_source == "on"){ - //changeLineToRed(master_div.parent().find(".line-to-on-air")) master_dj_on_air = true; }else{ master_dj_on_air = false; - //changeLineToWhite(master_div.parent().find(".line-to-on-air")) } + + if(obj.scheduled_play == "on"){ + scheduled_play_on_air = true; + }else{ + scheduled_play_on_air = false; + } + + $("#scheduled_play.source-switch-button").find("span").html(obj.scheduled_play) $("#live_dj.source-switch-button").find("span").html(obj.live_dj_source) $("#master_dj.source-switch-button").find("span").html(obj.master_dj_source) } function controlOnAirLight(){ - if(airtime_on_air || live_dj_on_air || master_dj_on_air){ + if(scheduled_play_on_air || live_dj_on_air || master_dj_on_air){ $('#on-air-info').attr("class", "on-air-info on"); }else{ $('#on-air-info').attr("class", "on-air-info off"); @@ -301,24 +285,24 @@ function controlOnAirLight(){ function controlSwitchLight(){ var live_div = $("#live_dj_connection") var master_div = $("#master_dj_connection") - var airtime_div = $("#airtime_connection") + var scheduled_play_div = $("#scheduled_play_connection") - if(airtime_on_air && !live_dj_on_air && !master_dj_on_air){ - changeLineToRed(airtime_div.parent().find(".line-to-on-air")) - changeLineToWhite(live_div.parent().find(".line-to-on-air")) - changeLineToWhite(master_div.parent().find(".line-to-on-air")) + if(scheduled_play_on_air && !live_dj_on_air && !master_dj_on_air){ + scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air on") + live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") }else if(live_dj_on_air && !master_dj_on_air){ - changeLineToWhite(airtime_div.parent().find(".line-to-on-air")) - changeLineToRed(live_div.parent().find(".line-to-on-air")) - changeLineToWhite(master_div.parent().find(".line-to-on-air")) + scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air on") + master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") }else if(master_dj_on_air){ - changeLineToWhite(airtime_div.parent().find(".line-to-on-air")) - changeLineToWhite(live_div.parent().find(".line-to-on-air")) - changeLineToRed(master_div.parent().find(".line-to-on-air")) + scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air on") }else{ - changeLineToWhite(airtime_div.parent().find(".line-to-on-air")) - changeLineToWhite(live_div.parent().find(".line-to-on-air")) - changeLineToWhite(master_div.parent().find(".line-to-on-air")) + scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") + master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") } } @@ -361,7 +345,7 @@ function setSwitchListener(){ var sourcename = $(this).attr('id') var status_span = $(this).find("span") var status = status_span.html() - var _class = $(this).parent().find("div.source-connection").attr("class") + var _class = $(this).parent().find("div.line-to-switch").attr("class") var source_connection_status = false if(_class.indexOf("off") > 0){ diff --git a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq index ea4455028..cc515875a 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq @@ -26,20 +26,6 @@ def transition(a,b) = fade.final(duration=!default_dj_fade_out, a) ]) end -def transition_to_live(a,b) = - log("transition called...") - #add(normalize=false, - # [fade.initial(duration=5.,type="log", b),fade.final(duration=5.,type="log",a)]) - smooth_add(delay=10., normal=a, special=b) -end - -def transition_from_live(a,b) = - log("transition called...") - #add(normalize=false, - # [fade.initial(duration=5.,type="log", b),fade.final(duration=5.,type="log",a)]) - smooth_add(delay=10., normal=b, special=a) -end - def crossfade(s) #duration is automatically overwritten by metadata fields passed in #with audio diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index e0a337dc7..d1fd9dd06 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -45,6 +45,7 @@ ignore(output.dummy(default, fallible=true)) master_dj_enabled = ref false; live_dj_enabled = ref false; +scheduled_play_enabled = ref true; def make_master_dj_available() master_dj_enabled := true @@ -62,6 +63,14 @@ def make_live_dj_unavailable() live_dj_enabled := false end +def make_scheduled_play_available() + scheduled_play_enabled := true +end + +def make_scheduled_play_unavailable() + scheduled_play_enabled := false +end + #live stream setup set("harbor.bind_addr", "0.0.0.0") @@ -94,7 +103,6 @@ def check_master_dj_client(user,password) = ret = list.hd(ret) #return true to let the client transmit data, or false to tell harbor to decline if (ret == "True") then - #master_dj_connect() true else false @@ -108,7 +116,6 @@ def check_dj_client(user,password) = ret = list.hd(ret) #return true to let the client transmit data, or false to tell harbor to decline if (ret == "True") then - #live_dj_connect() true else false @@ -139,7 +146,7 @@ def append_dj_inputs(master_harbor_input_port, master_harbor_input_mount_point, end end -s = fallback(id="default_fallback", track_sensitive=false, [queue, default]) +s = switch(id="default_switch", track_sensitive=false, transitions=[transition, transition], [({!scheduled_play_enabled},queue),({true},default)]) s = append_dj_inputs(master_live_stream_port, master_live_stream_mp, dj_live_stream_port, dj_live_stream_mp, s) s = crossfade(s) @@ -182,6 +189,16 @@ server.register(namespace="streams", usage="live_dj_start", "live_dj_start", fun (s) -> begin make_live_dj_available() "Done." end) +server.register(namespace="streams", + description="Stop Scheduled Play source.", + usage="scheduled_play_stop", + "scheduled_play_stop", + fun (s) -> begin make_scheduled_play_unavailable() "Done." end) +server.register(namespace="streams", + description="Start Scheduled Play source.", + usage="scheduled_play_start", + "scheduled_play_start", + fun (s) -> begin make_scheduled_play_available() "Done." end) if output_sound_device then diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 7ec43a512..aeb50b7a4 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -107,9 +107,11 @@ class PypoFetch(Thread): command = "streams." if(sourcename == "master_dj"): command += "master_dj_" - else: + elif(sourcename == "live_dj"): command += "live_dj_" - + elif(sourcename == "scheduled_play"): + command += "scheduled_play_" + if(status == "on"): command += "start\n" else: