Android的视频,听到声音,但没有视频 [英] android video, hear sound but no video
问题描述
我已经尝试了几种不同的例子,但我不能让任何视频显示。我听到声音,但没有视频。我想,也许我只是有一个不正确的视频格式,所以我下载了一个菲亚特的商业3GP格式和仍然没有喜悦。我使用Eclipse的Java EE与Android SDK和我的应用程序目标1.5 SDK(API等级3),而谷歌的API。可能有人请张贴链接到已知的视频在Android的播放或指出我的问题与code。我已经尝试了所有我能想到的..有/无prepare ..不同的布局等。
I have tried several different examples but I cannot get any video to show. I hear sound but no video. I thought maybe I just had a incorrect video format so I downloaded a fiat commercial in 3gp format and still no joy. I am using the Eclipse Java EE with android sdk and my app targets the 1.5 sdk (Api Level 3) without google api. Could someone please post a link to a video known to play in android or point out my problem with the code. I have tried all I could think of .. with/without prepare .. different layouts etc.
下面是我在活动的onCreate
Here is my onCreate in activity
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.video_test);
SurfaceView v = (SurfaceView) findViewById(R.id.surface_video);
SurfaceHolder holder = v.getHolder();
// Set the transparency
//getWindow().setFormat(PixelFormat.UNKNOWN);
// Set a size for the video screen
//holder.addCallback(this);
holder.setFixedSize(400,300);
MediaPlayer mp = MediaPlayer.create(this, R.raw.fiat);
mp.setDisplay(holder);
//mp.setAudioStreamType(2);
try {
//mp.prepare();
mp.start();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
她是video_test.xml布局
her is the layout in video_test.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"
>
<SurfaceView android:id="@+id/surface_video"
android:layout_width="250px"
android:layout_height="250px">
</SurfaceView>
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="10dip"
>
</LinearLayout>
</LinearLayout>
>块引用
推荐答案
如果您使用的是仿真器,它可能无法正常工作。仿真器缺少硬件加速的Android设备使用。例如,在一个2.6GHz的酷睿2,我有时可以得到一个视频播放,但并非总是如此。在速度较慢的计算机,视频播放永远不会奏效。在一个2.5GHz的酷睿2四核,我总是得到的视频播放。话虽这么说,我通常在实际设备上测试视频播放。
If you are using the emulator, it may not work. The emulator lacks the hardware acceleration available in Android devices. For example, on a 2.6GHz Core 2 Duo, I sometimes can get a video to play back, but not always. On slower machines, video playback never works. On a 2.5GHz Core 2 Quad, I always get video playback. That being said, I usually test video playback on actual devices.
我也是不确定的,如果视频播放的作品从原料资源。我强烈建议你尝试使用视频从一个文件在SD卡上的第一。
I am also uncertain if video playback works from raw resources. I strongly encourage you to try using a video from a file on the SD card first.
对于影片肯定的工作,我知道,纪录片与你和音乐为我们的孙子从的此处在他们的MP4形式的工作。
With respect to videos that definitely work, I know that "Documentaries and You" and "Music for our Grandchildren" from here work in their MP4 forms.
这篇关于Android的视频,听到声音,但没有视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!