Share via


Player.StateChanged Event

Raised to notify applications that the player state has changed.

Namespace:  Microsoft.Rtc.Collaboration.AudioVideo
Assembly:  Microsoft.Rtc.Collaboration (in Microsoft.Rtc.Collaboration.dll)

Syntax

'Declaration
Public Event StateChanged As EventHandler(Of PlayerStateChangedEventArgs)
'Usage
Dim instance As Player
Dim handler As EventHandler(Of PlayerStateChangedEventArgs)

AddHandler instance.StateChanged, handler
public event EventHandler<PlayerStateChangedEventArgs> StateChanged

Remarks

The StateChanged Event is raised for every state change that occurs on the player, including when the application causes the state change.

Examples

The following example shows an app subscribing to a StateChanged event. The event handler detaches all AudioVideoFlow if play is completed.

C# Subscribing to StateChanged event.

 

            player.StateChanged += delegate(object sender, PlayerStateChangedEventArgs e)
            {
                // Detaches all flow once player completes.
                if (e.TransitionReason == PlayerStateTransitionReason.PlayCompleted)
                {
                    foreach (AudioVideoFlow avFlow in player.AudioVideoFlows)
                    {
                        player.DetachFlow(avFlow);
                    }
                }
            };


See Also

Reference

Player Class

Player Members

Microsoft.Rtc.Collaboration.AudioVideo Namespace