开发者

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");
mMedi开发者_Go百科aPlayer.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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜