Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Example of Android application with two players

This example demonstrates how two or more players can be displayed in one application. Each of the players can be used to play a different stream.


Work with code of the example

To analyze the code, let's take class TwoPlayersActivity.java of the 2players example version with hash 4ed4c6d77, which can be downloaded with corresponding build 1.0.1.3.

Functions of initialization, creating stream, starting and stopping playback work the same as described in the example Player.

Unlike the example Player, this one has two Play buttons for starting playback of corresponding streams.

line 225

Code Block
languagejs
themeRDark
play1Stream.play();


line 299

Code Block
languagejs
themeRDark
play2Stream.play(); 


SurfaceViewRenderer, which will be used to play corresponding video stream, is passed with object StreamOptions when the stream is created.
Mehod StreamOptions.setRenderer() is used to add renderer to StreamOptions object.

line 191

Code Block
languagejs
themeRDark
streamOptions.setRenderer(remote2Render); 


line 265

Code Block
languagejs
themeRDark
streamOptions.setRenderer(remote2Render); 


Playback is stopped when corresponding Stop button is pressed.

line 235

Code Block
languagejs
themeRDark
play1Stream.stop(); 


line 309

Code Block
languagejs
themeRDark
play2Stream.stop();