MediaElement.MediaOpened Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs when the media stream has been validated and opened, and the file headers have been read.
// Register
event_token MediaOpened(RoutedEventHandler const& handler) const;
// Revoke with event_token
void MediaOpened(event_token const* cookie) const;
// Revoke with event_revoker
MediaElement::MediaOpened_revoker MediaOpened(auto_revoke_t, RoutedEventHandler const& handler) const;
public event RoutedEventHandler MediaOpened;
function onMediaOpened(eventArgs) { /* Your code */ }
mediaElement.addEventListener("mediaopened", onMediaOpened);
mediaElement.removeEventListener("mediaopened", onMediaOpened);
- or -
mediaElement.onmediaopened = onMediaOpened;
Public Custom Event MediaOpened As RoutedEventHandler
<MediaElement MediaOpened="eventhandler" .../>
Event Type
Examples
The following code shows how to determine if a media stream is a live stream.
private void media_MediaOpened(object sender, RoutedEventArgs e)
{
bool isLive = IsLiveStream(sender as MediaElement);
}
private bool IsLiveStream(MediaElement media)
{
bool isLive = false;
if (media.NaturalDuration.TimeSpan.Ticks == Int64.MaxValue)
{
isLive = true;
}
return isLive;
}
Remarks
Live media streams report a NaturalDuration of Int64.MaxValue.
Any calls to Play, Pause, and Stop methods that occur before the MediaOpened event is raised are ignored.
Applies to
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin