为什么我不能看视频模拟器? [英] Why can't I see video in emulator?
问题描述
我见过类似这样的一些问题,但我想,以确保..
我失败对我的模拟器中运行视频。是不是一致?有谁成功地运行在模拟器上的视频?
I have seen few questions similar to this one, but I wanted to make sure.. I fail running video on my emulator. Is it consistent? Does anyone succeeded running a video on the emulator?
以下是code我使用:
The following is the code I use:
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class TTTTest extends Activity {
/** Called when the activity is first created. */
private MediaController mc;
VideoView vd;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
vd = (VideoView) findViewById(R.id.VideoView);
Uri uri = Uri.parse("android.resource://" + getPackageName() + R.raw.samplevideo);
mc = new MediaController(this);
vd.setMediaController(mc);
vd.setVideoURI(uri);
vd.start();
}
}
samplevideo或者是MP4或3GP(在两种情况下它不工作)
"samplevideo" is either mp4 or 3gp (in both cases its not working)
main.xml中如下所示:
main.xml is as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<VideoView android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/VideoView"></VideoView>
</LinearLayout>
和清单是默认的。
谁能告诉我,如果我有一个问题,我的code?
附:我使用的android 2.2环境中运行的模拟器。
and the manifest is the default one. Can anyone please tell me if I have a problem with my code? p.s. I am running the emulator using android 2.2 environment.
推荐答案
仿真器确实有玩一些视频的问题,所以我一直做在实际设备上所有的视频测试。当视频确实在模拟器上工作,这通常是非常缓慢充其量(1fps,抵消音)。我也建议不要存放在APK视频,但是,这么说,我相信你需要另一个斜杠你的包名之后:
The emulator does have issues playing some videos, so I have always done all video testing on actual devices. When video does work on the emulator, it is typically extremely slow (1fps, offset sound) at best. I also recommend not storing the videos in the APK, but, that said, I believe you need another slash after your package name:
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.samplevideo);
这篇关于为什么我不能看视频模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!