【发布时间】:2011-12-13 23:17:27
【问题描述】:
我在三星 Galaxy S 上播放我的视频时遇到问题 ..如果它来自 sdcard,它可以正常播放,但是当我上传到服务器然后发送 URL 时,它给了我“抱歉,无法播放此视频” .这是一个.mp4视频,我使用Sothink视频转换器将其转换为android格式。
这是我的 VideoView 代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(ArrayAdapter.createFromResource(getApplicationContext(),
R.array.lecturehalls,R.layout.list_item));
final String[] links = getResources().getStringArray(R.array.vid_links);
getListView().setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String content = links[position];
Intent showContent = new Intent(getApplicationContext(),
VideoOutput.class);
showContent.setData(Uri.parse(content));
startActivity(showContent);
}
});
}
注意:URL 路径存储在 strings.xml 中的数组中 当我使用这个链接时它工作正常:http://www.pocketjourney.com/downloads/pj/video/famous.3gp 我的链接也可以正常工作,我在电脑上测试过,但是在手机上它不起作用!
这就是我得到的:
12-14 02:11:01.621: ERROR/PlayerDriver(1287): Command PLAYER_INIT completed with an error or info PVMFFailure
编辑: 视频输出类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videoview);
MediaController mediaController = new MediaController(this);
VideoView videoView = (VideoView) findViewById(R.id.video);
Intent launchingIntent = getIntent();
String content = launchingIntent.getData().toString();
mediaController.setMediaPlayer(videoView);
videoView.setVideoPath(content);
videoView.setMediaController(mediaController);
videoView.requestFocus();
videoView.start();
mediaController.show();
}
【问题讨论】:
标签: android url video video-streaming