Android VideoView setDataSource failed.: status=0x80000000

I know there are countless questions on stackoverflow describing this error and I have gone through each one of them in detail. Unfortunately none of the solution worked for me. I can’t believe streaming a video is such a pain.

This is my code.

MainActivity.java

public class MainActivity extends AppCompatActivity{
    VideoView videoview;

    private static final String VIDEO_URL = "http://www.law.duke.edu/cspd/contest/finalists/viewentry.php?file=docandyou";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        videoview = (VideoView) findViewById(R.id.VideoView);

        try {
            MediaController mediacontroller = new MediaController(
                    MainActivity.this);
            mediacontroller.setAnchorView(videoview);
            videoview.setMediaController(mediacontroller);
            videoview.setVideoURI(Uri.parse(VIDEO_URL));

        } catch (Exception e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }

        videoview.requestFocus();
        videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            // Close the progress bar and play the video
            public void onPrepared(MediaPlayer mp) {
                videoview.start();
            }
        });
    }
}

activity_main.xml

<RelativeLayout 
    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=".MainActivity">

    <VideoView
        android:id="@+id/VideoView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" />

</RelativeLayout>

AndroidManifest.xml

.......
<uses-permission android:name="ANDROID.PERMISSION.INTERNET"/>
<uses-permission android:name="ANDROID.PERMISSION.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="ANDROID.PERMISSION.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
........

Now I have tried to play the video from this url,

http://www.law.duke.edu/cspd/contest/finalists/viewentry.php?file=docandyou

But always getting error

E/MediaPlayer﹕ Unable to create media player
W/VideoView﹕ Unable to open content: http://www.law.duke.edu/cspd/contest/finalists/viewentry.php?file=docandyou
    java.io.IOException: setDataSource failed.: status=0x80000000

One common answer for this kind of questions is to try out with different video files, because not all devices support every video codecs. I made sure that by downloading the video from the above link and adding it to raw folder in the bundle. Application played the same video from raw folder without any issues.

So why is VideoPlayer not playing videos from public domains, which it can play locally?


Source: android

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.