Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 视频视图中的视频不显示_Java_Android_Android Relativelayout_Android Videoview - Fatal编程技术网

Java 视频视图中的视频不显示

Java 视频视图中的视频不显示,java,android,android-relativelayout,android-videoview,Java,Android,Android Relativelayout,Android Videoview,我有一个应用程序,在我的布局中,请参见下面的xml。这里有我的问题中的VideoView和TextView相同的应用程序,但在布局中有一些更改。TextView显示并滚动良好,但现在当我尝试启动它时,视频不显示。我做错了什么 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:la

我有一个应用程序,在我的布局中,请参见下面的xml。这里有我的问题中的VideoView和TextView相同的应用程序,但在布局中有一些更改。TextView显示并滚动良好,但现在当我尝试启动它时,视频不显示。我做错了什么

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
<VideoView
    android:id="@+id/videoview"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/textview"
/>
<TextView 
    android:id="@+id/textview" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:layout_alignParentBottom="true"
    android:maxLines="30" 
    android:text="My test App"
/>
</RelativeLayout>

为了启动视频,我使用了TCP服务器和反射,如果我删除TextView,它就可以正常工作。你为什么不使用surfaceview呢?你是在使用mediaplayer吗

private void iniElements() {
    mPreview = (SurfaceView) findViewById(R.id.screen_tutorial_video_surface);
    holder = mPreview.getHolder();
    holder.addCallback(this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    holder.setFixedSize(getWindow().getWindowManager().getDefaultDisplay().getWidth(), getWindow().getWindowManager().getDefaultDisplay().getHeight());
    mMediaPlayer = new MediaPlayer();
    mMediaPlayer.setDisplay(holder);
}

private void iniPlayer() {
    try {
        mMediaPlayer.setDataSource(videoPath); 
        mMediaPlayer.prepare();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
}

嗯,我能够找到一个解决我的问题的方法,通过返回感谢Sunil并对其进行一些修改,我的问题中也提到了这一点:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
<VideoView
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/videoview"
    android:layout_above="@+id/ScrollView01"
/>
<ScrollView   
    android:id="@+id/ScrollView01"  
    android:layout_height="350px"   
    android:layout_width="fill_parent"
    android:layout_gravity="bottom"
    android:layout_alignParentBottom="true"
    >
<TextView 
    android:layout_width="wrap_content" 
    android:id="@+id/textview" 
    android:layout_height="wrap_content" 
    android:text="Wellcome"
/>
</ScrollView>
</RelativeLayout>
改变是在ScrollView-android:layout_height=350px中,而不是android:layout_height=wrap内容,它将内容放在屏幕的下部,但具有特定的大小,并且不超过该大小。
虽然这不是可能的最干净的方式,但它确实满足了我的需要。我希望有人会觉得它有用。

仅显示xml布局文件并不能帮助任何人回答您的问题-您需要显示您正在使用的代码。@MisterSquonk谢谢。补充。我希望这会有帮助。我正在使用VideoView作为更大程序的一部分。由于VideoView实际上是MediaPlayer和surface的封装,我认为没有理由单独管理它。我认为这与此无关,但与一些布局配置有关。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
<VideoView
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/videoview"
    android:layout_above="@+id/ScrollView01"
/>
<ScrollView   
    android:id="@+id/ScrollView01"  
    android:layout_height="350px"   
    android:layout_width="fill_parent"
    android:layout_gravity="bottom"
    android:layout_alignParentBottom="true"
    >
<TextView 
    android:layout_width="wrap_content" 
    android:id="@+id/textview" 
    android:layout_height="wrap_content" 
    android:text="Wellcome"
/>
</ScrollView>
</RelativeLayout>