Skip to content

Commit

Permalink
Merge branch 'main' into fix/DE-7266-remove-workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
fingerartur authored Sep 9, 2024
2 parents f7c9961 + 820f071 commit 38ff9ac
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 10 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

## New Features

* Add option to disable focus-based keyboard interactivity.
* Add option to keep player controls hidden.
* Make `BaseThemeOverlay` more configurable:
* Add option to hide buttons (audio, full screen, track options)
* Add option to hide the top bar of player controls
* Add option to hide buttons (audio, full screen, track options).
* Add option to hide the top bar of player controls.
* Add option to render a companion component above the bottom bar
of player controls
* Add option to display cues on the seek bar
of player controls.
* Add option to display cues on the seek bar.

## Fixes

Expand Down
13 changes: 8 additions & 5 deletions app/src/InterstitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ export const InterstitialPage = () => {
{mounted ? (
<div className="in-video-container">
<InterstitialPlayer
enableFocus={false}
asset={{
source: {
// url: 'http://localhost:3000/vod-fixed.m3u8',
url: 'http://localhost:3000/vod-preroll.m3u8',
// url: 'https://9457688946fc45ac9a3b526e93b06bf7.us-west-2.alpha.mediatailor.aws.a2z.com/v1/master/5d22c610440c419b9290f9233dc99fe61adb77ab/mt-dev-vod/index.m3u8?aws.insertionMode=GUIDED',
url: 'https://content.players.castlabs.com/api-interstitials-v3/vod-fixed.m3u8',
// url: 'https://content.players.castlabs.com/api-interstitials-v3/vod-preroll.m3u8',
type: clpp.Type.HLS,
},
}}
hasTopControlsBar={false}
interstitialOptions={{
// Start resolving X-ASSET-LIST 15 seconds or less before
// the cue is scheduled
config: {
// license: '',
},
// Start resolving X-ASSET-LIST 15 seconds or less before
// the cue is scheduled
resolutionOffsetSec: 15,
interstitialAssetConverter: (asset: clpp.interstitial.PlayerItem) => {
asset.config.htmlcue = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"typescript": "^4.8.4"
},
"peerDependencies": {
"@castlabs/prestoplay": "^6.11.1-beta.4",
"@castlabs/prestoplay": "^6.16.1-beta.4",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
Expand Down
9 changes: 9 additions & 0 deletions src/components/PlayerSurface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { PrestoContext, PrestoContextType } from '../context/PrestoContext'
import { Player } from '../Player'
import { usePrestoUiEvent } from '../react'
import {
enableFocus,
focusElement,
focusNextElement, focusPreviousElement,
getFocusableElements, isIpadOS,
Expand Down Expand Up @@ -43,6 +44,10 @@ export interface PlayerProps extends BaseComponentProps {
* player will go to full-screen mode and no overlay will be possible.
*/
playsInline?: boolean
/**
* Enable focus-based keyboard interactivity. Default: true.
*/
enableFocus?: boolean
children?: React.ReactNode
/**
* @private
Expand Down Expand Up @@ -81,6 +86,10 @@ export const PlayerSurface = (props: PlayerProps) => {
})
const context = getContext(nullableContext)

useEffect(() => {
enableFocus(props.enableFocus ?? true)
}, [props.enableFocus])

useEffect(() => {
context && props.onContext?.(context)
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
9 changes: 9 additions & 0 deletions src/interstitial/InterstitialPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import '@castlabs/prestoplay/cl.hls'
import React, { useEffect, useRef } from 'react'

import { ControlsVisibilityMode } from '../services/controls'
import { enableFocus } from '../utils'

import { InterstitialOverlay } from './components/OverlayHlsi'
import { PlayerSurfaceHlsi } from './components/PlayerSurfaceHlsi'
Expand Down Expand Up @@ -110,6 +111,10 @@ export type InterstitialPlayerProps = {
* Callback to get the instance of the HLS interstitial player
*/
onHlsiPlayerReady?: (player: clpp.interstitial.Player) => void
/**
* Enable focus-based keyboard interactivity. Default: true.
*/
enableFocus?: boolean
}

/**
Expand All @@ -121,6 +126,10 @@ export type InterstitialPlayerProps = {
export const InterstitialPlayer = React.memo((props: InterstitialPlayerProps) => {
const playerRef = useRef(new PlayerHlsi(props.onHlsiPlayerReady))

useEffect(() => {
enableFocus(props.enableFocus ?? true)
}, [props.enableFocus])

const load = async () => {
try {
await playerRef.current.loadHlsi(props.asset)
Expand Down
9 changes: 9 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,17 @@ export function focusPreviousElement(items: HTMLElement[]) {
}

let focusElementTimerId_: ReturnType<typeof setTimeout> | null = null
let focusEnabled = true

export function enableFocus(enabled: boolean) {
focusEnabled = enabled
}

export function focusElement(item: HTMLElement) {
if (!focusEnabled) {
return
}

if (focusElementTimerId_) {
clearTimeout(focusElementTimerId_)
focusElementTimerId_= null
Expand Down

0 comments on commit 38ff9ac

Please sign in to comment.