SAAS-662: Make player auto-connect if there is a problem with the stream
Kind of working in HTML5 mode
This commit is contained in:
parent
d0f7f820a7
commit
778df97d3c
|
@ -39,11 +39,11 @@ class EmbeddablePlayerController extends Zend_Controller_Action
|
||||||
$this->view->station_name = Application_Model_Preference::GetStationName();
|
$this->view->station_name = Application_Model_Preference::GetStationName();
|
||||||
$stream = $request->getParam('stream');
|
$stream = $request->getParam('stream');
|
||||||
$streamData = Application_Model_StreamSetting::getEnabledStreamData();
|
$streamData = Application_Model_StreamSetting::getEnabledStreamData();
|
||||||
|
$availableMobileStreams = array();
|
||||||
|
$availableDesktopStreams = array();
|
||||||
|
|
||||||
if ($stream == "auto") {
|
if ($stream == "auto") {
|
||||||
$this->view->playerMode = "auto";
|
$this->view->playerMode = "auto";
|
||||||
$availableMobileStreams = array();
|
|
||||||
$availableDesktopStreams = array();
|
|
||||||
foreach ($streamData as $s) {
|
foreach ($streamData as $s) {
|
||||||
if ($s["mobile"]) {
|
if ($s["mobile"]) {
|
||||||
array_push($availableMobileStreams, $s);
|
array_push($availableMobileStreams, $s);
|
||||||
|
@ -51,14 +51,14 @@ class EmbeddablePlayerController extends Zend_Controller_Action
|
||||||
array_push($availableDesktopStreams, $s);
|
array_push($availableDesktopStreams, $s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->view->availableMobileStreams = json_encode($availableMobileStreams);
|
|
||||||
$this->view->availableDesktopStreams = json_encode($availableDesktopStreams);
|
|
||||||
} else {
|
} else {
|
||||||
$this->view->playerMode = "manual";
|
$this->view->playerMode = "manual";
|
||||||
$selectedStreamData = $streamData[$stream];
|
$selectedStreamData = $streamData[$stream];
|
||||||
$this->view->streamURL = $selectedStreamData["url"];
|
$this->view->streamURL = $selectedStreamData["url"];
|
||||||
$this->view->codec = $selectedStreamData["codec"];
|
$this->view->codec = $selectedStreamData["codec"];
|
||||||
}
|
}
|
||||||
|
$this->view->availableMobileStreams = json_encode($availableMobileStreams);
|
||||||
|
$this->view->availableDesktopStreams = json_encode($availableDesktopStreams);
|
||||||
//$this->view->displayMetadata = $request->getParam('display_metadata');
|
//$this->view->displayMetadata = $request->getParam('display_metadata');
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,45 +9,35 @@
|
||||||
|
|
||||||
var MusesPlayer = function() {
|
var MusesPlayer = function() {
|
||||||
this.mobileDetect = this.mobileDetect();
|
this.mobileDetect = this.mobileDetect();
|
||||||
this.availableMobileStreamQueue = <?php echo $this->availableMobileStreams?>;
|
|
||||||
this.availableDesktopStreamQueue = <?php echo $this->availableDesktopStreams?>;
|
|
||||||
this.playerMode = "<?php echo $this->playerMode ?>";
|
this.playerMode = "<?php echo $this->playerMode ?>";
|
||||||
|
this.flashDetect = FlashDetect.versionAtLeast(10, 1) ? true : false;
|
||||||
|
this.settings = {
|
||||||
|
'volume': 100,
|
||||||
|
'jsevents': true,
|
||||||
|
'autoplay': false,
|
||||||
|
'buffering': 5,
|
||||||
|
'title': 'test',
|
||||||
|
'bgcolor': '#FFFFFF',
|
||||||
|
'skin': 'mcclean',
|
||||||
|
'width': 180,
|
||||||
|
'height': 60
|
||||||
|
};
|
||||||
|
|
||||||
if (this.playerMode == "manual") {
|
if (this.playerMode == "manual") {
|
||||||
MRP.insert({
|
this.settings.url = "<?php echo $this->streamURL ?>";
|
||||||
'url': "<?php echo $this->streamURL ?>",
|
this.settings.codec = "<?php echo $this->codec ?>";
|
||||||
'codec': "<?php echo $this->codec ?>",
|
MRP.insert(this.settings);
|
||||||
'volume': 100,
|
|
||||||
'jsevents': true,
|
|
||||||
'autoplay': false,
|
|
||||||
'buffering': 5,
|
|
||||||
'title': 'test',
|
|
||||||
'bgcolor': '#FFFFFF',
|
|
||||||
'skin': 'mcclean',
|
|
||||||
'width': 180,
|
|
||||||
'height': 60
|
|
||||||
});
|
|
||||||
} else if (this.playerMode == "auto") {
|
} else if (this.playerMode == "auto") {
|
||||||
|
this.availableMobileStreamQueue = <?php echo $this->availableMobileStreams?>;
|
||||||
|
this.availableDesktopStreamQueue = <?php echo $this->availableDesktopStreams?>;
|
||||||
var stream = this.getNextAvailableStream();
|
var stream = this.getNextAvailableStream();
|
||||||
MRP.insert({
|
this.settings.url = stream["url"];
|
||||||
'url': stream["url"],
|
this.settings.codec = stream["codec"];
|
||||||
'codec': stream["codec"],
|
MRP.insert(this.settings);
|
||||||
'volume': 100,
|
|
||||||
'jsevents': true,
|
|
||||||
'autoplay': false,
|
|
||||||
'buffering': 5,
|
|
||||||
'title': 'test',
|
|
||||||
'bgcolor': '#FFFFFF',
|
|
||||||
'skin': 'mcclean',
|
|
||||||
'width': 180,
|
|
||||||
'height': 60
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$("p.station_name").html("<?php echo $this->station_name?>");
|
$("p.station_name").html("<?php echo $this->station_name?>");
|
||||||
|
|
||||||
this.flashDetect = FlashDetect.versionAtLeast(10, 1) ? true : false;
|
|
||||||
|
|
||||||
getMetadata();
|
getMetadata();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,7 +85,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
MusesPlayer.prototype.play = function() {
|
MusesPlayer.prototype.play = function() {
|
||||||
this.flashDetect ? MRP.play() : musesHTMLPlayClick();
|
this.flashDetect ? MRP.play() : musesHTMLPlayClick();;
|
||||||
togglePlayStopButton();
|
togglePlayStopButton();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,43 +98,39 @@
|
||||||
//this.flashDetect ? MRP.setVolume(value) : null;
|
//this.flashDetect ? MRP.setVolume(value) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
MusesPlayer.prototype.setURL = function() {
|
MusesPlayer.prototype.setURL = function(url) {
|
||||||
//TODO
|
MRP.setUrl(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// detects errors in FLASH mode
|
||||||
function musesCallback(event,value) {
|
function musesCallback(event,value) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case "loadComplete":
|
|
||||||
// no source URL is set
|
|
||||||
if (value === "0") {
|
|
||||||
console.log("loadComplete failed");
|
|
||||||
}
|
|
||||||
case "ioError":
|
case "ioError":
|
||||||
// connection limit reached or problem connecting to stream
|
// connection limit reached or problem connecting to stream
|
||||||
if (value === "0") {
|
if (value === "0") {
|
||||||
console.log("ioError");
|
console.log("ioError");
|
||||||
|
var stream = musesPlayer.getNextAvailableStream();
|
||||||
|
musesPlayer.setURL(stream["url"]);
|
||||||
|
musesPlayer.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a hack to trigger the play button in HTML5 mode
|
|
||||||
*/
|
|
||||||
function musesHTMLPlayClick() {
|
function musesHTMLPlayClick() {
|
||||||
//child nodes
|
MRP.html.audio.src = MRP.html.src;
|
||||||
var cn = document.getElementById("MusesRadioPlayer-HTML5-player-1").childNodes;
|
|
||||||
var playDiv = cn[4];
|
MRP.html.audio.play();
|
||||||
playDiv.onclick();
|
|
||||||
|
// detects errors in HTML5 mode
|
||||||
|
MRP.html.audio.addEventListener('error', function failed(e) {
|
||||||
|
var stream = musesPlayer.getNextAvailableStream();
|
||||||
|
MRP.html.audio.src = stream["url"];
|
||||||
|
MRP.html.audio.play();
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a hack to trigger the stop button in HTML5 mode
|
|
||||||
*/
|
|
||||||
function musesHTMLStopClick() {
|
function musesHTMLStopClick() {
|
||||||
//child nodes
|
MRP.html.audio.pause();
|
||||||
var cn = document.getElementById("MusesRadioPlayer-HTML5-player-1").childNodes;
|
|
||||||
var stopDiv = cn[5];
|
|
||||||
stopDiv.onclick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function togglePlayStopButton() {
|
function togglePlayStopButton() {
|
||||||
|
@ -247,14 +233,5 @@
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--
|
|
||||||
<div id="custom_muses_play" onclick="musesPlayer.play()">
|
|
||||||
<a href="#">play</a>
|
|
||||||
</div>
|
|
||||||
<div id="custom_muses_stop" onclick="musesPlayer.stop()">
|
|
||||||
<a href="#">stop</a>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -2298,6 +2298,7 @@
|
||||||
this.ui = new d.UI(this, a);
|
this.ui = new d.UI(this, a);
|
||||||
a.autoplay && (a = window.navigator.userAgent.toLowerCase(), -1 == a.indexOf("iphone") && -1 == a.indexOf("ipad") && -1 == a.indexOf("ipod") &&
|
a.autoplay && (a = window.navigator.userAgent.toLowerCase(), -1 == a.indexOf("iphone") && -1 == a.indexOf("ipad") && -1 == a.indexOf("ipod") &&
|
||||||
this.playAudio())
|
this.playAudio())
|
||||||
|
n.MRP.html = this;
|
||||||
};
|
};
|
||||||
d.Muses.__name__ = !0;
|
d.Muses.__name__ = !0;
|
||||||
d.Muses.initTimer = function(a) {
|
d.Muses.initTimer = function(a) {
|
||||||
|
|
Loading…
Reference in New Issue