serve simple webm as fallback for multiquality player

This commit is contained in:
Anton Schubert 2017-12-28 12:27:51 +01:00 committed by MaZderMind
parent d29fa32763
commit 870bacae02
2 changed files with 28 additions and 12 deletions

View file

@ -123,15 +123,19 @@ class Stream
]);
}
public function getVideoUrl($proto)
public function getVideoUrl($proto, $selection=null)
{
if (!$selection) {
$selection = $this->getSelection();
}
switch($proto)
{
case 'webm':
return proto().'://cdn.c3voc.de/'.rawurlencode($this->getRoom()->getStream()).'_'.rawurlencode($this->getLanguage()).'_'.rawurlencode($this->getSelection()).'.webm';
return proto().'://cdn.c3voc.de/'.rawurlencode($this->getRoom()->getStream()).'_'.rawurlencode($this->getLanguage()).'_'.rawurlencode($selection).'.webm';
case 'hls':
return proto().'://cdn.c3voc.de/hls/'.rawurlencode($this->getRoom()->getStream()).'_'.rawurlencode($this->getLanguage()).'_'.rawurlencode($this->getSelection()).'.m3u8';
return proto().'://cdn.c3voc.de/hls/'.rawurlencode($this->getRoom()->getStream()).'_'.rawurlencode($this->getLanguage()).'_'.rawurlencode($selection).'.m3u8';
}
return null;

View file

@ -36,9 +36,9 @@
});
}
var createPlayer = function(url) {
var player = new Clappr.Player({
source: url,
var createPlayer = function(sources) {
return new Clappr.Player({
sources: sources,
width: "100%",
plugins: [DashShakaPlayback, LevelSelector, AudioSelector],
shakaConfiguration: {
@ -74,12 +74,24 @@
});
}
// Detect WebM capability, Select relay, Create player
var hasWebM = document.createElement('video').canPlayType('video/webm') != "";
var cdnUrl = hasWebM ? '<?=h($room->getDashManifestUrl())?>' : '<?=h($room->getHLSPlaylistUrl())?>';
selectRelay(cdnUrl, function(relayUrl) {
createPlayer(relayUrl);
});
var hasMSE = 'MediaSource' in window,
hasWebM = document.createElement('video').canPlayType('video/webm') != "",
nativeHLS = document.createElement('video').canPlayType('application/vnd.apple.mpegURL') != "";
// Play Multiquality only if supported
if (hasMSE || nativeHLS) {
// Detect WebM capability, Select relay, Create player
var cdnUrl = hasWebM ? '<?=h($room->getDashManifestUrl())?>' : '<?=h($room->getHLSPlaylistUrl())?>';
selectRelay(cdnUrl, function(relayUrl) {
createPlayer([{source: relayUrl}]);
});
} else {
// Default to simple WebM playback
var player = createPlayer([{
source: "<?=h($stream->getVideoUrl('webm', 'hd'))?>",
mimeType: "video/webm"
}]);
}
}());
</script>