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:
Can anyone help me?
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With