Importing an audio file and playing by pressing a button with this:
Can anyone advise on how I can display the duration of the audio in Label 1?Code:My.Computer.Audio.Play(TextBox1.Text)
Printable View
Importing an audio file and playing by pressing a button with this:
Can anyone advise on how I can display the duration of the audio in Label 1?Code:My.Computer.Audio.Play(TextBox1.Text)
You're not able to do anything else, other than determine how/when the audio should stop using My.Computer.Audio.Play. The other method I know of is to use the active x windows media player and use the .CurrentMedia.DurationString to get the length of the current audio being played:
Code:Label1.Text = AxWindowsMediaPlayer1.currentMedia.durationString
Thanks dday! i was concerned that using windows media player stuff might prove to be tricky/annoying. actually, having played with it after your recommendation, it seems fairly flexible.
thanks
Hi...
Using the following code to display in my label (lblPlayer1Duration) how long of the current audio is left.
At the moment, it's displaying in seconds. eg if something is 3minutes and 10seconds long, it displays as 190. How can I format the label so it is
0:03:10
and counts down from there?
Code:Private Sub timerPlayerOneRemaining_Tick(sender As System.Object, e As System.EventArgs) Handles timerPlayerOneRemaining.Tick
Dim t As Double = Math.Floor(wmpPlayer1.currentMedia.duration - wmpPlayer1.Ctlcontrols.currentPosition)
' Display the time remaining in the current media.
lblPlayer1Duration.Text = t.ToString()
End Sub
lblPlayer1Duration.Text = TimeSpan.FromSeconds(t).ToString.Substring(0, 8)
Perfect! Thank you so much for your help!