全屏不适用于 clappr 播放器
Fullscreen doesn't work with clappr player
如何强制 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);
}
});
在官方 Clappr GitHub Issues 上找到了临时解决方案。感谢 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 文件)。
但是应该给你一些提示,告诉你从哪里开始挖掘。
Link on Clappr GitHub threat
如何强制 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);
}
});
在官方 Clappr GitHub Issues 上找到了临时解决方案。感谢 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 文件)。 但是应该给你一些提示,告诉你从哪里开始挖掘。 Link on Clappr GitHub threat