CC-3405: Display to users how to connect a live stream to Airtime

- Done
This commit is contained in:
James 2012-03-09 18:48:23 -05:00
parent 540f262a77
commit 79f8eabe2b
8 changed files with 125 additions and 28 deletions

View file

@ -14,6 +14,7 @@ class PreferenceController extends Zend_Controller_Action
->addActionContext('is-import-in-progress', 'json') ->addActionContext('is-import-in-progress', 'json')
->addActionContext('change-stream-setting', 'json') ->addActionContext('change-stream-setting', 'json')
->addActionContext('get-liquidsoap-status', 'json') ->addActionContext('get-liquidsoap-status', 'json')
->addActionContext('set-source-connection-url', 'json')
->initContext(); ->initContext();
} }
@ -335,6 +336,19 @@ class PreferenceController extends Zend_Controller_Action
} }
die(json_encode($out)); die(json_encode($out));
} }
public function setSourceConnectionUrlAction(){
$request = $this->getRequest();
$type = $request->getParam("type", null);
$url = urldecode($request->getParam("url", null));
if($type == 'masterdj'){
Application_Model_Preference::SetMasterDJSourceConnectionURL($url);
}elseif($type == 'livedj'){
Application_Model_Preference::SetLiveDJSourceConnectionURL($url);
}
die();
}
} }

View file

@ -47,13 +47,8 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
->setDecorators(array('ViewHelper')); ->setDecorators(array('ViewHelper'));
$this->addElement($custom_password); $this->addElement($custom_password);
// hardcoded for now
$liquidsoap_host = 'localhost';
$liquidsoap_port = "8080";
$liquidsoap_mount_point = "test";
$this->setDecorators(array( $this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/add-show-live-stream.phtml', "connection_url"=>"http://$liquidsoap_host:$liquidsoap_port/$liquidsoap_mount_point")) array('ViewScript', array('viewScript' => 'form/add-show-live-stream.phtml', "connection_url"=>Application_Model_Preference::GetLiveDJSourceConnectionURL()))
)); ));
} }
} }

View file

@ -5,10 +5,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
public function init() public function init()
{ {
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml'))
));
//Master username //Master username
$master_username = new Zend_Form_Element_Text('master_username'); $master_username = new Zend_Form_Element_Text('master_username');
$master_username->setAttrib('autocomplete', 'off') $master_username->setAttrib('autocomplete', 'off')
@ -31,37 +27,51 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$this->addElement($master_password); $this->addElement($master_password);
//liquidsoap harbor.input port //liquidsoap harbor.input port
$port = new Zend_Form_Element_Text('master_harbor_input_port'); $m_port = Application_Model_StreamSetting::GetMasterLiveSteamPort();
$port->setLabel("Master DJ Port") $master_dj_port = new Zend_Form_Element_Text('master_harbor_input_port');
->setValue(Application_Model_StreamSetting::GetMasterLiveSteamPort()) $master_dj_port->setLabel("Master DJ Port")
->setValue($m_port)
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.'))) ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
->setDecorators(array('ViewHelper')); ->setDecorators(array('ViewHelper'));
$this->addElement($port); $this->addElement($master_dj_port);
$mount = new Zend_Form_Element_Text('master_harbor_input_mount_point'); $m_mount = Application_Model_StreamSetting::GetMasterLiveSteamMountPoint();
$mount->setLabel("Master DJ Mount Point") $master_dj_mount = new Zend_Form_Element_Text('master_harbor_input_mount_point');
->setValue(Application_Model_StreamSetting::GetMasterLiveSteamMountPoint()) $master_dj_mount->setLabel("Master DJ Mount Point")
->setValue($m_mount)
->setValidators(array( ->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered')))) array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper')); ->setDecorators(array('ViewHelper'));
$this->addElement($mount); $this->addElement($master_dj_mount);
//liquidsoap harbor.input port //liquidsoap harbor.input port
$port = new Zend_Form_Element_Text('dj_harbor_input_port'); $l_port = Application_Model_StreamSetting::GetDJLiveSteamPort();
$port->setLabel("DJ Port") $live_dj_port = new Zend_Form_Element_Text('dj_harbor_input_port');
->setValue(Application_Model_StreamSetting::GetDJLiveSteamPort()) $live_dj_port->setLabel("DJ Port")
->setValue($l_port)
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.'))) ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
->setDecorators(array('ViewHelper')); ->setDecorators(array('ViewHelper'));
$this->addElement($port); $this->addElement($live_dj_port);
$mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point'); $l_mount = Application_Model_StreamSetting::GetDJLiveSteamMountPoint();
$mount->setLabel("DJ Mount Point") $live_dj_mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point');
->setValue(Application_Model_StreamSetting::GetDJLiveSteamMountPoint()) $live_dj_mount->setLabel("DJ Mount Point")
->setValue($l_mount)
->setValidators(array( ->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered')))) array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper')); ->setDecorators(array('ViewHelper'));
$this->addElement($mount); $this->addElement($live_dj_mount);
$master_dj_connection_url = Application_Model_Preference::GetMasterDJSourceConnectionURL();
$live_dj_connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL();
$master_dj_connection_url = ($master_dj_connection_url == "")?("http://".$_SERVER['SERVER_NAME'].":".$m_port."/".$m_mount):$master_dj_connection_url;
$live_dj_connection_url = ($live_dj_connection_url == "")?"http://".$_SERVER['SERVER_NAME'].":".$l_port."/".$l_mount:$live_dj_connection_url;
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url,))
));
} }
} }

View file

@ -740,6 +740,22 @@ class Application_Model_Preference
return "on"; return "on";
} }
} }
public static function SetMasterDJSourceConnectionURL($value){
self::SetValue("master_dj_source_connection_url", $value, false);
}
public static function GetMasterDJSourceConnectionURL(){
return self::GetValue("master_dj_source_connection_url");
}
public static function SetLiveDJSourceConnectionURL($value){
self::SetValue("live_dj_source_connection_url", $value, false);
}
public static function GetLiveDJSourceConnectionURL(){
return self::GetValue("live_dj_source_connection_url");
}
/* User specific preferences end */ /* User specific preferences end */
} }

View file

@ -133,7 +133,6 @@ class Application_Model_StreamSetting {
if(!isset($exists["dj_live_stream_mp"])){ if(!isset($exists["dj_live_stream_mp"])){
$rows[] = (array("keyname" =>"dj_live_stream_mp", "value"=>self::GetDJLiveSteamMountPoint(), "type"=>"string")); $rows[] = (array("keyname" =>"dj_live_stream_mp", "value"=>self::GetDJLiveSteamMountPoint(), "type"=>"string"));
} }
Logging::log(print_r($rows, true));
return $rows; return $rows;
} }

View file

@ -3,7 +3,6 @@
class Airtime_View_Helper_SourceSwitchStatus extends Zend_View_Helper_Abstract{ class Airtime_View_Helper_SourceSwitchStatus extends Zend_View_Helper_Abstract{
public function SourceSwitchStatus(){ 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"));
Logging::log(print_r($status,true));
return $status; return $status;
} }
} }

View file

@ -57,6 +57,14 @@
</ul> </ul>
<?php endif; ?> <?php endif; ?>
</dd> </dd>
<dt id="master_dj_connection_url-label">
<label class="optional" for="master_dj_connection_url">Master DJ Connection URL:
</label>
</dt>
<dd id="master_dj_connection_url-element">
<span id="stream_url"><?php echo $this->master_dj_connection_url ?></span> <a href=# id="connection_url_override" style="font-size: 12px;">override</a><br>
<div id="master_dj_connection_url_tb" style="display:none"><input type="text"><a href=# id="ok" style="font-size: 12px;">OK</a> <a href=# id="reset" style="font-size: 12px;">RESET</a></div>
</dd>
<dt id="dj_harbor_input_port-label"> <dt id="dj_harbor_input_port-label">
<label class="optional" for="dj_harbor_input_port"><?php echo $this->element->getElement('dj_harbor_input_port')->getLabel() ?> : <label class="optional" for="dj_harbor_input_port"><?php echo $this->element->getElement('dj_harbor_input_port')->getLabel() ?> :
</label> </label>
@ -85,5 +93,13 @@
</ul> </ul>
<?php endif; ?> <?php endif; ?>
</dd> </dd>
<dt id="live_dj_connection_url-label">
<label class="optional" for="live_dj_connection_url">Live DJ Connection URL:
</label>
</dt>
<dd id="live_dj_connection_url-element">
<span id="stream_url"><?php echo $this->live_dj_connection_url ?></span> <a href=# id="connection_url_override" style="font-size: 12px;">override</a>
<div id="live_dj_connection_url_tb" style="display:none"><input type="text"><a href=# id="ok" style="font-size: 12px;">OK</a> <a href=# id="reset" style="font-size: 12px;">RESET</a></div>
</dd>
</dl> </dl>
</fieldset> </fieldset>

View file

@ -106,6 +106,52 @@ function checkLiquidsoapStatus(){
}); });
} }
function setLiveSourceConnectionOverrideListener(){
$("[id=connection_url_override]").click(function(){
var div_ele = $(this).parent().find("div[id$='_dj_connection_url_tb']")
div_ele.find(":input").val("")
div_ele.show()
})
// set action for "OK" and "X"
var live_dj_input = $("#live_dj_connection_url_tb")
var live_dj_label = live_dj_input.parent().find("span")
var master_dj_input = $("#master_dj_connection_url_tb")
var master_dj_label = master_dj_input.parent().find("span")
live_dj_input.find("#ok").click(function(){
var url = $(this).parent().find(":input").val()
live_dj_label.html(url)
live_dj_input.hide()
$.get("/Preference/set-source-connection-url/", {format: "json", type: "livedj", url:encodeURIComponent(url)});
})
live_dj_input.find("#reset").click(function(){
var port = $("#dj_harbor_input_port").val()
var mount = $("#dj_harbor_input_mount_point").val()
var url = "http://"+location.hostname+":"+port+"/"+mount
live_dj_label.html(url)
live_dj_input.hide()
$.get("/Preference/set-source-connection-url", {format: "json", type: "livedj", url:encodeURIComponent(url)});
})
master_dj_input.find("#ok").click(function(){
var url = $(this).parent().find(":input").val()
master_dj_label.html(url)
master_dj_input.hide()
$.get("/Preference/set-source-connection-url", {format: "json", type: "masterdj", url:encodeURIComponent(url)})
})
master_dj_input.find("#reset").click(function(){
var port = $("#master_harbor_input_port").val()
var mount = $("#master_harbor_input_mount_point").val()
var url = "http://"+location.hostname+":"+port+"/"+mount
master_dj_label.html(url)
master_dj_input.hide()
$.get("/Preference/set-source-connection-url", {format: "json", type: "masterdj", url:encodeURIComponent(url)})
})
}
$(document).ready(function() { $(document).ready(function() {
// initial stream url // initial stream url
@ -178,6 +224,8 @@ $(document).ready(function() {
return false; return false;
}) })
setLiveSourceConnectionOverrideListener()
showErrorSections() showErrorSections()
setInterval('checkLiquidsoapStatus()', 1000) setInterval('checkLiquidsoapStatus()', 1000)
$.mask.rules = { $.mask.rules = {