1. 程式人生 > >VideoView播放視訊異常MediaPlayer: Error (1,-2147483648)

VideoView播放視訊異常MediaPlayer: Error (1,-2147483648)

異常資訊如下:

05-28 23:19:52.019 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.softpo.videodemo.MainActivity.access$super
05-28 23:19:52.019 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.os.PersistableBundle'
, referenced from method com.softpo.videodemo.MainActivity.access$super 05-28 23:19:52.019 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.softpo.videodemo.MainActivity.access$super 05-28 23:19:52.019 15284-15284/com.softpo.videodemo E/dalvikvm: Could not
find class 'android.widget.Toolbar', referenced from method com.softpo.videodemo.MainActivity.access$super 05-28 23:19:52.019 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.softpo.videodemo.MainActivity.access$super
05-28 23:
19:52.023 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.softpo.videodemo.MainActivity.access$super 05-28 23:19:52.023 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.softpo.videodemo.MainActivity.access$super 05-28 23:19:52.023 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.softpo.videodemo.MainActivity.access$super 05-28 23:19:52.031 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method com.softpo.videodemo.MainActivity.access$super 05-28 23:19:52.031 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method com.softpo.videodemo.MainActivity.access$super 05-28 23:19:52.031 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.softpo.videodemo.MainActivity.access$super 05-28 23:19:52.067 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.view.ViewOutlineProvider', referenced from method com.softpo.videodemo.widget.FullVideoView.access$super 05-28 23:19:52.067 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.animation.StateListAnimator', referenced from method com.softpo.videodemo.widget.FullVideoView.access$super 05-28 23:19:52.071 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.view.View$OnApplyWindowInsetsListener', referenced from method com.softpo.videodemo.widget.FullVideoView.access$super 05-28 23:19:52.071 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.view.ViewStructure', referenced from method com.softpo.videodemo.widget.FullVideoView.access$super 05-28 23:19:52.075 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.view.View$OnContextClickListener', referenced from method com.softpo.videodemo.widget.FullVideoView.access$super 05-28 23:19:52.079 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method com.softpo.videodemo.widget.FullVideoView.access$super 05-28 23:19:52.079 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.view.View$OnScrollChangeListener', referenced from method com.softpo.videodemo.widget.FullVideoView.access$super 05-28 23:19:52.083 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.view.ViewStructure', referenced from method com.softpo.videodemo.widget.FullVideoView.access$super 05-28 23:19:52.083 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.view.ViewStructure', referenced from method com.softpo.videodemo.widget.FullVideoView.access$super 05-28 23:19:52.083 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method com.softpo.videodemo.widget.FullVideoView.access$super 05-28 23:19:52.087 15284-15284/com.softpo.videodemo E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method com.softpo.videodemo.widget.FullVideoView.access$super 05-28 23:19:52.447 15284-15284/com.softpo.videodemo E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from GradienCache 05-28 23:19:52.447 15284-15284/com.softpo.videodemo E/OpenGLRenderer: MAX_TEXTURE_SIZE: 16384 05-28 23:19:52.459 15284-15284/com.softpo.videodemo E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from Caches::initConstraints() 05-28 23:19:52.459 15284-15284/com.softpo.videodemo E/OpenGLRenderer: MAX_TEXTURE_SIZE: 16384 05-28 23:19:54.047 15284-15296/com.softpo.videodemo E/MediaPlayer: error (1, -2147483648) 05-28 23:19:54.047 15284-15284/com.softpo.videodemo E/MediaPlayer: Error (1,-2147483648)

原因如下:

原因在於,MP4有多種編碼格式,例如H.264,H.263等,而Android版本較低的機器只支援部分編碼; 我的測試是這樣的:華為榮耀6,4.4.4系統可以執行程式播放視訊,Genymotion4.4.4以及5.0.0都不易執行程式播放視訊,Genymotion6.0.0可以執行程式播放視訊