Fix some playery errors and layout issues
This commit is contained in:
@@ -246,28 +246,28 @@ export const OwncastPlayer: FC<OwncastPlayerProps> = ({ source, online }) => {
|
|||||||
|
|
||||||
// You can handle player events here, for example:
|
// You can handle player events here, for example:
|
||||||
player.on('waiting', () => {
|
player.on('waiting', () => {
|
||||||
player.log('player is waiting');
|
console.debug('player is waiting');
|
||||||
});
|
});
|
||||||
|
|
||||||
player.on('dispose', () => {
|
player.on('dispose', () => {
|
||||||
player.log('player will dispose');
|
console.debug('player will dispose');
|
||||||
ping.stop();
|
ping.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
player.on('playing', () => {
|
player.on('playing', () => {
|
||||||
player.log('player is playing');
|
console.debug('player is playing');
|
||||||
ping.start();
|
ping.start();
|
||||||
setVideoPlaying(true);
|
setVideoPlaying(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
player.on('pause', () => {
|
player.on('pause', () => {
|
||||||
player.log('player is paused');
|
console.debug('player is paused');
|
||||||
ping.stop();
|
ping.stop();
|
||||||
setVideoPlaying(false);
|
setVideoPlaying(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
player.on('ended', () => {
|
player.on('ended', () => {
|
||||||
player.log('player is ended');
|
console.debug('player is ended');
|
||||||
ping.stop();
|
ping.stop();
|
||||||
setVideoPlaying(false);
|
setVideoPlaying(false);
|
||||||
});
|
});
|
||||||
@@ -291,13 +291,13 @@ export const OwncastPlayer: FC<OwncastPlayerProps> = ({ source, online }) => {
|
|||||||
useEffect(
|
useEffect(
|
||||||
() => () => {
|
() => () => {
|
||||||
stopLatencyCompensator();
|
stopLatencyCompensator();
|
||||||
playbackMetrics.stop();
|
playbackMetrics?.stop();
|
||||||
},
|
},
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'grid' }}>
|
<div style={{ display: 'grid', width: '100% !important', aspectRatio: '16/9' }}>
|
||||||
{online && (
|
{online && (
|
||||||
<div style={{ gridColumn: 1, gridRow: 1 }}>
|
<div style={{ gridColumn: 1, gridRow: 1 }}>
|
||||||
<VideoJS options={videoJsOptions} onReady={handlePlayerReady} />
|
<VideoJS options={videoJsOptions} onReady={handlePlayerReady} />
|
||||||
|
|||||||
@@ -6,14 +6,9 @@
|
|||||||
video {
|
video {
|
||||||
position: static !important;
|
position: static !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@include screen(desktop) {
|
|
||||||
height: 30vh !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.poster {
|
.poster {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ import styles from './VideoJS.module.scss';
|
|||||||
|
|
||||||
require('video.js/dist/video-js.css');
|
require('video.js/dist/video-js.css');
|
||||||
|
|
||||||
// TODO: Restore volume that was saved in local storage.
|
|
||||||
// import { getLocalStorage, setLocalStorage } from '../../utils/helpers.js';
|
|
||||||
// import { PLAYER_VOLUME, URL_STREAM } from '../../utils/constants.js';
|
|
||||||
export type VideoJSProps = {
|
export type VideoJSProps = {
|
||||||
options: any;
|
options: any;
|
||||||
onReady: (player: videojs.Player, vjsInstance: videojs) => void;
|
onReady: (player: videojs.Player, vjsInstance: videojs) => void;
|
||||||
@@ -23,7 +20,8 @@ export const VideoJS: FC<VideoJSProps> = ({ options, onReady }) => {
|
|||||||
|
|
||||||
// eslint-disable-next-line no-multi-assign
|
// eslint-disable-next-line no-multi-assign
|
||||||
const player = (playerRef.current = videojs(videoElement, options, () => {
|
const player = (playerRef.current = videojs(videoElement, options, () => {
|
||||||
player.log('player is ready');
|
console.debug('player is ready');
|
||||||
|
|
||||||
return onReady && onReady(player, videojs);
|
return onReady && onReady(player, videojs);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -36,18 +34,6 @@ export const VideoJS: FC<VideoJSProps> = ({ options, onReady }) => {
|
|||||||
}
|
}
|
||||||
}, [options, videoRef]);
|
}, [options, videoRef]);
|
||||||
|
|
||||||
// Dispose the Video.js player when the functional component unmounts
|
|
||||||
React.useEffect(() => {
|
|
||||||
const player = playerRef.current;
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
if (player) {
|
|
||||||
player.dispose();
|
|
||||||
playerRef.current = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}, [playerRef]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div data-vjs-player>
|
<div data-vjs-player>
|
||||||
{/* eslint-disable-next-line jsx-a11y/media-has-caption */}
|
{/* eslint-disable-next-line jsx-a11y/media-has-caption */}
|
||||||
@@ -61,57 +47,6 @@ export const VideoJS: FC<VideoJSProps> = ({ options, onReady }) => {
|
|||||||
|
|
||||||
export default VideoJS;
|
export default VideoJS;
|
||||||
|
|
||||||
// import PlaybackMetrics from '../metrics/playback.js';
|
|
||||||
// import LatencyCompensator from './latencyCompensator.js';
|
|
||||||
|
|
||||||
// const VIDEO_ID = 'video';
|
|
||||||
// const LATENCY_COMPENSATION_ENABLED = 'latencyCompensatorEnabled';
|
|
||||||
|
|
||||||
// // Video setup
|
|
||||||
// const VIDEO_SRC = {
|
|
||||||
// src: URL_STREAM,
|
|
||||||
// type: 'application/x-mpegURL',
|
|
||||||
// };
|
|
||||||
// const VIDEO_OPTIONS = {
|
|
||||||
// autoplay: false,
|
|
||||||
// liveui: true,
|
|
||||||
// preload: 'auto',
|
|
||||||
// controlBar: {
|
|
||||||
// progressControl: {
|
|
||||||
// seekBar: false,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// html5: {
|
|
||||||
// vhs: {
|
|
||||||
// // used to select the lowest bitrate playlist initially. This helps to decrease playback start time. This setting is false by default.
|
|
||||||
// enableLowInitialPlaylist: true,
|
|
||||||
// experimentalBufferBasedABR: true,
|
|
||||||
// useNetworkInformationApi: true,
|
|
||||||
// maxPlaylistRetries: 30,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// liveTracker: {
|
|
||||||
// trackingThreshold: 0,
|
|
||||||
// liveTolerance: 15,
|
|
||||||
// },
|
|
||||||
// sources: [VIDEO_SRC],
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export const POSTER_DEFAULT = `/img/logo.png`;
|
|
||||||
// export const POSTER_THUMB = `/thumbnail.jpg`;
|
|
||||||
|
|
||||||
// export default class MenuSeparator extends VjsMenuItem {
|
|
||||||
// constructor(player, options) {
|
|
||||||
// super(player, options);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// createEl(tag = 'button', props = {}, attributes = {}) {
|
|
||||||
// const el = super.createEl(tag, props, attributes);
|
|
||||||
// el.innerHTML = '<hr style="opacity: 0.3; margin-left: 10px; margin-right: 10px;" />';
|
|
||||||
// return el;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// class OwncastPlayer {
|
// class OwncastPlayer {
|
||||||
// constructor() {
|
// constructor() {
|
||||||
// window.VIDEOJS_NO_DYNAMIC_STYLE = true; // style override
|
// window.VIDEOJS_NO_DYNAMIC_STYLE = true; // style override
|
||||||
|
|||||||
Reference in New Issue
Block a user