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 local = options;
|
||||||
var global = (typeof mistoptions == 'undefined' ? {} : mistoptions);
|
var global = (typeof mistoptions == 'undefined' ? {} : mistoptions);
|
||||||
var options = {
|
var options = {
|
||||||
host: null,
|
host: null, //override mistserver host (default is the host that player.js is loaded from)
|
||||||
autoplay: true,
|
autoplay: true, //start playing when loaded
|
||||||
controls: true,
|
controls: true, //show controls (MistControls when available)
|
||||||
loop: false,
|
loop: false, //don't loop when the stream has finished
|
||||||
poster: null,
|
poster: null, //don't show an image before the stream has started
|
||||||
callback: false
|
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) {
|
for (var i in global) {
|
||||||
options[i] = global[i];
|
options[i] = global[i];
|
||||||
|
@ -781,28 +782,12 @@ function mistPlay(streamName,options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//get info js
|
|
||||||
var info = document.createElement('script');
|
function onstreaminfo() {
|
||||||
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(){
|
|
||||||
options.target.innerHTML = '';
|
options.target.innerHTML = '';
|
||||||
options.target.removeAttribute('data-loading');
|
options.target.removeAttribute('data-loading');
|
||||||
embedLog('Stream info was loaded succesfully');
|
embedLog('Stream info was loaded succesfully');
|
||||||
|
|
||||||
//clean up info script
|
|
||||||
document.head.removeChild(info);
|
|
||||||
|
|
||||||
//get streaminfo data
|
//get streaminfo data
|
||||||
var streaminfo = mistvideo[streamName];
|
var streaminfo = mistvideo[streamName];
|
||||||
//embedLog('Stream info contents: '+JSON.stringify(streaminfo));
|
//embedLog('Stream info contents: '+JSON.stringify(streaminfo));
|
||||||
|
@ -1256,4 +1241,33 @@ function mistPlay(streamName,options) {
|
||||||
mistError(str);
|
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('html5');
|
||||||
tryplayers.push('dashjs');
|
tryplayers.push('dashjs');
|
||||||
//tryplayers.push('videojs');
|
//tryplayers.push('videojs');
|
||||||
|
tryplayers.push('img');
|
||||||
|
//tryplayers.push('dashjs');
|
||||||
//tryplayers.push('flash_strobe');
|
//tryplayers.push('flash_strobe');
|
||||||
//tryplayers.push('silverlight');
|
//tryplayers.push('silverlight');
|
||||||
streams = [];
|
streams = [];
|
||||||
|
|
|
@ -580,7 +580,7 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
if (it->asStringRef() == "img"){
|
if (it->asStringRef() == "img"){
|
||||||
#include "img.js.h"
|
#include "img.js.h"
|
||||||
response.append((char*)img, (size_t)img_len);
|
response.append((char*)img_js, (size_t)img_js_len);
|
||||||
used = true;
|
used = true;
|
||||||
}
|
}
|
||||||
if (!used) {
|
if (!used) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue