Samsung VideoView OnErrorListener - PullRequest
       16

Samsung VideoView OnErrorListener

2 голосов
/ 24 апреля 2019

У меня проблемы с видеовидением на устройстве Samsung Galaxy A5 (Motorola и другие устройства работают нормально)

Мой репо: 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
...