feat(android): add sample to test decoder capabilities

This commit is contained in:
olivier bouillet 2022-06-23 22:54:47 +02:00
parent 3a4cb7f6d9
commit 8408664600

View File

@ -16,7 +16,7 @@ import {
import { Picker } from '@react-native-picker/picker'
import Video, { TextTrackType } from 'react-native-video';
import Video, { VideoDecoderProperties, TextTrackType } from 'react-native-video';
class VideoPlayer extends Component {
@ -77,6 +77,28 @@ class VideoPlayer extends Component {
video: Video;
seekPanResponder: PanResponder | undefined;
popupInfo = () => {
VideoDecoderProperties.getWidevineLevel().then((widevineLevel: number) => {
VideoDecoderProperties.isHEVCSupported().then((hevcSupported: boolean) => {
VideoDecoderProperties.isCodecSupported('video/avc', 1920, 1080).then(
(avcSupported: boolean) => {
this.toast(
true,
'Widevine level: ' +
widevineLevel +
'\n hevc: ' +
(hevcSupported ? '' : 'NOT') +
'supported' +
'\n avc: ' +
(avcSupported ? '' : 'NOT') +
'supported',
)
},
)
})
})
}
onLoad = (data: any) => {
this.setState({ duration: data.duration, loading: false, });
this.onAudioTracks(data.audioTracks)
@ -288,6 +310,18 @@ class VideoPlayer extends Component {
)
}
renderInfoControl() {
return (
<TouchableOpacity
onPress={() => {
this.popupInfo()
}}
>
<Text style={[styles.controlOption]}>{'decoderInfo'}</Text>
</TouchableOpacity>
)
}
renderFullScreenControl() {
return (
<TouchableOpacity
@ -541,6 +575,9 @@ class VideoPlayer extends Component {
</View>
<View style={styles.bottomControls}>
<View style={styles.generalControls}>
<View style={styles.generalControls}>
<View style={styles.resizeModeControl}>{this.renderInfoControl()}</View>
</View>
<View style={styles.resizeModeControl}>{this.renderPause()}</View>
<View style={styles.resizeModeControl}>
{this.renderRepeatModeControl()}