Reputation:
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>
Upvotes: 3
Views: 6564
Reputation: 6791
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);
}
thank @Qadir Hussain .it work for me
Upvotes: 1
Reputation: 1
`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{
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();
}
}`
Upvotes: 0
Reputation: 553
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" />
Upvotes: 5
Reputation: 8856
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"
Upvotes: 1
Reputation: 216
If using live streaming, then there is a layout file for live streaming with the name of "mediaplayer_2.xml"
change the layout with following.
<?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>
Through this way i resolve my issue.
Upvotes: 0