我尝试以两种方式导入视频,一种是将视频文件包含到 Raw 文件夹中,另一种是直接调用链接
import android.app.Activity;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;
public class HomeVideo extends Activity{
private VideoView videoView;
String extStorageDirectory;
private String current;
private VideoView mVideoView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// set the view to our layout file
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.main);
// Video view: to view our video
String path ="http://commonsware.com/misc/test2.3gp";
VideoView video = (VideoView) findViewById(R.id.video);
Uri uri = Uri.parse("android.resource://comm.fib.work/"+R.raw.test2);
//Uri uri=Uri.parse(path);
video.setVideoURI(uri);
video.start();
}
}
在错误日志中显示
05-15 13:54:14.981: D/MediaPlayer(586): 获取元数据 05-15 13:57:57.711: D/MediaPlayer(623): 获取元数据
我在清单中包含了权限
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
我找不到丢失的东西。