Share via


Proprietà IWMPMedia::d urationString

[La funzionalità associata a questa pagina, Lettore multimediale Windows SDK, è una funzionalità legacy. È stato sostituito da MediaPlayer. MediaPlayer è stato ottimizzato per Windows 10 e Windows 11. Microsoft consiglia vivamente che il nuovo codice usi MediaPlayer invece di Lettore multimediale Windows SDK, quando possibile. Microsoft suggerisce che il codice esistente che usa le API legacy venga riscritto per usare le nuove API, se possibile.

La proprietà durationString ottiene una stringa che indica la durata dell'elemento multimediale corrente in formato HH:MM:SS.

Questa proprietà è di sola lettura.

Sintassi

public System.String durationString {get;}

Public ReadOnly Property durationString As System.String

Valore proprietà

Valore System.String che rappresenta la durata.

Commenti

Se questa proprietà viene usata con un elemento multimediale diverso da quello specificato in AxWindowsMediaPlayer.currentMedia, potrebbe non contenere un valore valido. Se l'elemento multimediale è inferiore a un'ora, la parte relativa alle ore del valore restituito viene omessa.

Prima di usare questa proprietà, è necessario disporre dell'accesso in lettura alla libreria. Per altre informazioni, vedere Accesso alla libreria.

Esempio

Nell'esempio seguente viene utilizzato durationString per visualizzare la durata dell'elemento multimediale corrente come testo formattato in un'etichetta. L'oggetto AxWMPLib.AxWindowsMediaPlayer è rappresentato dalla variabile denominata player.

// Create an event handler for the OpenStateChange event.
private void player_OpenStateChange(object sender, AxWMPLib._WMPOCXEvents_OpenStateChangeEvent e)
{
    // Test whether the current media item is open.
    if (e.newState == (int)WMPLib.WMPOpenState.wmposMediaOpen)
    {
         // Display the formatted duration string in the label.
         mediaDuration.Text = player.currentMedia.durationString;
    }
}

' Create an event handler for the OpenStateChange event.
Public Sub player_OpenStateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_OpenStateChangeEvent) Handles player.OpenStateChange

    ' Test whether the current media item is open.
    If (e.newState = 13) Then

        ' Display the formatted duration string in the label.
        mediaDuration.Text = player.currentMedia.durationString

    End If

End Sub

Requisiti

Requisito Valore
Versione
Lettore multimediale Windows serie 9 o successive
Spazio dei nomi
WMPLib
Assembly
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

Vedi anche

AxWindowsMediaPlayer.currentMedia (VB e C#)

Interfaccia IWMPMedia (VB e C#)

IWMPMedia.duration (VB e C#)