This repository was archived by the owner on Apr 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
This repository was archived by the owner on Apr 28, 2021. It is now read-only.
little emprovement for init call #13
Copy link
Copy link
Open
Description
hi ,
your project it is very interesting i m working for integrating it in my player :)
I emproved a bit the init call:
- style is copied by video el
- it is possible to create also if video element is not in the dom
- parent node is more generic
function init(onReady, options) {
if (!options) options={}
var polyfillSwfUrl=options.polyfillSwfUrl || 'fMSE.swf';
var flashByDefault=options.flashByDefault || false;
var videoElement=options.videoElement||null;
var parent=options.videoContainer||(videoElement&&videoElement.parentElement)||document.body;
var isMSESupported = !!window.MediaSource;
if (isMSESupported && !flashByDefault) {
return onReady(videoElement);
}
window.fMSE.debug=options.debug||false;
window.MediaSource = MediaSourceFlash;
window.fMSE.callbacks = window.fMSE.callbacks || {};
window.fMSE.callbacks.onFlashReady = function () {
onReady(new VideoExtension(swfObj));
};
var readyFunctionString = "window.fMSE.callbacks.onFlashReady";
var height = options.height||(videoElement&&videoElement.height) || 150;
var width = options.width || (videoElement&&videoElement.width) || 300;
var oldId , oldIdClasses ;
if (videoElement){
oldId = videoElement.id;
oldIdClasses = videoElement.className;
}
var swfObj = document.createElement("object");
oldId='e'
if (oldId) {
swfObj.setAttribute('id',oldId);
swfObj.setAttribute('name',oldId)
}
swfObj.setAttribute('type','application/x-shockwave-flash')
swfObj.setAttribute('data',polyfillSwfUrl)
swfObj.setAttribute('width',width)
swfObj.setAttribute('height',height)
if (oldIdClasses)swfObj.setAttribute('class',oldIdClasses)
swfObj.setAttribute('style','display:'+(videoElement &&videoElement.style.display?videoElement.style.display:'block'))
var param = document.createElement("param");
param.setAttribute('name','movie')
param.setAttribute('value',polyfillSwfUrl)
swfObj.appendChild(param);
param = document.createElement("param");
param.setAttribute('name','flashvars')
param.setAttribute('value',"readyFunction="+readyFunctionString)
swfObj.appendChild(param);
param = document.createElement("param");
param.setAttribute('name','allowScriptAccess')
param.setAttribute('value','always')
swfObj.appendChild(param);
param = document.createElement("param");
param.setAttribute('name','wmode')
param.setAttribute('value','opaque')
swfObj.appendChild(param);
param = document.createElement("param");
param.setAttribute('name','allowNetworking')
param.setAttribute('value','all')
swfObj.appendChild(param);
param = document.createElement("param");
param.setAttribute('name','bgcolor')
param.setAttribute('value','#000000')
swfObj.appendChild(param);
parent.appendChild(swfObj);
}
Metadata
Metadata
Assignees
Labels
No labels