mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-29 03:16:22 -05:00
Diplaying video poster on lock screen.
This commit is contained in:
parent
c89b16f623
commit
19a0e7e1c5
2 changed files with 22 additions and 0 deletions
|
|
@ -1272,6 +1272,23 @@ export function HotspotStatusIcon() {
|
|||
</>
|
||||
}
|
||||
|
||||
export function useMediaSession(title, artist, artworkUrl) {
|
||||
useEffect(() => {
|
||||
if ('mediaSession' in navigator && title) {
|
||||
const artwork = [];
|
||||
if (artworkUrl) {
|
||||
artwork.push({src: artworkUrl, type: 'image/jpeg'});
|
||||
}
|
||||
|
||||
navigator.mediaSession.metadata = new MediaMetadata({
|
||||
title: title,
|
||||
artist: artist || '',
|
||||
artwork: artwork,
|
||||
});
|
||||
}
|
||||
}, [title, artist, artworkUrl]);
|
||||
}
|
||||
|
||||
export function useTitle(title) {
|
||||
const documentDefined = typeof document !== 'undefined';
|
||||
const originalTitle = React.useRef(documentDefined ? document.title : null);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import {
|
|||
MultilineText,
|
||||
PageContainer,
|
||||
PreviewPath,
|
||||
useMediaSession,
|
||||
useTitle
|
||||
} from "./Common";
|
||||
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
||||
|
|
@ -210,6 +211,10 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
|
|||
const {channel} = useChannel(video && video.channel_id ? video.channel_id : channelId);
|
||||
const {comments, captions} = useVideoExtras(videoFile?.video?.id);
|
||||
|
||||
const mediaTitle = videoFile ? (videoFile.title || videoFile.stem || videoFile.name) : null;
|
||||
const mediaArtworkUrl = video && video.poster_path ? `${MEDIA_PATH}/${encodeMediaPath(video.poster_path)}` : null;
|
||||
useMediaSession(mediaTitle, channel ? channel.name : null, mediaArtworkUrl);
|
||||
|
||||
// Keyboard shortcuts for video player controls
|
||||
// k: Play/pause
|
||||
useHotkeys('k', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue