Versions Compared

Key

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

Example of iOS 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.

Image Added

Work with code of the example

To analyze the code, let's take TwoPlayers example version with hash 088a74d, which can be downloaded with build 2.2.4.

View class for the main view of the application: ViewController (header file ViewController.h; implementation file ViewController.m).

Functions of establishing connection, creating stream and starting playback work the same as described in the example Player.
Unlike the example Player, method for establishing connection is called when Connect button is tapped.

(ViewController.m, line 253)

Code Block
languagejs
themeRDark
[self connect]; 


This example has two views for displaying video and two corresponding Play buttons; corresponding method is called to start playing when one of the buttons is tapped.

(ViewController.m, line 270)

Code Block
languagejs
themeRDark
[self play1Stream]; 


(ViewController.m, line 291)

Code Block
languagejs
themeRDark
[self play2Stream]; 


Playback is stopped when corresponding Stop button is tapped: FPWCSApi2Stream method stop is called for corresponding stream

(ViewController.m, line 262)

Code Block
languagejs
themeRDark
[player1Stream stop:&error]; 


(ViewController.m, line 283)

Code Block
languagejs
themeRDark
[player2Stream stop:&error];