2012-07-27 103 views
0

我使用VLC Webplugin在Chrome捕获MediaPlayerPlaying事件

<div id="div-vlc" style="display: none;"> 
    <embed id="vlc" name="vlc" width="640" height="480" pluginspage="http://www.videolan.org" type="application/x-vlc-plugin" /> 
    <object style="width:0px;height:0px;" classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" codebase="http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab"> </object> 
</div> 

并试图捕捉事件来控制与播放:

document.vlc.addEventListener('MediaPlayerPlaying', function() {alert();}) 

document.vlc.attachEvent('MediaPlayerPlaying', function() {alert();}) //crash 

像这样的文档说:http://wiki.videolan.org/Documentation:WebPlugin

但事件从未被解雇。

出了什么问题?

回答

0

一些注意事项:

  • 首先,它不会工作,如果你将使“显示:无”。
  • 其次,嵌入中必须有src/target。
  • 最后但并非最不重要的是,对象的大小必须至少为1x1px。

这将提醒回调:

var vlc=document.getElementById('vlc'); 
vlc.addEventListener("MediaPlayerPlaying", function(event) {alert(event);}, false); 
vlc.playlist.play();  

请注意,这是对Firefox &铬。由于IE使用ActiveX,所以使用另一种表示法。有关完整的文档,请访问https://wiki.videolan.org/Documentation:WebPlugin/

1

只是想了解一下当dinamically加载时ASP.NET对VLC所做的一件奇怪事情。

当在aspx.cs或ascx.cs中以像素为单位设置特定的宽度和高度时,ASP.NET向ActiveX返回错误的宽度和高度属性。示例:

aspx.cs或ascx.cs文件:当客户端是IE8或

myLiteral.Text = @"<object type='application/x-vlc-plugin' 
width='150px' height='100px' 
pluginspage='http://www.videolan.org' version='VideoLAN.VLCPlugin.2' events='True' classid='clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921'>Check activex settings</object>"; 

HTML返回更大:

<object type='application/x-vlc-plugin' 
width=0px height=0px style='HEIGHT:0px;WIDTH:0px;TOP:0px;LEFT:0px' pluginspage='http://www.videolan.org' version='VideoLAN.VLCPlugin.2' events='True' classid='clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921'>Check activex settings</object> 

在IE8和IE9只发生在第一VLC的ActiveX 。在IE10中,它发生在所有的VLC ActiveX中。

我的解决方法是在我的VLC加载JavaScript一点的jQuery:

$(plugin).width(playerWidth); 
$(plugin).height(playerHeight); 
$(plugin).attr('style', ''); 

希望它可以帮助:-)

1

顺便说一句,在https://wiki.videolan.org/Documentation:WebPlugin/的信息在以后的版本已经过时。

代码库网址'http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab'不存在了...

下一直很好,我:

<object type='application/x-vlc-plugin' pluginspage='http://www.videolan.org' version='VideoLAN.VLCPlugin.2' id='vlc1' width='100px' height='150px' events='True' classid='clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921'> 
    <param name='MRL' value='' /> 
    <param name='toolbar' value='false' /> 
    <param name='autoplay' value='false' /> 
    <param name='loop' value='false' /> 
    <param name='allowfullscreen' value='true' /> 
ActiveX not loaded. Check IE settings</object> 

的Javascript:

var plugin = document.getElementById('vlc1'); 
$(plugin).width(playerWidth); 
$(plugin).height(playerHeight); 
$(plugin).attr('style', ''); 
// Add items to plugin.playlist