如何用HTML5播放视频?

时间:2013-10-21 14:44:22

标签: asp.net html5

视频无法播放:

<asp:DataList ID="DL_Media" runat="server">
    <ItemTemplate>
        <video src="windowsmedia.ogg" controls="controls" width="215" height="160">
            <object id='mediaPlayer' width="215" height="160"
                        classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
                        codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
                        standby="Loading Microsoft Windows Media Player components..."
                        type="application/x-oleobject">
                <param name="fileName" value="res/Files/test.wmv" >
                <param name="animationatStart" value="true">
                <param name="transparentatStart" value="true">
                <param name="autoStart" value="true">
                <param name="showControls" value="true">
                <param name="loop" value="true">
            </object>
        </video>
    </ItemTemplate>
</asp:DataList>

2 个答案:

答案 0 :(得分:2)

确保您的浏览器兼容

首先,请确保browser you are attempting to view in supports the HTML 5 video element

示例代码

developer site at Mozilla

中无耻地采取行动

嵌入视频

<video src="http://v2v.cc/~j/theora_testsuite/320x240.ogg" controls>
  Your browser does not support the <code>video</code> element.
</video>

嵌入包含多个来源的视频

<video controls>
  <source src="foo.ogg" type="video/ogg">
  <source src="foo.mp4" type="video/mp4">
  Your browser does not support the <code>video</code> element.
</video>

指定所需的编解码器

<video controls>
  <source src="foo.ogg" type="video/ogg; codecs=dirac, speex">
  Your browser does not support the <code>video</code> element.
</video>

网站上的其他示例包括controlling playbackfallback options

答案 1 :(得分:0)

使用source代替对象

<video controls>
  <source src="res/Files/test.wmv" type="video/wmv"> 
  Your browser does not support the <code>video</code> element.
</video>