如何自动在查询上播放vimeo视频?

时间:2018-05-09 14:20:18

标签: javascript vimeo-api

一开始,视频会显示,但它会停止。 我希望在浏览器启动时播放视频。

import React, { Component } from 'react';

class Cppersons extends Component {

 myFocus () {
 this.lastref.current.focus() 
 }

 render() {

 //something

 return (

 <div> Something </div>

   )
  }
}
export default Cppersons;

1 个答案:

答案 0 :(得分:0)

froogaloop2 js现在无法正常使用 player.vimeo.com/api/player.js
试试这个

<iframe id="player" width="" height="" src="http://player.vimeo.com/video/62207569?api=1&player_id=player" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>

<script src="https://player.vimeo.com/api/player.js"></script>
<script>
    var frame = document.querySelector('iframe');
    var jqueryPlayer = new Vimeo.Player(frame);
    jqueryPlayer.play();
    console.log('played the video!');
</script>

我已经运行了这段代码,只需检查输出 enter image description here

您可以参考此https://github.com/vimeo/player.js#create-a-player了解详情。