Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how play video in fullscreen with exoplayer?

this is my code:

  setContentView(R.layout.activity_video);
        SimpleExoPlayerView exoPlayerView;
        //SimpleExoPlayer exoPlayer;
        Intent intent = getIntent();

        String url_video_passato = intent.getStringExtra("URL_VIDEO");
        System.out.println("PASSATO?"+url_video_passato);
       // String videoURL = "http://vod06.msf.ticdn.it/farmunica/2017/11/124899_15fc565cd8f965/15fc565cd8f965-11_0.mp4";


            exoPlayerView = (SimpleExoPlayerView) findViewById(R.id.exo_player_view);
            try {


                BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
                TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter));
                exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector);

                Uri videoURI = Uri.parse(url_video_passato);

                DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory("exoplayer_video");
                ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
                MediaSource mediaSource = new ExtractorMediaSource(videoURI, dataSourceFactory, extractorsFactory, null, null);

                exoPlayerView.setPlayer(exoPlayer);
                exoPlayer.prepare(mediaSource);
                exoPlayer.setPlayWhenReady(true);
            }catch (Exception e){
                Log.e("MainAcvtivity"," exoplayer error "+ e.toString());
            }

VIDEO ACTIVITY LAYOUT

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="marco.uomini.donne.Video">
        <com.google.android.exoplayer2.ui.SimpleExoPlayerView
        android:id="@+id/exo_player_view"
        android:layout_alignParentStart="true"
        android:layout_alignParentEnd="true"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
       >

    </com.google.android.exoplayer2.ui.SimpleExoPlayerView>

</android.support.constraint.ConstraintLayout>

Video is not playing in fullscreen by using exoplayer, i don't know why.
this is the result as of now:

enter image description here

Can anyone help me?

like image 533
Sisso Avatar asked Nov 26 '17 11:11

Sisso


1 Answers

Try change the resize mode of SimpleExoPlayerView like below

app:resize_mode="fill"

You may also set it from java

simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
like image 121
Munir Avatar answered Oct 31 '22 20:10

Munir