Quantcast
Channel: Visual Basic Tips and Tricks
Viewing all articles
Browse latest Browse all 2212

media player

$
0
0

Ho gia' visto altre risposte su questo forum ma per un motivo non conosciuto il codice nella risposta/e non appare. Sono stato quindi costretto a reiterare la domanda con il seguente codice che funzione una prima volta, ma che nel momento di caricare una ulteriore canzone rimane in modalita "caricamento". Ho provato anche ad inserire un timer :

Private Sub Timer1_Timer()

Dim a As Long

Dim f As String

Dim nn As Integer

' Initialize the random-number generator.

Math.Randomize (99)

' Generate random value between 1 and 99.

nn = CInt(Int((99 * Rnd()) + 1))

f = frmprincipale.directoryMusica & "_mp3\musica"& CStr(nn) & ".mp3"

'WMP1.openPlayer (f)

FormMedia1.WMP1.URL = f

a = FormMedia1.WMP1.currentMedia.duration

Timer1.Interval = a


o altrimenti al cambio di stato del lettore ( avvenuta fine del brano il codice press. uguale:

 

Private Sub WMP1_PlayStateChange(ByVal NewState As Long)

 

If NewState = 8 Then

Dim a As Long

Dim f As String

Dim nn As Integer

' Initialize the random-number generator.

Math.Randomize (99)

' Generate random value between 1 and 99.

nn = CInt(Int((99 * Rnd()) + 1))

f = frmprincipale.directoryMusica & "_mp3\musica"& CStr(nn) & ".mp3"

'WMP1.openPlayer (f)

FormMedia1.WMP1.URL = f

a = FormMedia1.WMP1.currentMedia.duration

Timer1.Interval = a

End If

End Sub



Viewing all articles
Browse latest Browse all 2212