Apollo_17_stroll.mpg could not be played


I was doing the challenge abut playing video from this chapter, using VideoView with a MediaController, and I got a dialog saying this mpg couldn’t be played. This was on my device, a Samsung 2 running 4.0.4. When I swapped it out for a .mp4 video I had created on the device, everything worked well.


Had the same issue on a Galaxy Nexus running 4.2.2. Converted the video to an m4v file and it worked.


I am having trouble doing the Challenge. I am using MediaPlayer and SurfaceView, not the VideoView. When I run, I get an error of the form:

05-13 19:02:13.900: D/MediaPlayer(14630): java.io.IOException: Prepare failed.: status=0x1
on my line:
mPlayer = MediaPlayer.create(c, R.raw.apollo_17_stroll);

My idea for the challenge was to create a new class VideoPlayer, very much like AudioPlayer except with a constructor like so:

public VideoPlayer(SurfaceHolder holder)
mSurfaceHolder = holder;


Any ideas as to what is going on? The previous two posts indicated a problem with mpg files. Does this apply if you are using MediaPlayer (instead of VideoView)? If so, how do I convert the file to mp4 (or something else?).


UPDATE!!! By downloading an mp4 file, I was able to get things working. Sort of… The mp4 file can be downloaded at:
support.apple.com/kb/HT1425 I’m sure you could find better ones somewhere else. So I still have the question: "Can Android handle mpg files and if not, how to convert mpg to mp4 on MACs.

I say “Sort of…” above because when the video plays, it is very choppy. I’m not sure if this is a limitation of using MediaPlayer, or if I’m doing something wrong. Also, to get things working, I had to give up one of my slick ideas. Inside fragment_hello_moon.xml, I introduced a surface view that I made invisible:


Then in code HelloMoonFragment.java, I had:

mPlayVideoButton = (Button)v.findViewById(R.id.hellomoon_playVideoButton);
mPlayVideoButton.setOnClickListener(new View.OnClickListener() {

		public void onClick(View v) {
			mVideoPlayer = new VideoPlayer(mVideoSurfaceView.getHolder());

In other words, I made the image view invisible when I was using the surface view and vice versa. Things did not work (the movie was not shown). I suspect there were problems with the the call to setDisplay (where you give it the SurfaceHolder). Perhaps it takes some time after making the Surface View visible before you can use the SurfaceHolder?

Anyhow, I’d be interested to see if anyone gets the Challenge to work using MediaPlayer. I think I will now try VideoView.



Be aware that the video plays out quite differently on the phone versus the simulator. My problems of “choppiness” went away when I ran the program on the actual phone. Perhaps the emulator is just not very good at playing videos? I’m on a MacBook Air running Mountain Lion with an Intel i5 processor at 1.8 GHz and 4 GB of ram.


The file wouldn’t work for me on my Nexus 4, I ended up using the sample mp4 file as mentioned above: support.apple.com/kb/HT1425


[code]public class HelloMoonFragment extends Fragment {

private VideoView videoView;
private Uri resourceUri = Uri.parse("android.resource://" + "com.bignerdranch.android.hellomoon/raw/sample_mpeg4");
private Button mPlayButton;
private Button mStopButton;

public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_hello_moon, parent, false);

    videoView = (VideoView)v.findViewById(R.id.VideoView);

    mPlayButton = (Button)v.findViewById(R.id.hellomoon_playButton);
    mPlayButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
    mStopButton = (Button)v.findViewById(R.id.hellomoon_stopButton);
    mStopButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

    return v;

public void onDestroy() {



[code]<?xml version="1.0" encoding="utf-8"?>

    <Button android:id="@+id/hellomoon_stopButton"



As people mentioned, the video file doesn’t work properly. In my case (Nexus7) , i dont get any video but i do get audio playing at a very fast speed (like the chipmunks). Using a different video solved the problem.


We’ll get this fixed in the solutions. Will post back here when that’s ready.


This is one case where I think I’m just going to have to provide multiple alternatives. Video playback is notoriously frustrating on Android - only newer devices even offer the ability to reliably query which codecs are supported out of the box. (Which is why 3rd party video players are so popular.)

I’ve added a constant framerate mp4 to the repo. I’ll repost here when the updated solutions are up.


I also could not play the mpg in my emulator. I just converted the mpg to mp4 using site:


Is the mp4 available yet?


I found if I converted apollo_17_stroll.mpg to apollo_17_stroll.m4v in Quicktime as MP4 video and audio to play on iPod/iPhone/iPad, it played on my Nexus 5.


Hi, I just converted the mpg file to mp4 format with ffmpeg. Everything work very well on Nexus 7.

$> ffmpeg -i apollo_17_stroll.mpg -f mp4 -vcodec libx264 -acodec libvo_aacenc apollo_17_stroll.mp4

For windows : ffmpeg.zeranoe.com/builds/
For Linux/Mac : ffmpeg.org/download.html