Diplaying video poster on lock screen.

This commit is contained in:
Roland 2026-03-08 09:22:50 -06:00
parent c89b16f623
commit 19a0e7e1c5
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
2 changed files with 22 additions and 0 deletions

View file

@ -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);

View file

@ -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', () => {