0

First time working with video on Android.. All code samples I have tried to use render a "can't play this video" message.

Here is one implementation I have been trying:

public class MainActivity extends Activity {

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

  Uri.parse("http://www.boisestatefootball.com/sites/default/files/videos/original/01%20-%20coach%20pete%20bio_4.mp4");

  VideoView mVideoView  = (VideoView)findViewById(R.id.VideoView);
  mVideoView.setMediaController(new MediaController(this));       
  mVideoView.setVideoURI(uri);
  mVideoView.requestFocus();
  mVideoView.start();
}

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    tools:context="com.example.moviedemo.MainActivity" >

    <VideoView 
         android:layout_height="fill_parent"
         android:layout_width="fill_parent" 
         android:id="@+id/VideoView" />
</RelativeLayout>

I also tried this one: Streaming video with videoview

and a couple other solutions like those here: How to play a video file in android?

but the result is the same each time. I also tried putting the video from this post: Playing a video in VideoView in Android into my assets folder and loading it from there, but I got the same message. (EDIT: This video file isn't compatible with new Androids, but the one in the URI definitely is)

The two videos I've been testing with have both come from sample android code, so I know it can't be a formatting issue. Is there something else that is needed to get a video playing?

5
  • Well, the video from this one of your links does not work on newer versions of Android. I have updated my answer there to reflect that. Rather than testing from assets, test playback of your file on external storage. If if fails there, the video is incompatible with whatever you are testing it on. Jul 5, 2014 at 21:56
  • huh didn't see your update. I just transferred the video file from that 'boisestatefootball' link without reformatting it and it ran fine on my device using the default video player.
    – Cbas
    Jul 5, 2014 at 22:29
  • Did you add permissions in AndroidManifest.xml? ` <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> ` Did you try to play other online video? Ex. wowza.com/html/mobile.html Jul 5, 2014 at 23:27
  • That would suggest that the problem is somehow tied to the HTTP stream. You might see if an existing Web-capable video player can play it. Jul 5, 2014 at 23:34
  • I tried adding the permissions but no change. I tried changing the video uri to: wowza.com/_h264/BigBuckBunny_115k.mov, but it still said 'can't play this video'
    – Cbas
    Jul 5, 2014 at 23:51

1 Answer 1

0

I reinstalled ADT and the same code worked.. I guess it was a configuration error in the install

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.