problem adding vlc object via javascript in ie8 [resolved]

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
federico.perotto
New Cone
New Cone
Posts: 6
Joined: 14 May 2010 17:11

problem adding vlc object via javascript in ie8 [resolved]

Postby federico.perotto » 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).

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>
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
Last edited by federico.perotto on 18 Jun 2010 12:40, edited 1 time in total.

federico.perotto
New Cone
New Cone
Posts: 6
Joined: 14 May 2010 17:11

Re: problem adding vlc object via javascript in ie8

Postby federico.perotto » 18 Jun 2010 12:39

To see the video playing in ie you have to set the width and height of the <object> element after it is created.

Code: Select all

wrapper.innerHTML = '<object type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" width="720px" height="720px" 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>'; wrapper.firstChild.style.width = "720px"; wrapper.firstChild.style.height = "540px";


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 4 guests