首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使popcorn.js工作

无法使popcorn.js工作
EN

Stack Overflow用户
提问于 2016-11-08 21:40:56
回答 1查看 202关注 0票数 1

我认为这是一个非常基本/愚蠢的问题,但我不能理解我做错了什么……我想添加字幕和时间线到一个使用popcorn.js的html5视频。

下面是html5代码:

代码语言:javascript
复制
<script src="http://popcornjs.org/code/dist/popcorn-complete.js">
</script>
(...)
<nav id="timeline"> </nav>
(...)
<video id="video" controls>
        <source src="media/ita.webm" type="video/webm">
        <source src="media/ita.mp4" type="video/mp4">
</video>
(...)

下面是爆米花部分:

代码语言:javascript
复制
document.addEventListener( "DOMContentLoaded", function() {
  var popcorn = Popcorn('#video', { pauseOnLinkClicked: true });

  popcorn.timeline({
          start: 1,
          target: "timeline",
          title: "This is a title",
          text: "this is some interesting text that goes inside",
          innerHTML: "Click here for <a href='http://www.google.ca'>Google</a>" ,
          direction: "down"
        })
        .timeline({
          start: 3,
          target: "#timeline",
          title: "double as interesting",
          text: "this is some interesting text that goes inside",
          innerHTML: "Maybe a button? <button onClick=\"window.location.href='http://www.google.com'\">Click Me</button>",
          direction: "down"
        })
       .timeline({
          start: 7,
          end: 10,
          target: "#timeline",
          title: "3x as interesting",
          text: "this is some interesting text that goes inside",
          innerHTML: "",
          direction: "down"
        });

        popcorn.subtitle({
                start: 1,
                end: 5,
                text: "Subtitle",
            });

        popcorn.play();

}, false);

pauseOnLinkClicked: true是唯一起作用的部分...

EN

回答 1

Stack Overflow用户

发布于 2016-11-08 22:02:20

Here's what you've posted working in action.

在你的JS里

代码语言:javascript
复制
target: "timeline"

初始设置,但在设置之后

代码语言:javascript
复制
target: "#timeline"

时间线数组中的下一个元素。

HTML:

代码语言:javascript
复制
<html>
    <head>
        <title>PopcornJS Test</title>
        <script src="http://popcornjs.org/code/dist/popcorn-complete.js"></script>
    </head>

    <body>
        <nav id="timeline"></nav>
        <video id="video" controls>
            <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/webm">
            <source src="media/ita.mp4" type="video/mp4">
        </video>
    </body>
</html>

JS:

代码语言:javascript
复制
document.addEventListener("DOMContentLoaded", function() {
  var popcorn = Popcorn('#video', { pauseOnLinkClicked: true });

  popcorn.timeline({
          start: 1,
          target: "timeline",
          title: "This is a title",
          text: "this is some interesting text that goes inside",
          innerHTML: "Click here for <a href='http://www.google.ca'>Google</a>" ,
          direction: "down"
        })
        .timeline({
          start: 3,
          target: "timeline",
          title: "double as interesting",
          text: "this is some interesting text that goes inside",
          innerHTML: "Maybe a button? <button onClick=\"window.location.href='http://www.google.com'\">Click Me</button>",
          direction: "down"
        })
       .timeline({
          start: 7,
          end: 10,
          target: "timeline",
          title: "3x as interesting",
          text: "this is some interesting text that goes inside",
          innerHTML: "",
          direction: "down"
        });

        popcorn.subtitle({
            start: 1,
            end: 5,
            text: "Subtitle",
        });

        popcorn.play();

}, false);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40488434

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档