简体   繁体   English

JwPlayer - 播放前显示视频截图

[英]JwPlayer - Show video screenshot before playing

I haven't been able to find anything on this so maybe someone can give me a hand我一直没能找到任何关于这个的东西,所以也许有人可以帮我一把

What I'm trying to do is when the JwPlayer loads, instead of the default black screen it currently shows, I'd like it to show a frame from the video it's set to play我想要做的是当 JwPlayer 加载时,而不是它当前显示的默认黑屏,我希望它显示它设置播放的视频中的帧

The following is the snippet of HTML and JS I use to load the JwPlayer以下是我用来加载 JwPlayer 的 HTML 和 JS 片段

<div id="video">
</div>

<script type="text/javascript" language="javascript">
        jwplayer("video").setup({ 
            height: 300,
            width: 620,
        autostart: false,
        volume: 50,
        file: "/video.mp4",
            modes: [
        {
                type: "html5",
                config: {
                    file: "/video.mp4"
                }
            },
        {
                type: "flash",
                src: "/player.swf"
            },
        {
                type: "download"
            }]
        }); 

</script>

Note that I don't have it set to autostart, so on load it just shows a black screen with a play button overlayed on the black screen请注意,我没有将其设置为自动启动,因此加载时它只显示黑屏,黑屏上覆盖有播放按钮

I know how to make it show an image instead of the black screen with an image attribute in the setup function, but that requires me to manually generate an image from the video and upload it to a server.我知道如何让它在设置功能中显示图像而不是带有图像属性的黑屏,但这需要我从视频中手动生成图像并将其上传到服务器。 I need it to be able to do it dynamically depending on the video我需要它能够根据视频动态执行

I looked at the JWPlayer documentation but couldn't find anything, so perhaps its not possible to even do, but was hoping maybe someone here knows better than I do我查看了 JWPlayer 文档但找不到任何东西,所以也许它甚至不可能做到,但希望这里有人比我更了解

Thanks!谢谢!

看起来快照插件可能正是您要找的。

I realize this question has been answered and accepted, however, an option would be to start the player and pause it immediately.我意识到这个问题已经得到回答并被接受,但是,一个选项是启动播放器并立即暂停它。 This worked for me:这对我有用:

onReady: function () {
    $this = this;
    this.play(); 
    var pauseMe = window.setTimeout(this.pause, 500); // sets auto poster
    ...
}

This only works of course if you want to show the first frame or so of your video;当然,这仅在您想显示视频的第一帧左右时才有效; grabbing a specific frame anywhere else in the video might work with seekTo(), and then play and pause, but you would likely get buffering delays.抓取视频中其他任何地方的特定帧可能会与 seekTo() 一起使用,然后播放和暂停,但您可能会遇到缓冲延迟。 I actually now need to grab an image from later in the video so will likely be trying that or ffmpeg :)实际上,我现在需要从视频的后面抓取图像,因此可能会尝试使用该图像或 ffmpeg :)

In the setup just add the "image"在设置中只需添加“图像”

jwplayer("myDiv").setup({
  "file": "http://example.com/myVideo.mp4",
  "image": "http://example.com/myImage.png",
  "height": 360,
  "width": 640
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM