Screen Mirroring

You can mirror the device screen and sound to another device wirelessly using the screen mirroring feature. Tizen follows the Wi-Fi Display Technical Specification and supports the feature as a sink which receives shared data from a source device that supports the Wi-Fi Display, and displays it. Remember to prepare your application to use the screen mirroring sink functionality and set up the necessary callbacks before you start, and release the resources when you are done.

The main features of the Tizen.Multimedia.Remoting.ScreenMirroring class include the following:

  • Preparing for screen mirroring

    You can prepare for screen mirroring by registering an event handler to track screen mirroring state changes.

  • Managing the connection to the screen mirroring source

    You can connect to a screen mirroring source, and start, pause, and resume the screen mirroring sink.

  • Monitoring state changes in the screen mirroring sink

    To track state changes, you can register an event handler for the StateChanged event of the Tizen.Multimedia.Remoting.ScreenMirroring class.

    You can also handle any errors with the ErrorOccurred event.

The following figure illustrates the screen mirroring states.

Figure: Screen mirroring state diagram

State diagram

Prerequisites

To use the methods and properties of the Tizen.Multimedia.Remoting.ScreenMirroring class, include the Tizen.Multimedia.Remoting namespace in your application:

C#
Copy
using Tizen.Multimedia.Remoting;

Prepare for screen mirroring

To prepare for screen mirroring, proceed as follows:

  1. Define and register an event handler for the StateChanged event of the Tizen.Multimedia.Remoting.ScreenMirroring class:

    C#
    Copy
    void OnStateChanged(object sender, ScreenMirroringStateChangedEventArgs args) { Tizen.Log.Info(LOG_TAG, $"Current state = {args.State}"); } screenMirroring.StateChanged += OnStateChanged;
  2. Prepare the screen mirroring sink using the Prepare() method with an instance of the Tizen.Multimedia.Display class as a parameter:

    C#
    Copy
    screenMirroring.Prepare(new Display(mediaView));

    The screen mirroring state changes to Prepared.

Connect and starting screen mirroring

To connect to a source and start screen mirroring, proceed as follows:

  1. Connect to the screen mirroring source using the ConnectAsync() method of the Tizen.Multimedia.Remoting.ScreenMirroring class with the source IP address as a parameter:

    C#
    Copy
    await screenMirroring.ConnectAsync(ipAddress);

    The screen mirroring state changes to Connected.

  2. Start the screen mirroring using the StartAsync() method:

    C#
    Copy
    await screenMirroring.StartAsync();

    The screen mirroring state changes from Connected to Playing.

Handle screen mirroring errors

You can receive notifications of errors caused by internal screen mirroring issues or by the source device disconnecting the session. Define and register an event handler for the ErrorOccurred event of the Tizen.Multimedia.Remoting.ScreenMirroring class:

C#
Copy
void OnErrorOccurred(object sender, ScreenMirroringErrorOccurredEventArgs args) { Tizen.Log.Info(LOG_TAG, $"Error = {args.Error}"); } screenMirroring.ErrorOccurred += OnErrorOccurred;
  • Dependencies
    • Tizen 4.0 and Higher
Media Conversions
Next Radio
Submit your feedback to GitHub