dev_android
dev_android

Reputation: 8818

Android play video from url problem

I have .mp4 file. If I placed it in the memory card, android's default video player can play it normally. But If I upload it to the web server and try to play it through the web browser of Android, it is giving mag saying, "Sorry, the video is not valid for seaming to this device."

The same is happening is I want to play it through my App. I used the following code:

private SurfaceHolder holder;
mPreview = (SurfaceView) findViewById(R.id.surface);
holder = mPreview.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource("http://www.languagehostess.com/videos/aka1.mp4");
mMediaPlayer.setDisplay(holder);
mMediaPlayer.prepare();
mMediaPlayer.setOnBufferingUpdateListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnVideoSizeChangedListener(this);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 

It is giving the follwing error:

Command PLAYER_INIT completed with an error or info PVMFFailure

What is the problem related the that video or code?

Upvotes: 1

Views: 2099

Answers (1)

Ovidiu Latcu
Ovidiu Latcu

Reputation: 72311

You need to check the Android Video Encoding Recommandations . Make sure that your video is encoded with the supported code, and your video respects the resolutions. I had the exact same issues and after the video were properly encoded the streamming worked.

Also if you didn't noticed yet, usually the emulator does not play them, and you'll have to test on a real device.

Upvotes: 1

Related Questions