Add aria-title attribute to video player. For #1826

This commit is contained in:
Gabe Kangas 2023-01-23 19:28:32 -08:00
parent 308aea9f59
commit 24f6bb1ea5
No known key found for this signature in database
GPG key ID: 4345B2060657F330
4 changed files with 15 additions and 6 deletions

View file

@ -335,7 +335,13 @@ export const Content: FC = () => {
<div className={styles.mainSection}>
<div className={styles.topSection}>
{appState.appLoading && <Skeleton loading active paragraph={{ rows: 7 }} />}
{online && <OwncastPlayer source="/hls/stream.m3u8" online={online} />}
{online && (
<OwncastPlayer
source="/hls/stream.m3u8"
online={online}
title={streamTitle || name}
/>
)}
{!online && !appState.appLoading && (
<OfflineBanner
streamName={name}

View file

@ -34,4 +34,5 @@ export const LiveDemo = Template.bind({});
LiveDemo.args = {
online: true,
source: 'https://watch.owncast.online/hls/stream.m3u8',
title: 'Stream title',
};

View file

@ -10,7 +10,6 @@ import { isVideoPlayingAtom, clockSkewAtom } from '../../stores/ClientConfigStor
import PlaybackMetrics from '../metrics/playback';
import createVideoSettingsMenuButton from '../settings-menu';
import LatencyCompensator from '../latencyCompensator';
import styles from './OwncastPlayer.module.scss';
const VIDEO_CONFIG_URL = '/api/video/variants';
@ -26,6 +25,7 @@ export type OwncastPlayerProps = {
source: string;
online: boolean;
initiallyMuted?: boolean;
title: string;
};
async function getVideoSettings() {
@ -44,6 +44,7 @@ export const OwncastPlayer: FC<OwncastPlayerProps> = ({
source,
online,
initiallyMuted = false,
title,
}) => {
const playerRef = React.useRef(null);
const [videoPlaying, setVideoPlaying] = useRecoilState<boolean>(isVideoPlayingAtom);
@ -85,13 +86,13 @@ export const OwncastPlayer: FC<OwncastPlayerProps> = ({
}
};
const setLatencyCompensatorItemTitle = title => {
const setLatencyCompensatorItemTitle = t => {
const item = document.querySelector('.latency-toggle-item > .vjs-menu-item-text');
if (!item) {
return;
}
item.innerHTML = title;
item.innerHTML = t;
};
const startLatencyCompensator = () => {
@ -310,7 +311,7 @@ export const OwncastPlayer: FC<OwncastPlayerProps> = ({
<div className={styles.container} id="player">
{online && (
<div className={styles.player}>
<VideoJS options={videoJsOptions} onReady={handlePlayerReady} />
<VideoJS options={videoJsOptions} onReady={handlePlayerReady} aria-label={title} />
</div>
)}
<div className={styles.poster}>

View file

@ -20,7 +20,7 @@ export default function VideoEmbed() {
const { name } = clientConfig;
const { offlineMessage } = clientConfig;
const { viewerCount, lastConnectTime, lastDisconnectTime } = status;
const { viewerCount, lastConnectTime, lastDisconnectTime, streamTitle } = status;
const online = useRecoilValue<boolean>(isOnlineSelector);
const router = useRouter();
@ -48,6 +48,7 @@ export default function VideoEmbed() {
source="/hls/stream.m3u8"
online={online}
initiallyMuted={initiallyMuted}
title={streamTitle || name}
/>
)}
{!online && (