Embed: custom streaminfo
This commit is contained in:
parent
4b1608646d
commit
aa3527dcb0
3 changed files with 41 additions and 25 deletions
|
@ -745,12 +745,13 @@ function mistPlay(streamName,options) {
|
|||
var local = options;
|
||||
var global = (typeof mistoptions == 'undefined' ? {} : mistoptions);
|
||||
var options = {
|
||||
host: null,
|
||||
autoplay: true,
|
||||
controls: true,
|
||||
loop: false,
|
||||
poster: null,
|
||||
callback: false
|
||||
host: null, //override mistserver host (default is the host that player.js is loaded from)
|
||||
autoplay: true, //start playing when loaded
|
||||
controls: true, //show controls (MistControls when available)
|
||||
loop: false, //don't loop when the stream has finished
|
||||
poster: null, //don't show an image before the stream has started
|
||||
callback: false, //don't call a function when the player has finished building
|
||||
streaminfo: false //don't use this streaminfo but collect it from the mistserverhost
|
||||
};
|
||||
for (var i in global) {
|
||||
options[i] = global[i];
|
||||
|
@ -781,28 +782,12 @@ function mistPlay(streamName,options) {
|
|||
}
|
||||
}
|
||||
|
||||
//get info js
|
||||
var info = document.createElement('script');
|
||||
info.src = options.host+'/info_'+encodeURIComponent(streamName)+'.js';
|
||||
embedLog('Retrieving stream info from '+info.src);
|
||||
document.head.appendChild(info);
|
||||
info.onerror = function(){
|
||||
options.target.innerHTML = '';
|
||||
options.target.removeAttribute('data-loading');
|
||||
mistError('Error while loading stream info.');
|
||||
protoplay.report({
|
||||
type: 'init',
|
||||
error: 'Failed to load '+info.src
|
||||
});
|
||||
}
|
||||
info.onload = function(){
|
||||
|
||||
function onstreaminfo() {
|
||||
options.target.innerHTML = '';
|
||||
options.target.removeAttribute('data-loading');
|
||||
embedLog('Stream info was loaded succesfully');
|
||||
|
||||
//clean up info script
|
||||
document.head.removeChild(info);
|
||||
|
||||
//get streaminfo data
|
||||
var streaminfo = mistvideo[streamName];
|
||||
//embedLog('Stream info contents: '+JSON.stringify(streaminfo));
|
||||
|
@ -1256,4 +1241,33 @@ function mistPlay(streamName,options) {
|
|||
mistError(str);
|
||||
}
|
||||
}
|
||||
if ((options.streaminfo) && (typeof options.streaminfo == 'object') && ('type' in options.streaminfo)
|
||||
&& ('source' in options.streaminfo) && (options.streaminfo.source.length)
|
||||
&& ('meta' in options.streaminfo) && ('tracks' in options.streaminfo.meta)) { //catch some of the most problematic stuff
|
||||
if (typeof mistvideo == 'undefined') { mistvideo = {}; }
|
||||
mistvideo[streamName] = options.streaminfo;
|
||||
onstreaminfo();
|
||||
}
|
||||
else {
|
||||
//get info js
|
||||
var info = document.createElement('script');
|
||||
info.src = options.host+'/info_'+encodeURIComponent(streamName)+'.js';
|
||||
embedLog('Retrieving stream info from '+info.src);
|
||||
document.head.appendChild(info);
|
||||
info.onerror = function(){
|
||||
options.target.innerHTML = '';
|
||||
options.target.removeAttribute('data-loading');
|
||||
mistError('Error while loading stream info.');
|
||||
protoplay.report({
|
||||
type: 'init',
|
||||
error: 'Failed to load '+info.src
|
||||
});
|
||||
}
|
||||
info.onload = function(){
|
||||
//clean up info script
|
||||
document.head.removeChild(info);
|
||||
|
||||
onstreaminfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,6 +85,8 @@
|
|||
//tryplayers.push('html5');
|
||||
tryplayers.push('dashjs');
|
||||
//tryplayers.push('videojs');
|
||||
tryplayers.push('img');
|
||||
//tryplayers.push('dashjs');
|
||||
//tryplayers.push('flash_strobe');
|
||||
//tryplayers.push('silverlight');
|
||||
streams = [];
|
||||
|
|
|
@ -580,7 +580,7 @@ namespace Mist {
|
|||
}
|
||||
if (it->asStringRef() == "img"){
|
||||
#include "img.js.h"
|
||||
response.append((char*)img, (size_t)img_len);
|
||||
response.append((char*)img_js, (size_t)img_js_len);
|
||||
used = true;
|
||||
}
|
||||
if (!used) {
|
||||
|
|
Loading…
Add table
Reference in a new issue