mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
WIP
This commit is contained in:
parent
96eccd2ecd
commit
7d9208e951
143 changed files with 1000 additions and 1008 deletions
|
@ -1,6 +1,6 @@
|
|||
import events from 'jellyfin-apiclient';
|
||||
import browser from 'browser';
|
||||
import appRouter from 'appRouter';
|
||||
import { events } from 'jellyfin-apiclient';
|
||||
import browser from '../../scripts/browser';
|
||||
import { appRouter } from '../../components/appRouter';
|
||||
import loading from '../../components/loading/loading';
|
||||
|
||||
/* globals YT */
|
||||
|
@ -20,7 +20,7 @@ function createMediaElement(instance, options) {
|
|||
const dlg = document.querySelector('.youtubePlayerContainer');
|
||||
|
||||
if (!dlg) {
|
||||
import('./style').then(() => {
|
||||
import('./style.css').then(() => {
|
||||
loading.show();
|
||||
|
||||
const dlg = document.createElement('div');
|
||||
|
@ -114,7 +114,7 @@ function onPlaying(instance, playOptions, resolve) {
|
|||
instance.videoDialog.classList.remove('onTop');
|
||||
}
|
||||
|
||||
import('loading').then(({default: loading}) => {
|
||||
import('../../components/loading/loading').then(({default: loading}) => {
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
|
@ -122,60 +122,58 @@ function onPlaying(instance, playOptions, resolve) {
|
|||
|
||||
function setCurrentSrc(instance, elem, options) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
import('queryString').then(({default: queryString}) => {
|
||||
instance._currentSrc = options.url;
|
||||
const params = queryString.parse(options.url.split('?')[1]);
|
||||
// 3. This function creates an <iframe> (and YouTube player)
|
||||
// after the API code downloads.
|
||||
window.onYouTubeIframeAPIReady = function () {
|
||||
instance.currentYoutubePlayer = new YT.Player('player', {
|
||||
height: instance.videoDialog.offsetHeight,
|
||||
width: instance.videoDialog.offsetWidth,
|
||||
videoId: params.v,
|
||||
events: {
|
||||
'onReady': onPlayerReady,
|
||||
'onStateChange': function (event) {
|
||||
if (event.data === YT.PlayerState.PLAYING) {
|
||||
onPlaying(instance, options, resolve);
|
||||
} else if (event.data === YT.PlayerState.ENDED) {
|
||||
onEndedInternal(instance);
|
||||
} else if (event.data === YT.PlayerState.PAUSED) {
|
||||
events.trigger(instance, 'pause');
|
||||
}
|
||||
instance._currentSrc = options.url;
|
||||
const params = new URLSearchParams(options.url.split('?')[1]); /* eslint-disable-line compat/compat */
|
||||
// 3. This function creates an <iframe> (and YouTube player)
|
||||
// after the API code downloads.
|
||||
window.onYouTubeIframeAPIReady = function () {
|
||||
instance.currentYoutubePlayer = new YT.Player('player', {
|
||||
height: instance.videoDialog.offsetHeight,
|
||||
width: instance.videoDialog.offsetWidth,
|
||||
videoId: params.v,
|
||||
events: {
|
||||
'onReady': onPlayerReady,
|
||||
'onStateChange': function (event) {
|
||||
if (event.data === YT.PlayerState.PLAYING) {
|
||||
onPlaying(instance, options, resolve);
|
||||
} else if (event.data === YT.PlayerState.ENDED) {
|
||||
onEndedInternal(instance);
|
||||
} else if (event.data === YT.PlayerState.PAUSED) {
|
||||
events.trigger(instance, 'pause');
|
||||
}
|
||||
},
|
||||
playerVars: {
|
||||
controls: 0,
|
||||
enablejsapi: 1,
|
||||
modestbranding: 1,
|
||||
rel: 0,
|
||||
showinfo: 0,
|
||||
fs: 0,
|
||||
playsinline: 1
|
||||
}
|
||||
});
|
||||
|
||||
let resizeListener = instance.resizeListener;
|
||||
if (resizeListener) {
|
||||
window.removeEventListener('resize', resizeListener);
|
||||
window.addEventListener('resize', resizeListener);
|
||||
} else {
|
||||
resizeListener = instance.resizeListener = onVideoResize.bind(instance);
|
||||
window.addEventListener('resize', resizeListener);
|
||||
},
|
||||
playerVars: {
|
||||
controls: 0,
|
||||
enablejsapi: 1,
|
||||
modestbranding: 1,
|
||||
rel: 0,
|
||||
showinfo: 0,
|
||||
fs: 0,
|
||||
playsinline: 1
|
||||
}
|
||||
window.removeEventListener('orientationChange', resizeListener);
|
||||
window.addEventListener('orientationChange', resizeListener);
|
||||
};
|
||||
});
|
||||
|
||||
if (!window.YT) {
|
||||
const tag = document.createElement('script');
|
||||
tag.src = 'https://www.youtube.com/iframe_api';
|
||||
const firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
let resizeListener = instance.resizeListener;
|
||||
if (resizeListener) {
|
||||
window.removeEventListener('resize', resizeListener);
|
||||
window.addEventListener('resize', resizeListener);
|
||||
} else {
|
||||
window.onYouTubeIframeAPIReady();
|
||||
resizeListener = instance.resizeListener = onVideoResize.bind(instance);
|
||||
window.addEventListener('resize', resizeListener);
|
||||
}
|
||||
});
|
||||
window.removeEventListener('orientationChange', resizeListener);
|
||||
window.addEventListener('orientationChange', resizeListener);
|
||||
};
|
||||
|
||||
if (!window.YT) {
|
||||
const tag = document.createElement('script');
|
||||
tag.src = 'https://www.youtube.com/iframe_api';
|
||||
const firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
} else {
|
||||
window.onYouTubeIframeAPIReady();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue