Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vitamio full screen videoview

I try to play live streaming with Vitamio. I fixed some problems however I can't fix this problem. Video doesn't play in fullscreen. These are my codes. I hope you can help me! Thank you and sorry for my bad English.

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>

2 Answers

Put the VideoView in a RelativeLayout and set it as:

<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" />
like image 99
ali.turan Avatar answered Nov 22 '25 23:11

ali.turan


Use this method to stretch your videoview in onCreate() method of your activity

mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0);

To handle onConfigurationChange();

use below code

@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");
    }

}

also add this in your activity menifest file

android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
like image 34
Qadir Hussain Avatar answered Nov 22 '25 23:11

Qadir Hussain