我在Samsung Galaxy A5设备上遇到视频观看问题(摩托罗拉和其他设备运行正常)
我的仓库:https://github.com/rchampa/VideoViewOnSamsung
视频:https://github.com/rchampa/VideoViewOnSamsung/blob/master/app/src/main/res/raw/background.mp4
下面的代码在其他设备看起来不错时触发无限循环。
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
videoBackground.setVideoURI(getUri())
videoBackground.setOnPreparedListener{ mp ->
mp.start()
mp.isLooping = true
}
videoBackground.setOnErrorListener{ mp, what, extra ->
mp.reset()
videoBackground.setVideoURI(getUri())
true
}
}
fun getUri() : Uri {
val videoPath = "android.resource://" + applicationContext.packageName + "/"
val uri = Uri.parse(videoPath + R.raw.background)
return uri
}
}
错误日志:
04-24 18:44:55.839 15478-15478/com.example.myvideoapp V/MediaPlayer-JNI: getCurrentPosition: 0 (msec)
04-24 18:44:55.859 15478-15489/com.example.myvideoapp V/MediaPlayer: message received msg=100, ext1=1, ext2=-5001
04-24 18:44:55.859 15478-15489/com.example.myvideoapp E/MediaPlayer: error (1, -5001)
04-24 18:44:55.859 15478-15489/com.example.myvideoapp V/MediaPlayer: callback application
04-24 18:44:55.859 15478-15489/com.example.myvideoapp V/MediaPlayer: back from callback
04-24 18:44:55.859 15478-15478/com.example.myvideoapp E/MediaPlayer: Error (1,-5001)
04-24 18:44:55.859 15478-15478/com.example.myvideoapp D/VideoView: Error: 1,-5001
04-24 18:44:55.859 15478-15478/com.example.myvideoapp V/MediaPlayer-JNI: reset
04-24 18:44:55.859 15478-15478/com.example.myvideoapp V/MediaPlayer: reset
04-24 18:44:55.859 15478-15613/com.example.myvideoapp V/MediaPlayer: message received msg=8, ext1=0, ext2=0
04-24 18:44:55.879 15478-15478/com.example.myvideoapp D/RingtoneManager: Can't get current user. return default user
04-24 18:44:55.869 15478-15478/com.example.myvideoapp V/MediaPlayer-JNI: reset
04-24 18:44:55.869 15478-15478/com.example.myvideoapp V/MediaPlayer: reset
04-24 18:44:55.869 15478-15478/com.example.myvideoapp V/MediaPlayer-JNI: release
04-24 18:44:55.869 15478-15478/com.example.myvideoapp V/MediaPlayer: setListener
04-24 18:44:55.869 15478-15478/com.example.myvideoapp V/MediaPlayer: disconnect
04-24 18:44:55.869 15478-15613/com.example.myvideoapp V/MediaPlayer: notify(8, 0, 0) callback on disconnected mediaplayer
04-24 18:44:55.869 15478-15613/com.example.myvideoapp V/MediaPlayer: destructor
04-24 18:44:55.869 15478-15478/com.example.myvideoapp I/VideoView: Open Video
04-24 18:44:55.869 15478-15613/com.example.myvideoapp V/MediaPlayer: disconnect
04-24 18:44:55.869 15478-15478/com.example.myvideoapp V/MediaPlayer-JNI: native_setup
04-24 18:44:55.869 15478-15478/com.example.myvideoapp E/ExtMediaPlayer-JNI: env->IsInstanceOf fails
04-24 18:44:55.869 15478-15478/com.example.myvideoapp E/MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
04-24 18:44:55.869 15478-15478/com.example.myvideoapp E/ExtMediaPlayer-JNI: env->IsInstanceOf fails
04-24 18:44:55.869 15478-15478/com.example.myvideoapp E/MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
04-24 18:44:55.869 15478-15478/com.example.myvideoapp V/MediaPlayer: constructor
04-24 18:44:55.869 15478-15478/com.example.myvideoapp V/MediaPlayer: setListener
04-24 18:44:55.869 15478-15478/com.example.myvideoapp V/MediaPlayer-JNI: set_session_id(): 2372
04-24 18:44:55.869 15478-15478/com.example.myvideoapp V/MediaPlayer: MediaPlayer::setAudioSessionId(2372)
04-24 18:44:55.879 15478-15478/com.example.myvideoapp V/MediaPlayer-JNI: setDataSourceFD: fd 30
04-24 18:44:55.879 15478-15478/com.example.myvideoapp V/MediaPlayer: setDataSource(30, 1768188, 2928810)
04-24 18:44:55.879 15478-15478/com.example.myvideoapp V/MediaPlayer: setVideoSurfaceTexture
04-24 18:44:55.879 15478-15478/com.example.myvideoapp V/MediaPlayer-JNI: setAudioStreamType: 3
04-24 18:44:55.879 15478-15478/com.example.myvideoapp V/MediaPlayer: MediaPlayer::setAudioStreamType
04-24 18:44:55.879 15478-15478/com.example.myvideoapp V/MediaPlayer: setVideoSurfaceTexture
04-24 18:44:55.879 15478-15478/com.example.myvideoapp V/MediaPlayer: prepareAsync
04-24 18:44:55.909 15478-15489/com.example.myvideoapp V/MediaPlayer: message received msg=5, ext1=1080, ext2=1920
04-24 18:44:55.909 15478-15489/com.example.myvideoapp V/MediaPlayer: New video size 1080 x 1920
04-24 18:44:55.909 15478-15489/com.example.myvideoapp V/MediaPlayer: callback application
04-24 18:44:55.909 15478-15489/com.example.myvideoapp V/MediaPlayer: back from callback
04-24 18:44:55.909 15478-15613/com.example.myvideoapp V/MediaPlayer: message received msg=1, ext1=0, ext2=0
04-24 18:44:55.909 15478-15478/com.example.myvideoapp V/MediaPlayer: getVideoWidth
04-24 18:44:55.909 15478-15478/com.example.myvideoapp V/MediaPlayer-JNI: getVideoWidth: 1080
04-24 18:44:55.909 15478-15478/com.example.myvideoapp V/MediaPlayer: getVideoHeight
04-24 18:44:55.909 15478-15478/com.example.myvideoapp V/MediaPlayer-JNI: getVideoHeight: 1920
04-24 18:44:55.909 15478-15613/com.example.myvideoapp V/MediaPlayer: prepared
04-24 18:44:55.909 15478-15613/com.example.myvideoapp V/MediaPlayer: callback application
04-24 18:44:55.909 15478-15613/com.example.myvideoapp V/MediaPlayer: back from callback