How to play a video file?

How to play a video file?

Using VideoIO you can publish using real-time streaming (only rtmp or rtmfp URLs) but play using streaming (rtmp orrtmfp) as well as web download mode (http or https). Please see How to record and play a video message? for details on the streaming play mode. This tutorial will walk you through details on the web downloaded play mode.

If you want to play a video file that is already available on some web server, you can just set the src property with the URL of the FLV file. For example, there are some free FLV files here.

If you want to play your video files, e.g., the ones you recorded using VideoIO, you will need to serve your files from a web server. There are many free and commercial web servers in the market, e.g., Apache httpd. Information about how to set up a web server is beyond the scope of this tutorial.

Python comes with a built-in web server named SimpleHTTPServer that can server any file from your current directory or sub-directory. Suppose you have your video files in the current directory, you can start a web server as follows, then open a browser and point it to http://localhost:8080 to see the list of files in the directory where you ran this command.

$ python -m SimpleHTTPServer 8080

Suppose you have a video file named file1.flv which you can now reach using http://localhost:8080/file1.flv from a browser. For playing this file using VideoIO, just set this URL to the src property.

To programmatically set the property, use JavaScript as shown below. The example is similar to the one in How to record and play a video message? where you can set the src property of the VideoIO object named video1.


 
<object type="application/x-shockwave-flash" data="VideoIO.swf"
    id="video1" width="320" height="240">
    <param name="movie" value="VideoIO.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#000000" />
    <param name="allowFullScreen" value="true" />
    <param name="allowScriptAccess" value="always" />
    <param name="flashVars" value="controls=true" />
</object>
<script>
function getFlashMovie(movieName) {
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];  
}
</script>
<input id="src1" type="text"/>
<input value="set" type="button" 
    οnclick="getFlashMovie('video1').setProperty('src', 
        document.getElementById('src1').value)"/>
<input value="reset" type="button" 
    οnclick="getFlashMovie('video1').setProperty('src', null)"/>

This type of message playback with http or https URL is called web downloaded play mode. The control panel allows you to pause or play the media, or seek to a new position of the total duration is available using the play head bar. You can create your own JavaScript and HTML based user interface to control these properties of VideoIO.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值