javascript JWPlayer:加载后开始播放视频
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6889804/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JWPlayer: Start playing video after it loaded
提问by luqita
I need to show a video in a site automatically, but the customer wants it to be shown only after it starts playing. Is this possible?
我需要在网站上自动显示视频,但客户希望它在开始播放后才显示。这可能吗?
To explain this better, on document.ready I have the player.swf opening and then it starts playing the video. However, before showing the actual video, there are 2 or 3 seconds of buffering while the video loads and then it starts playing. How can I avoid showing these buffering seconds to the user? This way, when the box that plays the video opens it does with the video starting, with no buffering or loading wheels.
为了更好地解释这一点,在 document.ready 上,我打开了 player.swf,然后它开始播放视频。但是,在显示实际视频之前,视频加载时会有 2 或 3 秒的缓冲然后开始播放。如何避免向用户显示这些缓冲秒数?这样,当播放视频的框打开时,它会启动视频,没有缓冲或加载轮。
Any ideas?
有任何想法吗?
回答by Bernardo Bicalho
You need to call jwplayer().play();
你需要打电话 jwplayer().play();
After you setup player using jwplayer.setup()
, just make a call to jwplayer().play();
and video should start playing.
使用 设置播放器后jwplayer.setup()
,只需拨打电话即可jwplayer().play();
开始播放视频。
See the documentationfor more.
有关更多信息,请参阅文档。
回答by Hitesh
if you have not found answer yet than this might help
如果您还没有找到答案,这可能会有所帮助
It is quite easy in setup just include 'autostart : true'
I am using jwplayer 6
Autostart
Embedding jwplayer
设置非常简单,只需包含“autostart : true”
我正在使用 jwplayer 6
Autostart
Embedding jwplayer
<div id="myElement"></div>
<script>
jwplayer("myElement").setup({
file: "/uploads/myVideo.mp4",
image: "/uploads/myPoster.jpg",
autostart: true,
mute: true
});
</script>
And to avoid buffering in user end, you can have your own loader (buffering image) on Buffering...using
并且为了避免在用户端进行缓冲,您可以在 Buffering 上拥有自己的加载程序(缓冲图像)...使用
onBuffer() API in jwplayer .... so that user will understand that video is being loaded
jwplayer 中的 onBuffer() API .... 以便用户了解正在加载视频
onBuffer(callback)
Fired when the player enters the BUFFERING state. Event attributes:
oldstate (String): the state the player moved from. Can be IDLE, PLAYING or PAUSED.
onBuffer(callback)
当玩家进入 BUFFERING 状态时触发。事件属性: oldstate (String):玩家移动的状态。可以是空闲、播放或暂停。
回答by Bombcode
Have you tried seating the bufferlengthflashvar to 0? http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12536/configuration-options
您是否尝试将bufferlength flashvar 设置为 0? http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12536/configuration-options
It's flash only and won't work with the html5 player.
它仅是 flash,不能与 html5 播放器一起使用。
回答by user3085713
This is the comment issue i found when use JW flash player.
这是我在使用 JW Flash Player 时发现的评论问题。
I found one solution of it.
我找到了一种解决方案。
Open "player.xml" file in your wordpress plugin or JW Flash player config
在 wordpress 插件或 JW Flash 播放器配置中打开“player.xml”文件
Set the smoothing flashvar to false. Set the bufferlength flashvar to 1.
将平滑 flashvar 设置为 false。将 bufferlength flashvar 设置为 1。