I am currently developing an Android application, including a video player, which uploads a mp4 video file via HTTP using Android-VideoView. It works great on Nexus 4 with Android version 5.1.1, as well as on a tablet with Android 4.4 installed.
However, using Android 6.0, the video stream unexpectedly ends in a few minutes (tested on Nexus 5 and the emulator). As you can see in the log output, the thread plays for about 5 minutes until java.net.ProtocolException occurs , and another minute until the buffer is empty.
10-16 11:08:21.030 4657-4657/...app D/video: start
10-16 11:08:21.060 4657-4657/...app W/MediaPlayer: Couldn't open file on client side; trying server side: java.io.FileNotFoundException: No content provider: http://someurl...mp4
10-16 11:08:29.330 4657-4657/...app D/MediaPlayer: getMetadata
10-16 11:08:29.360 4657-4657/...app D/video: prepared
10-16 11:08:29.470 4657-4671/...app W/MediaPlayer: info/warning (3, 0)
10-16 11:09:19.930 4657-4664/...app W/art: Suspending all threads took: 10ms
10-16 11:14:32.550 4657-4664/...app W/art: Suspending all threads took: 10ms
10-16 11:23:46.940 4657-4671/...app W/MediaHTTPConnection: readAt 121022400 / 22592 => java.net.ProtocolException: unexpected end of stream
10-16 11:24:40.780 4657-4669/...app E/MediaPlayer: error (1, -1004)
10-16 11:24:40.780 4657-4657/...app E/MediaPlayer: Error (1,-1004)
10-16 11:24:40.780 4657-4657/...app D/VideoView: Error: 1,-1004
10-16 11:24:40.780 4657-6289/...app E/MediaPlayer: error (1, -1004)
10-16 11:24:40.790 4657-4713/...app E/MediaPlayer: error (1, -1004)
10-16 11:24:40.830 4657-4657/...app E/MediaPlayer: Error (1,-1004)
10-16 11:24:40.830 4657-4657/...app D/VideoView: Error: 1,-1004
10-16 11:24:40.840 4657-4657/...app E/MediaPlayer: Error (1,-1004)
10-16 11:24:40.840 4657-4657/...app D/VideoView: Error: 1,-1004
10-16 11:24:40.860 4657-4697/...app W/EGL_emulation: eglSurfaceAttrib not implemented
10-16 11:24:40.860 4657-4697/...app W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe0d7e740, error=EGL_SUCCESS
10-16 11:24:40.880 4657-6289/...app E/MediaPlayer: error (1, -1004)
10-16 11:24:40.880 4657-4713/...app E/MediaPlayer: error (1, -1004)
10-16 11:24:40.890 4657-4697/...app W/EGL_emulation: eglSurfaceAttrib not implemented
10-16 11:24:40.890 4657-4697/...app W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe11fbd80, error=EGL_SUCCESS
10-16 11:24:40.920 4657-4697/...app W/EGL_emulation: eglSurfaceAttrib not implemented
10-16 11:24:40.920 4657-4697/...app W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xed7939e0, error=EGL_SUCCESS
10-16 11:24:40.950 4657-4657/...app E/MediaPlayer: Error (1,-1004)
10-16 11:24:40.950 4657-4657/...app D/VideoView: Error: 1,-1004
10-16 11:24:40.950 4657-4657/...app E/MediaPlayer: Error (1,-1004)
10-16 11:24:40.950 4657-4657/...app D/VideoView: Error: 1,-1004
10-16 11:24:41.010 4657-4697/...app W/EGL_emulation: eglSurfaceAttrib not implemented
10-16 11:24:41.010 4657-4697/...app W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe0ed12e0, error=EGL_SUCCESS
10-16 11:24:41.030 4657-4697/...app W/EGL_emulation: eglSurfaceAttrib not implemented
10-16 11:24:41.030 4657-4697/...app W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe0ed1300, error=EGL_SUCCESS
Adding wake and wifi locks didn't seem to stop it.
:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".VideoActivity"
android:keepScreenOn="true">
<VideoView
android:id="@+id/video"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
/>
...
:
videoView = (VideoView) v.findViewById(R.id.video);
videoView.setOnCompletionListener(this);
videoView.setOnPreparedListener(this);
videoView.setVideoURI(videoUrl);
videoView.seekTo(0);
videoView.start();