使用vlc的ActiveX控件播放視頻

最近項目中涉及到在web頁面中去播放一個.mp4格式的視頻文件。html

開始使用的是windows自帶的播放器,clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6web

發現播放不了視頻,由於視頻用的是.mp4格式,須要h264解碼,因此須要一個支持h264的windows

播放器。app


從網上看了一下vlc播放器,支持ActiveX,就下載了一個試試看。版本爲vlc-2.1.5-win32。ide

clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921 這個是objectid。oop


從網上搜了一下用法弄了半天才把視頻放出來,主要遇到了幾個問題。測試

·建議去看安裝目錄下的readme.txt裏面的內容挺具體。ui

·須要把ActiveX在系統中註冊一下orm

  註冊表信息視頻

  新建一個install.reg文件,內容以下

  Windows Registry Editor Version 5.00   //必須有這句話


  [HKEY_LOCAL_MACHINE\Software\VideoLAN\VLC] 

  InstallDir="C:\Program Files\VideoLAN\VLC"  //vlc安裝的路徑,必須在plugins文件的父文件夾


  新建一個install.bat文件,內容以下

  REGSVR32 C:\WINDOWS\AXVLC.DLL  //指向axvlc.dll文件的路徑,就在安裝路徑下能找到此dll


  按照上面的兩個步驟進行註冊。


  或者在install.bat文件中直接寫成這樣。

  regsvr32 axvlc.dll

  regedit /s install.reg


  readme.txt原文:

  

III. Local Install


The VLC NSIS installer will install the ActiveX Control without

requiring any further manual intervention, but for people who like to

live on the edge, here are the steps you need to perform once you have

built the ActiveX Control.


The ActiveX control DLL file may be copied anywhere on the target

machine, but before you can use the control, you will need to register

it with Windows by using the REGSVR32 command, as per following example:


REGSVR32 C:\WINDOWS\AXVLC.DLL


If the control needs to use external VLC plugins (i.e other than the

built-in ones), make sure that the plugin path is set in the registry as

per following example:


[HKEY_LOCAL_MACHINE\Software\VideoLAN\VLC]

InstallDir="C:\Program Files\VideoLAN\VLC"


The InstallDir must be the parent directory of the 'plugins' directory.


WARNING: Both control and plugins must come from the same source build

tree. Otherwise, at best, the control will not play any content,

at worse it may crash Internet Explorer while attempting to load

incompatible plugins.


·接下來測試是否能播放視頻文件了,這個弄了很久。

  在<param name="MRL" values="">這個屬性中進行播放視頻的設置,我試了好多種形式都沒能正常播放。最後發現values的地址值要加上file:///前綴。(本地視頻播放)

  代碼:  

<html>
<body>
    <div>
		<object id="vlc" type="application/x-vlc-plugin" width="600" height="400" classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" >
			<param name="src" value="file:///E:\\00_docs\\01_projects\\mp4\\test.mp4">
			<param name="autoloop" value="False" />
			<param name="autoplay" value="True" />
		</object>
    </div>
</body>
</html>

試了一下,下面的地址方式也是能夠播放的

file:///E:\00_docs\01_projects\mp4\test.mp4


cab製做


vlc屬性

1) Properties


The following public properties can be used to control the plugin

from HTML, the property panel of Visual Basic and most ActiveX aware

applications.


+==========+=========+===================================+===============+

| Name:    | Type:   |   Description:                    | Alias:        |

+==========+=========+===================================+===============+

| autoplay | boolean | play when control is activated    | autostart     |

+----------+---------+-----------------------------------+---------------+

| autoloop | boolean | loop the playlist                 | loop          |

+----------+---------+-----------------------------------+---------------+

| mrl      | string  | initial MRL in playlist           | src, filename |

+----------+---------+-----------------------------------+---------------+

| mute     | boolean | mute audio volume                 |               |

+----------+---------+-----------------------------------+---------------+

| visible  | boolean | show/hide control viewport        | showdisplay   |

+----------+---------+-----------------------------------+---------------+

| volume   | integer | set/get audio volume              |               |

+----------+---------+-----------------------------------+---------------+

| toolbar  | boolean | set/get visibility of the toolbar |               |

+----------+---------+-----------------------------------+---------------+


The alias column shows an alternative <PARAM name> for the property in

internet explorer, which is useful to maintain compatibility with HTML

pages already leveraging Windows Media Player


2) Programming APIs


The MRL, Autoplay and Autoloop properties are only used to configure the

initial state of the ActiveX control,i.e before its activation; they are

ignored afterward. Therefore, if some runtime control is required, the

following APIs should be used within your programming environment:


Variables:


+==========+=========+=========+=======================================+

| Name:    | Type:   | Access: | Description:                          |

+==========+=========+=========+=======================================+

| Playing  | boolean |   RO    | Returns whether some MRL is playing   |

+----------+---------+---------+---------------------------------------+

| Time     | integer |   RW    | Time elapsed in seconds playing       |

|          |         |         | current MRL                           |

|          |         |         | NOTE: live feeds returns 0            |

+----------+---------+---------+---------------------------------------+

| Position | real    |   RW    | Playback position within current MRL  |

|          |         |         | in a scale from 0.0 to 1.0            |

|          |         |         | NOTE: live feeds returns 0.0          |

+----------+---------+---------+---------------------------------------+

| Length   | integer |   RO    | Total length in seconds of current MRL|

|          |         |         | NOTE: live feeds returns 0            |

+----------+---------+---------+---------------------------------------+

| Volume   | integer |   RW    | Current volume from 0 to 100          |

+----------+---------+---------+---------------------------------------+

| Visible  | boolean |   RW    | Indicates whether control is visible  |

+----------+---------+---------+---------------------------------------+

相關文章
相關標籤/搜索