如何在Android模拟器从远程URL显示视频? [英] How to display Video in the Android Emulator from Remote URL?

查看:133
本文介绍了如何在Android模拟器从远程URL显示视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的code以显示Android模拟器的视频文件,它工作正常时,视频文件存储在一个SDcard.But当我给视频中的任何URL中的code不工作。

I am using the following code to display a video file in the android emulator,it works fine when the video file is stored in a SDcard.But when i give any URL of a video the code not working.

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.View;
import android.widget.*;

public class playerActivity extends Activity 
{
Button b;
VideoView preview;
SurfaceHolder holder;
MediaPlayer mp;

 private String path = "/data/data/payoda.android/funny.mp4";

//private String path = "http://www.daily3gp.com/vids/3.3gp";

public void onCreate(Bundle savedInstanceState) 
{
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);
	preview=(VideoView)findViewById(R.id.surface);
	holder=preview.getHolder();
	b=(Button)findViewById(R.id.cmd_play);
	b.setOnClickListener(new View.OnClickListener()
	{
	public void onClick(View v)
	{
		try
		{
		        mp=new MediaPlayer(); 
	    	    mp.setDataSource(path);
	    	    mp.setScreenOnWhilePlaying(true);
	    	    mp.setDisplay(holder);
	    	    mp.prepare();
	    	    mp.start();
		}
		catch(Exception e)
		{

		}
	}
	});
}
}

例外thorwn是:

The Exception thorwn is:

prepare failed:
status=0xC8

在LogCat中细节是:

The LogCat details are:

09-16 12:16:36.729: ERROR/PlayerDriver(542): Command PLAYER_INIT completed with an error or info PVMFErrContentInvalidForProgressivePlayback
09-16 12:16:36.739: ERROR/MediaPlayer(2867): error (200, -27)

在上面的code。如果更改路径变量模拟器的屏幕是黑的单button.May是我必须做更多的事情,以显示从远程URL的视频,我不知道该怎么do.Any是具有这方面有任何想法,请帮助我。

In the above code if change the path variable the Emulator screen is black with single button.May be i have to do some more things to display the video from the Remote URL,i dont know what to do.Any one having any idea about this please help Me.

推荐答案

首先,不要使用模拟器进行测试的视频播放。它能够处理视频播放效果十分有限。用一个实际的Andr​​oid设备。

First, do not use the emulator for testing video playback. Its ability to handle video playback is very limited. Use an actual Android device.

其次,经常检查LogCat中(亚行logcat ,DDMS或DDMS透视图在Eclipse)的警告,当你遇到多媒体问题。的OpenCore - 使用Android的多媒体引擎 - 有一种倾向,记录错误级别的条件警告

Second, always check LogCat (adb logcat, DDMS, or DDMS perspective in Eclipse) for warnings when you run into multimedia problems. OpenCORE -- the multimedia engine used by Android -- has a tendency to log error-level conditions as warnings.

例如,您的视频文件可能不会被设置为渐进式下载,这是需要的HTTP流。在Linux上,您可以通过安装MP4Box和运行修补MP4视频的渐进式下载 MP4Box -hint<文件>

For example, your video file may not be set up for progressive download, which is required for HTTP streaming. On Linux, you can patch up MP4 videos for progressive download by installing MP4Box and running MP4Box -hint <file>.

这篇关于如何在Android模拟器从远程URL显示视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆