I can't figure out why I'm not able to play the video in my VideoView. All I'm getting for a message is:
Cannot Play Video : Sorry, this video cannot be played.
I created an SD card for my emulator as well. Do I need to place my SD card in a particular folder in my SDK? Please comment.
Here's the layout:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01" android:layout_height="fill_parent" android:paddingLeft="2px" android:paddingRight="2px" xmlns:android="http://schemas.android.com/apk/res/android" android:paddingTop="2px" android:paddingBottom="2px" android:layout_width="fill_parent" android:orientation="vertical"> <VideoView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/VideoView" /> </LinearLayout>
Here's the code:
package com.examples.videoviewdemo; import android.app.Activity; import android.os.Bundle; import android.widget.MediaController; import android.widget.VideoView; public class VideoViewDemo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); VideoView videoView = (VideoView)findViewById(R.id.VideoView); //MediaController mediaController = new MediaController(this); // mediaController.setAnchorView(videoView); //videoView.setMediaController(mediaController); videoView.setVideoPath("/sdcard/blonde_secretary.3gp"); videoView.start(); } }
Waiting for the reply...
Watch the video tutorial how to play Youtube videos in Android with VideoView with Android Studio version 1.5: Download free slideshow app from here and install it on your device to see an youtube video.
Step 2: Open res -> layout -> xml (or) main. xml and add following code : In this step we open an xml file and add the code to display a VideoView in our activity. In this step we open MainActivity and add the code to initiate the video view and create an object of MediaController to control the video playback.
My guess is that your video is incompatible with Android. Try it with a different video. This one definitely works used to work with Android (but does not on newer devices, for some reason). If that video works, and yours does not, then your video is not compatible with Android.
As others have indicated, please test this on a device. Video playback on the emulator requires too much power.
UPDATE 2020-02-18: https://law.duke.edu/cspd/contest/videos/Framed-Contest_Documentaries-and-You.mp4 is an MP4 of the same content, but I have no idea if it is the same actual MP4 as I previously linked to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With