Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c256a045f9 | ||
|
|
98603439cb | ||
|
|
a6ca011202 | ||
|
|
114c2572a4 | ||
|
f64b362603
|
@@ -20,6 +20,29 @@
|
||||
// TODO: Call abort to cancel in-progress appends?
|
||||
|
||||
|
||||
// Buffer sizes for different systems
|
||||
const BUFFER_CONFIG = {
|
||||
default: 50 * 10**6, // 50 megabytes
|
||||
webOS: 20 * 10**6, // 20 megabytes WebOS (LG)
|
||||
samsungTizen: 20 * 10**6, // 20 megabytes Samsung Tizen OS
|
||||
androidTV: 30 * 10**6, // 30 megabytes Android TV
|
||||
desktop: 50 * 10**6, // 50 megabytes PC/Mac
|
||||
};
|
||||
|
||||
function detectSystem() {
|
||||
const userAgent = navigator.userAgent.toLowerCase();
|
||||
if (/webos|lg browser/i.test(userAgent)) {
|
||||
return "webOS";
|
||||
} else if (/tizen/i.test(userAgent)) {
|
||||
return "samsungTizen";
|
||||
} else if (/android tv|smart-tv/i.test(userAgent)) {
|
||||
return "androidTV";
|
||||
} else if (/firefox|chrome|safari|edge/i.test(userAgent)) {
|
||||
return "desktop";
|
||||
} else {
|
||||
return "default";
|
||||
}
|
||||
}
|
||||
|
||||
function AVMerge(video, srcInfo, startTime){
|
||||
this.audioSource = null;
|
||||
@@ -164,6 +187,8 @@ AVMerge.prototype.printDebuggingInfo = function() {
|
||||
}
|
||||
|
||||
function Stream(avMerge, source, startTime, avRatio) {
|
||||
const selectedSystem = detectSystem();
|
||||
let baseBufferTarget = BUFFER_CONFIG[selectedSystem] || BUFFER_CONFIG.default;
|
||||
this.avMerge = avMerge;
|
||||
this.video = avMerge.video;
|
||||
this.url = source['url'];
|
||||
@@ -173,10 +198,11 @@ function Stream(avMerge, source, startTime, avRatio) {
|
||||
this.mimeCodec = source['mime_codec']
|
||||
this.streamType = source['acodec'] ? 'audio' : 'video';
|
||||
if (this.streamType == 'audio') {
|
||||
this.bufferTarget = avRatio*50*10**6;
|
||||
this.bufferTarget = avRatio * baseBufferTarget;
|
||||
} else {
|
||||
this.bufferTarget = 50*10**6; // 50 megabytes
|
||||
this.bufferTarget = baseBufferTarget;
|
||||
}
|
||||
console.info(`Detected system: ${selectedSystem}. Applying bufferTarget of ${this.bufferTarget} bytes to ${this.streamType}.`);
|
||||
|
||||
this.initRange = source['init_range'];
|
||||
this.indexRange = source['index_range'];
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
},
|
||||
});
|
||||
|
||||
const player = new Plyr(document.getElementById('js-video-player'), {
|
||||
const playerOptions = {
|
||||
// Learning about autoplay permission https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy/autoplay#syntax
|
||||
autoplay: autoplayActive,
|
||||
disableContextMenu: false,
|
||||
@@ -117,5 +117,20 @@
|
||||
tooltips: {
|
||||
controls: true,
|
||||
},
|
||||
}
|
||||
|
||||
const player = new Plyr(document.getElementById('js-video-player'), playerOptions);
|
||||
|
||||
// disable double click to fullscreen
|
||||
// https://github.com/sampotts/plyr/issues/1370#issuecomment-528966795
|
||||
player.eventListeners.forEach(function(eventListener) {
|
||||
if(eventListener.type === 'dblclick') {
|
||||
eventListener.element.removeEventListener(eventListener.type, eventListener.callback, eventListener.options);
|
||||
}
|
||||
});
|
||||
|
||||
// Add .started property, true after the playback has been started
|
||||
// Needed so controls won't be hidden before playback has started
|
||||
player.started = false;
|
||||
player.once('playing', function(){this.started = true});
|
||||
})();
|
||||
|
||||
@@ -37,3 +37,41 @@ e.g. Firefox playback speed options */
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/*
|
||||
* Custom styles similar to youtube
|
||||
*/
|
||||
.plyr__controls {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.plyr__progress__container {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
margin-bottom: -10px;
|
||||
}
|
||||
|
||||
.plyr__controls .plyr__controls__item:first-child {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.plyr__controls .plyr__controls__item.plyr__volume {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.plyr__controls .plyr__controls__item.plyr__progress__container {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.plyr__progress input[type="range"] {
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
/*
|
||||
* End custom styles
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
__version__ = '0.2.21'
|
||||
__version__ = 'v0.3.1'
|
||||
|
||||
Reference in New Issue
Block a user