problem adding vlc object via javascript in ie8 [resolved]
Posted: 14 May 2010 18:11
Hi all,
the following code snippet works on firefox and chrome but not in ie8 (videolan 1.0.5 and windows server 2003).
I dynamically create the vlc plugin object inside a div, let vlc (auto)play to the end, then remove it.
In ie8 I can see messages in the console, it seems the video plays but it is not displayed in the web page.
Note that if i place the object tag directly in the web page it works as expected.
Anyone can tell me what is wrong?
Is it possibile add the vlc plugin object to the web page via javascript in ie?
Thanks
Federico
the following code snippet works on firefox and chrome but not in ie8 (videolan 1.0.5 and windows server 2003).
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<script type="text/javascript">
var vlc, vlc1, vlc2;
function VlcObjectManager (elemId, url)
{
var wrapperId = elemId;
var url = url;
var wrapper;
var vlc = null;
var that = this;
this.count = 0;
this.init = function(){
wrapper = document.getElementById(wrapperId);
console.log('init ' + wrapperId);
if (wrapper) {
console.log(wrapper);
if (window.attachEvent) { //is ie
wrapper.innerHTML = '<object type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" width="100%" height="100%" events="True" classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"><param name="MRL" value="'+url+'" /><param name="volume" value="50" /><param name="autoplay" value="true" /></object>';
}
else {
wrapper.innerHTML = '<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" width="720px" height="540px" target="'+ url +'"></embed>';
}
vlc = wrapper.firstChild;
// let it play for 15 seconds then remove it when playing ends
var playingEnded = setInterval(function(){
that.count++;
if (that.count > 30) {
console.log('is playing ended?');
if (!vlc.playlist.isPlaying) {
console.log('yes');
that.count = 0;
clearInterval(playingEnded);
that.end();
}
}
}, 500);
}
};
this.end = function(){
console.log('end ' + wrapperId);
wrapper.removeChild(vlc);
delete vlc;
vlc = null;
};
}
window.onload = function () {
vlc1 = new VlcObjectManager ("vlc1", "mymovie.avi");
vlc1.init();
}
</script>
</head>
<body>
<div id="vlc1"></div>
</body>
</html>
In ie8 I can see messages in the console, it seems the video plays but it is not displayed in the web page.
Note that if i place the object tag directly in the web page it works as expected.
Anyone can tell me what is wrong?
Is it possibile add the vlc plugin object to the web page via javascript in ie?
Thanks
Federico