如何迫使Clappr播放器在更改视频后保持全屏?我编写了一个在PLAYER_ENDED事件上触发的函数,函数用这个load方法加载下一个视频:
enter code here`enter code here`player.load([{source: 'video_url_exmpl'}], null, true);但当事件被触发和新的视频加载播放器取消全屏模式。我设置了选项:
exitFullscreenOnEnd: false,我编写了一个插件,它假定可以切换全屏,但浏览器会抛出警告消息:
Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture下面是我的Clappr播放器初始化和设置:
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);
}
});发布于 2017-08-22 04:56:16
找到了官方Clappr GitHub问题的临时解决方案。多亏了kslimani。
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威胁
https://stackoverflow.com/questions/45118638
复制相似问题