libretime/legacy/application/forms/Player.php

88 lines
3.2 KiB
PHP
Raw Normal View History

2015-02-12 20:08:06 +01:00
<?php
2015-04-07 23:49:21 +02:00
define("OPUS", "opus");
2015-04-08 20:01:57 +02:00
class Application_Form_Player extends Zend_Form_SubForm
2015-02-12 20:08:06 +01:00
{
public function init()
{
$this->setDecorators(array(
2015-04-08 20:01:57 +02:00
array('ViewScript', array('viewScript' => 'form/player.phtml'))
2015-02-12 20:08:06 +01:00
));
2015-04-09 20:22:50 +02:00
$title = new Zend_Form_Element_Text('player_title');
$title->setValue(_('Now Playing'));
$title->setLabel(_('Title:'));
$title->setDecorators(array(
2015-04-09 15:43:15 +02:00
'ViewHelper',
'Errors',
'Label'
));
2015-04-09 20:22:50 +02:00
$title->addDecorator('Label', array('class' => 'player-title'));
2015-04-09 15:43:15 +02:00
$this->addElement($title);
2015-02-12 20:08:06 +01:00
$streamMode = new Zend_Form_Element_Radio('player_stream_mode');
$streamMode->setLabel(_('Select Stream:'));
$streamMode->setMultiOptions(
array(
2015-04-07 23:49:21 +02:00
"auto" => _("Auto detect the most appropriate stream to use."),
"manual" => _("Select a stream:")
)
);
2015-03-25 16:44:28 +01:00
$streamMode->setValue("auto");
$this->addElement($streamMode);
$streamURL = new Zend_Form_Element_Radio('player_stream_url');
$opusStreamCount = 0;
$urlOptions = Array();
foreach(Application_Model_StreamSetting::getEnabledStreamData() as $stream => $data) {
$urlOptions[$stream] = strtoupper($data["codec"])." - ".$data["bitrate"]."kbps";
if ($data["mobile"]) {
2015-04-07 23:49:21 +02:00
$urlOptions[$stream] .= _(" - Mobile friendly");
}
2015-04-07 23:49:21 +02:00
if ($data["codec"] == OPUS) {
$opusStreamCount += 1;
2015-04-07 23:49:21 +02:00
$urlOptions[$stream] .= _(" - The player does not support Opus streams.");
}
}
$streamURL->setMultiOptions(
$urlOptions
);
2015-04-07 23:49:21 +02:00
// Set default value to the first non-opus stream we find
foreach ($urlOptions as $o => $v) {
2015-04-07 23:49:21 +02:00
if (strpos(strtolower($v), OPUS) !== false) {
continue;
} else {
$streamURL->setValue($o);
break;
}
}
$streamURL->setAttrib('numberOfEnabledStreams', sizeof($urlOptions)-$opusStreamCount);
2015-04-08 20:01:57 +02:00
$streamURL->removeDecorator('label');
$this->addElement($streamURL);
2015-04-09 15:43:15 +02:00
$embedSrc = new Zend_Form_Element_Textarea('player_embed_src');
$embedSrc->setAttrib("readonly", "readonly");
$embedSrc->setAttrib("class", "embed-player-text-box");
2015-04-09 15:43:15 +02:00
$embedSrc->setAttrib('cols', '40')
->setAttrib('rows', '4');
2015-04-08 20:01:57 +02:00
$embedSrc->setLabel(_("Embeddable code:"));
2015-04-09 20:22:50 +02:00
$embedSrc->setDescription(_("Copy this code and paste it into your website's HTML to embed the player in your site."));
2015-04-10 16:55:39 +02:00
$embedSrc->setValue('<iframe frameborder="0" width="280" height="216" src="'.Application_Common_HTTPHelper::getStationUrl().'embed/player?stream=auto&title=Now Playing"></iframe>');
$this->addElement($embedSrc);
$previewLabel = new Zend_Form_Element_Text('player_preview_label');
2015-04-07 23:49:21 +02:00
$previewLabel->setLabel(_("Preview:"));
$previewLabel->setDecorators(array(
'ViewHelper',
'Errors',
'Label'
));
$previewLabel->addDecorator('Label', array('class' => 'preview-label'));
$this->addElement($previewLabel);
2015-02-12 20:08:06 +01:00
}
}