HTML5视频Javascript [英] HTML5 Video Javascript

查看:124
本文介绍了HTML5视频Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有Javascript经验,我有以下脚本在Andriod手机上播放视频文件,而且工作正常。

I am not experienced in Javascript, I have the following script to play video files on Andriod phone, and it works fine.

 <script type="text/javascript">
        function PlayMyVideo(arg) {
            var myVideo = document.getElementById([arg]);
            myVideo.play();
        }
    </script>
<video id="what" src="what.mp4" poster="" />
<input type="button" onclick="PlayMyVideo('what')" value="Play" />

我正在尝试动态写标签:

I am trying to write the tag on the fly:

  <script type="text/javascript">
        function PlayVideo() {
            new_video = document.createElement('video');
            new_video.setAttribute('scr', 'what.mp4'); 
            new_video.play(); 
         }
    </script>
<input type="button" onclick="PlayVideo()" value="Play2" />

什么都没发生,谢谢你的建议。
提前致谢

Nothing happen, would appreciate your suggestions. Thanks in advance

推荐答案

new_video.setAttribute('scr', 'what.mp4');

'scr'拼写错误。它应该是'src'。

'scr' is misspelled. It should be 'src'.

你还应该等到电影加载才能播放

and also you should wait for the movie to load before play

这篇关于HTML5视频Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆