我能够在我的裸反应原生项目中设置和使用博览会视频。它适用于最新版本的 IOS 和 android。不幸的是,它不适用于 Android 5.1 或 5.0
我在调试控制台中没有看到任何错误,但是使用 Android Studio 的 LogCat 我看到以下本机错误
06-05 13:46:02.223 5024-5158/com.getsafeuikit E/AudioTrack: AudioFlinger could not create track, status: -12
06-05 13:46:02.227 5024-5158/com.getsafeuikit E/AudioTrack-JNI: Error -12 initializing AudioTrack
06-05 13:46:02.227 5024-5158/com.getsafeuikit E/android.media.AudioTrack: Error code -20 when initializing AudioTrack.
06-05 13:46:02.227 5024-5158/com.getsafeuikit E/ExoPlayerImplInternal: Playback error.
com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.audio.AudioSink$InitializationException: AudioTrack init failed: 0, Config(48000, 12, 48000)
at com.google.android.exoplayer2.audio.MediaCodecAudioRenderer.processOutputBuffer(MediaCodecAudioRenderer.java:646)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1355)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:663)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:536)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:303)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: com.google.android.exoplayer2.audio.AudioSink$InitializationException: AudioTrack init failed: 0, Config(48000, 12, 48000)
at com.google.android.exoplayer2.audio.DefaultAudioSink.initializeAudioTrack(DefaultAudioSink.java:1128)
at com.google.android.exoplayer2.audio.DefaultAudioSink.initialize(DefaultAudioSink.java:532)
at com.google.android.exoplayer2.audio.DefaultAudioSink.handleBuffer(DefaultAudioSink.java:593)
at com.google.android.exoplayer2.audio.MediaCodecAudioRenderer.processOutputBuffer(MediaCodecAudioRenderer.java:640)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1355)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:663)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:536)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:303)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
我正在使用这样的世博视频
<Video
source={{ uri: props.sourceUri }}
ref={videoRef}
shouldPlay={props.autoPlay}
useNativeControls
onPlaybackStatusUpdate={onPlaybackStatusUpdate}
resizeMode={RESIZE_MODES[props.resizeMode || 'contain']}
onFullscreenUpdate={({ fullscreenUpdate }) => {
if (
fullscreenUpdate === Video.FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS &&
props.onCloseFullScreen
) {
props.onCloseFullScreen()
}
}}
/>