3

我尝试用 Vitamio 播放直播。我解决了一些问题,但是我无法解决这个问题。视频无法全屏播放。这些是我的代码。我希望你能帮帮我!谢谢你,对不起我的英语不好。

package com.uusoftware.tvizle;

import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.WindowManager;

public class Trt extends Activity{

    VideoView videoView;

    private void Trt1(){
        String httpLiveUrl = "rtmp://trt-i.mncdn.com/trt1/trt15";   
        videoView = (VideoView) findViewById(R.id.VideoView);
        videoView.setVideoURI(Uri.parse(httpLiveUrl));
        MediaController mediaController = new MediaController(this);
        videoView.setMediaController(mediaController);
        videoView.requestFocus();
        videoView.start();
    }


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.videolayout);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        Trt1();             
    }     
}


<?xml version="1.0" encoding="utf-8"?>`
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <io.vov.vitamio.widget.CenterLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <io.vov.vitamio.widget.VideoView
            android:id="@+id/VideoView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true" />
    </io.vov.vitamio.widget.CenterLayout>

</LinearLayout>
4

5 回答 5

5

放入VideoViewaRelativeLayout并将其设置为:

<io.vov.vitamio.widget.VideoView 
         android:id="@+id/vitamioView" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentTop="true" 
         android:layout_alignParentRight="true" 
         android:layout_alignParentBottom="true" />
于 2014-05-05T20:54:18.413 回答
1
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        mVideoView.setVideoLayout(io.vov.vitamio.widget.VideoView.VIDEO_LAYOUT_STRETCH, 0);

} else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        mVideoView.setVideoLayout(io.vov.vitamio.widget.VideoView.VIDEO_LAYOUT_ORIGIN, 0);
}

谢谢@Qadir Hussain。它对我有用

于 2014-11-13T02:59:28.720 回答
1

使用此方法在活动的 onCreate() 方法中拉伸视频视图

mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0);

处理 onConfigurationChange();

使用下面的代码

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {

        mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0);
        Log.e("On Config Change", "LANDSCAPE");

    } else {
        mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0);
        Log.e("On Config Change", "PORTRAIT");
    }

}

还将其添加到您的活动清单文件中

android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
于 2014-06-11T07:02:10.690 回答
0

`包 com.uusoftware.tvizle;

import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.WindowManager;

public class Trt extends Activity{

private VideoView mVideoView;

private void Trt1(){
    String httpLiveUrl = "rtmp://trt-i.mncdn.com/trt1/trt15";   
    mVideoView = (VideoView) findViewById(R.id.VideoView);
    mVideoView.setVideoURI(Uri.parse(httpLiveUrl));
    MediaController mediaController = new MediaController(this);
    mVideoView.setMediaController(mediaController);
    mVideoView.requestFocus();
    mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0);
    mVideoView.start();
}


public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.videolayout);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    Trt1();             
}     

}`

于 2014-08-13T00:16:08.363 回答
0

如果使用直播,则有一个名为“mediaplayer_2.xml”的直播布局文件

使用以下更改布局。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<io.vov.vitamio.widget.CenterLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <SurfaceView
        android:id="@+id/surface"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center" >
    </SurfaceView>
</io.vov.vitamio.widget.CenterLayout>

</LinearLayout>

通过这种方式,我解决了我的问题。

于 2013-10-25T09:42:31.443 回答