标签:web视频播放mp4
最近项目中涉及到在web页面中去播放一个.mp4格式的视频文件。
开始使用的是windows自带的播放器,clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6
发现播放不了视频,因为视频用的是.mp4格式,需要h264解码,所以需要一个支持h264的
播放器。
从网上看了一下vlc播放器,支持ActiveX,就下载了一个试试看。版本为vlc-2.1.5-win32。
clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921 这个是objectid。
从网上搜了一下用法弄了半天才把视频放出来,主要遇到了几个问题。
·建议去看安装目录下的readme.txt里面的内容挺具体。
·需要把ActiveX在系统中注册一下
注册表信息
新建一个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 |
+----------+---------+---------+---------------------------------------+
标签:web视频播放mp4
原文地址:http://mingsuper.blog.51cto.com/8269088/1660090