Ustream API - 在iframe播放器中寻找Javascript

时间:2014-11-20 20:48:22

标签: javascript api iframe embed

我想要寻找Ustream视频播放器到60秒进行exple

但它没有用。
我的代码出了什么问题?

<iframe id="UstreamIframe" src="//ustream.tv/embed/recorded/24364591" style="border: 0 none transparent; margin-top:1px;" frameborder="no" width="720" height="437"></iframe>

<a id="link1" href="javascript:;">0001</a>
<a id="link2" href="javascript:;">0001</a>
<a id="link3" href="javascript:;">0001</a>

<script src="http://static.ustream.tv/js/libs/ustream-embedapi.min.js"></script>

<script type="text/javascript">
  $(document).ready(function () {

    var viewer = UstreamEmbed("UstreamFrame");

    $('#link1').click(function(){ viewer.callMethod('seek', 60);})
    $('#link2').click(function(){ viewer.callMethod('seek', 90);})
    $('#link3').click(function(){ viewer.callMethod('seek', 120);})
  });
</script>

他们是这样做的:http://ustream.github.io/api-docs/embed-api/index.html

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

我设法这样做了:

如果可能,请让我的代码更简单,更简洁,更清洁。

<iframe src="http://www.ustream.tv/embed/recorded/24364591" id="UstreamFrame" width="640" height="392" style="border: 0 transparent none;"></iframe>
<br>
<a id="link1" href="javascript:;"><span>0sec</span></a><br>
<a id="link2" href="javascript:;"><span>60sec</span></a><br>
<a id="link3" href="javascript:;"><span>120sec</span></a><br>

<script src="http://static.ustream.tv/js/libs/ustream-embedapi.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var viewer = UstreamEmbed("UstreamFrame");

        $('#link1').click(function(){
            viewer.callMethod('seek', 0);
        });

        $('#link2').click(function(){
            viewer.callMethod('seek', 60);
        });

        $('#link3').click(function(){
            viewer.callMethod('seek', 120);
        });
    });
    </script>