How to keep the display on during audio/video playback

How to keep the display on during audio/video playback 

// Create this variable at a global scope. Set it to null.
private DisplayRequest dispRequest = null;

public void StartVideoPlayback()
{
    if (dispRequest == null) 
    {
        // Activate a display-required request. If successful, the screen is 
        // guaranteed not to turn off automatically due to user inactivity.
        dispRequest = new DisplayRequest();
        dispRequest.RequestActive();
        
        rootPage.NotifyUser("Display request activated",
                        NotifyType.StatusMessage);
        
        // Insert your own code here to start the video.
     }
}

public void StopVideoPlayback()
{
    // Insert your own code here to stop the video.
    if (dispRequest != null)
    {
        // Deactivate the display request and set the var to null.
        dispRequest.RequestRelease();
        dispRequest = null;
        
        rootPage.NotifyUser("Display request released",
                            NotifyType.StatusMessage);
    }
}

Quelle

Kommentare sind geschlossen

Tags