-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into feature/base-enable-lock-screen-controls
- Loading branch information
Showing
19 changed files
with
266 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React, { useCallback } from 'react'; | ||
import { View, Platform, StyleSheet } from 'react-native'; | ||
import { useFocusEffect } from '@react-navigation/native'; | ||
import { | ||
Event, | ||
usePlayer, | ||
PlayerView, | ||
SourceType, | ||
PlayerViewConfig, | ||
TvUi, | ||
} from 'bitmovin-player-react-native'; | ||
import { useTVGestures } from '../hooks'; | ||
|
||
function prettyPrint(header: string, obj: any) { | ||
console.log(header, JSON.stringify(obj, null, 2)); | ||
} | ||
|
||
export default function BasicTvPlayback() { | ||
useTVGestures(); | ||
|
||
const player = usePlayer({ | ||
remoteControlConfig: { | ||
isCastEnabled: false, | ||
}, | ||
}); | ||
|
||
const config: PlayerViewConfig = { | ||
uiConfig: { | ||
// This is only applied for Android TVs, as on TvOS only the system UI is supported. | ||
variant: new TvUi(), | ||
}, | ||
}; | ||
|
||
useFocusEffect( | ||
useCallback(() => { | ||
player.load({ | ||
url: | ||
Platform.OS === 'ios' | ||
? 'https://bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8' | ||
: 'https://bitmovin-a.akamaihd.net/content/MI201109210084_1/mpds/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.mpd', | ||
type: Platform.OS === 'ios' ? SourceType.HLS : SourceType.DASH, | ||
title: 'Art of Motion', | ||
poster: | ||
'https://bitmovin-a.akamaihd.net/content/MI201109210084_1/poster.jpg', | ||
thumbnailTrack: | ||
'https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/thumbnails/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.vtt', | ||
metadata: { platform: Platform.OS }, | ||
}); | ||
return () => { | ||
player.destroy(); | ||
}; | ||
}, [player]) | ||
); | ||
|
||
const onReady = useCallback((event: Event) => { | ||
prettyPrint(`EVENT [${event.name}]`, event); | ||
}, []); | ||
|
||
const onEvent = useCallback((event: Event) => { | ||
prettyPrint(`EVENT [${event.name}]`, event); | ||
}, []); | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<PlayerView | ||
player={player} | ||
style={styles.player} | ||
config={config} | ||
onPlay={onEvent} | ||
onPlaying={onEvent} | ||
onPaused={onEvent} | ||
onReady={onReady} | ||
onSourceLoaded={onEvent} | ||
onSeek={onEvent} | ||
onSeeked={onEvent} | ||
onStallStarted={onEvent} | ||
onStallEnded={onEvent} | ||
onVideoPlaybackQualityChanged={onEvent} | ||
/> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: 'black', | ||
}, | ||
player: { | ||
flex: 1, | ||
}, | ||
}); |
Oops, something went wrong.