Android 为什么我不能在emulator中查看视频?
我见过几个类似的问题,但我想确定。。 在模拟器上运行视频失败。它是一致的吗?是否有人成功地在模拟器上运行了视频 以下是我使用的代码:Android 为什么我不能在emulator中查看视频?,android,video,emulation,Android,Video,Emulation,我见过几个类似的问题,但我想确定。。 在模拟器上运行视频失败。它是一致的吗?是否有人成功地在模拟器上运行了视频 以下是我使用的代码: import android.app.Activity; import android.net.Uri; import android.os.Bundle; import android.widget.MediaController; import android.widget.VideoView; public class TTTTest extends Ac
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,在这两种情况下都不起作用
main.xml如下所示:
<?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>
清单是默认清单。
谁能告诉我我的代码有问题吗?
p、 我使用android 2.2环境运行模拟器。模拟器在播放某些视频时确实存在问题,因此我一直在实际设备上进行所有视频测试。当视频在模拟器上工作时,通常速度非常慢,最多只能抵消声音。我还建议不要将视频存储在APK中,但也就是说,我相信您需要在包名后再加一个斜杠:
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.samplevideo);
在此发布您遇到的问题和代码格式我收到了抱歉,此视频无法播放错误。我认为模拟器存在问题,因为对我来说,当您在设备上运行应用程序而不是在模拟器上运行应用程序时,会播放视频…感谢您的回复。我已经弄明白了刀砍的事。现在我可以运行3gp文件了。mp4视频仍未运行。