开发者

Playing video on a web browser from a web server

I need to play videos stored on a web server from a web browser.

I was thinking of using Flash to achieve this. I found this article http://www.republicofcode.com/tutorials/flash/video_flvplayback/

Is there a better 开发者_JS百科approach? Also when the video is playing or is paused, I'd like to be able to read the current time of playback from the browser (I guess through Javascript). Would Javascript be able to retrieve this time from the flash player?

Thanks and regards, Krt_Malta


No, no and no. Flash is the worst way to embed videos in websites, as the plugin creates speed and security drawbacks. Try using the HTML <video> tag, which embeds video without the need for any plugin. The syntax is as follows:

<video width="..." height="..." src="..."></video>

autoplay, controls, loop and preload are optional attributes.

To get the current elapsed time, use the currentTime property of the tag:

myVideo.elapsedTime

To get the duration of the video, use the duration property:

myVideo.duration


You should cosider using a special module for your webserver not to send media files with full bandwidth as the clients won't cache hundreds of megabytes. It alsouses unneccessarily high bandwidth.

The correct strategy is to send one or two megabytes of the data with full bandwidth, then throttle the transfer to the bitrate of the video itself. There are a few experimental apache modules which do that, or you can write a minimal PHP script too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜