Share via


MediaElement.MediaOpened Evento

Definição

Ocorre quando o fluxo de mídia foi validado e aberto e os cabeçalhos de arquivo foram lidos.

// 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" .../>

Tipo de evento

Exemplos

O código a seguir mostra como determinar se uma transmissão de mídia é uma transmissão ao vivo.

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;
}

Comentários

Transmissões de mídia ao vivo relatam uma NaturalDuration de Int64.MaxValue.

Todas as chamadas para os métodos Reproduzir, Pausar e Parar que ocorrem antes do evento MediaOpened ser acionado são ignoradas.

Aplica-se a