首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >全屏不适用于clappr播放器

全屏不适用于clappr播放器
EN

Stack Overflow用户
提问于 2017-07-15 13:18:50
回答 1查看 2.3K关注 0票数 1

如何迫使Clappr播放器在更改视频后保持全屏?我编写了一个在PLAYER_ENDED事件上触发的函数,函数用这个load方法加载下一个视频:

代码语言:javascript
复制
enter code here`enter code here`player.load([{source: 'video_url_exmpl'}], null, true);

但当事件被触发和新的视频加载播放器取消全屏模式。我设置了选项:

代码语言:javascript
复制
exitFullscreenOnEnd: false,

我编写了一个插件,它假定可以切换全屏,但浏览器会抛出警告消息:

代码语言:javascript
复制
Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture

下面是我的Clappr播放器初始化和设置:

代码语言:javascript
复制
 player = new Clappr.Player({
        source: sourceUrl,
        parentId: "#player",
        autoPlay: true,
        width: '100%',
        height: '100%',
        exitFullscreenOnEnd: false,
        playInline: true,
        recycleVideo: Clappr.Browser.isMobile,
        poster: '',
    }).on(Clappr.Events.PLAYER_ENDED, function() {
           player.load([{source: 'video_url'}], null, true);
          }
    });
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-22 04:56:16

找到了官方Clappr GitHub问题的临时解决方案。多亏了kslimani

代码语言:javascript
复制
var player = new Clappr.Player({
  parentId: "#player-wrapper",
  source: 'http://clappr.io/highline.mp4',
  height: 360,
  width: 640,
  exitFullscreenOnEnd: false,
  playback: {
    playInline: true,
    recycleVideo: true,
  },
  events: {
    onEnded: function () {
      var setSource = function (newSrc) {
        this.core.options.source = newSrc;
        var container = this.core.getCurrentContainer();
        var playback = this.core.getCurrentPlayback();
        if (container) {
          container.options.source = newSrc;
        }
        if (playback) {
          playback.options.source = newSrc;
          playback._setupSrc && playback._setupSrc(newSrc);
        }
      }.bind(this);

      // Set another .mp4 source and start again player
      setSource('https://static.playmedia-cdn.net/resources/sample/h264_sintel_trailer-1080p.mp4');
      this.play();
    }
  }
});

请注意,这段代码是一个丑陋的技巧,它可能会让某些播放器组件(如插件)处于不一致的状态。只有当源代码格式相同时(即:所有源文件都是.mp4文件),才能完成此工作。但应该给你一些提示,从哪里开始挖掘。链接到Clappr GitHub威胁

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

https://stackoverflow.com/questions/45118638

复制
相关文章

相似问题

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