yes its possible to stream videos from firebase.
first create an exoplayer in your xml file
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="0sp"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
i have set the height as 0 cuz im gonna fix the height programmatically later
then declare simple SimpleExoPlayer in your activity as player.
SimpleExoPlayer player;
then in you follow these steps
//declare your PlayerView
final PlayerView playerView = mview.findViewById(R.id.video_view);
//your database ref
final StorageReference storageReference =
FirebaseStorage.getInstance().getReference("/Post_Video/"+ video + ".mp4");
player = ExoPlayerFactory.newSimpleInstance(MainActivity.this);
playerView.setPlayer(player);
playerView.setVisibility(View.VISIBLE);
playerView.getLayoutParams().height=550;
playerView.getLayoutParams().width=950;
storageReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter.Builder(MainActivity.this).build();
TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter));
ExoPlayer exoPlayer = (SimpleExoPlayer) ExoPlayerFactory.newSimpleInstance(MainActivity.this);
Uri video = Uri.parse(uri.toString());
DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory("video");
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource mediaSource = new ExtractorMediaSource(video,dataSourceFactory,extractorsFactory,null,null);
playerView.setPlayer(exoPlayer);
exoPlayer.prepare(mediaSource);
exoPlayer.setPlayWhenReady(false);
}
});