In the next step you'll learn more about controlling streams in Media Management guide.
Storm Library is a signal and data processing library designed for Storm Server, and based on the ExoPlayer library. This library is only used to run the playback, as it does not include a working user interface (GUI), like its JavaScript counterpart.
MainActivity.java file
StormLibrary stormLibrary = new StormLibrary();
stormLibrary.initExoPlayer(this, findViewById(R.id.exoPlayerView));
StormMediaItem stormMediaItem = new StormMediaItem("sub1.mydomain.com",443,true,"live","my_stream_320","320p");
stormLibrary.addMediaItem(stormMediaItem);
stormMediaItem = new StormMediaItem("sub1.mydomain.com",443,true,"live","my_stream_720","720p");
stormLibrary.addMediaItem(stormMediaItem, true);
try {
stormLibrary.prepare(true);
} catch(Exception e){
e.printStackTrace();
}
activity_main.xml file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".MainActivity">
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/exoPlayerView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="H,16:9"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/exoPlayerView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="H,16:9"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>
ExoPlayer library view implementation.
StormLibrary stormLibrary = new StormLibrary();
Creation of a new StormLibrary object. This object is responsible for downloading a stream from the Storm server and for all actions such as play, pause, stop, seek.
stormLibrary.initExoPlayer(this, findViewById(R.id.exoPlayerView));
ExoPlayer is assigned to the StormLibrary object.
StormMediaItem stormMediaItem = new StormMediaItem("stormserver.myhost.com",443,true,"live","my_stream_320","320p");
stormLibrary.addMediaItem(stormMediaItem);
New StormMediaItem object containing information about the stream is created. Then it is added to Storm Library on the StormLibrary object. If you wish to learn more about StormMediaItem or use Gateway server approach please check our Media management section of this library.
stormMediaItem = new StormMediaItem("stormserver.myhost.com",443,true,"live","my_stream_720","720p");
stormLibrary.addMediaItem(stormMediaItem, true);
If the player is to support multiple qualities, we can add any number of StormMediaItem objects. Thanks to this approach, we will be able to create a video quality selection button and freely switch between objects.
try {
stormLibrary.prepare(true);
} catch(Exception e){
e.printStackTrace();
}
The prepare() method is responsible for preparing the library to run. Its parameter is the boolean autostart field, which tells you whether the player should start playing immediately or wait for the play button to be pressed.
To avoid the effect of double video playback after rotating the device, a <activity> tag in the AndroidManifest.xml file should include parameter android:configChanges="orientation|screenSize":
android:configChanges="orientation|screenSize"
Create a free ticket and our support team will provide you necessary assistance.