|
-
Apr 30th, 2013, 06:58 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Audio Duration
Importing an audio file and playing by pressing a button with this:
Code:
My.Computer.Audio.Play(TextBox1.Text)
Can anyone advise on how I can display the duration of the audio in Label 1?
-
Apr 30th, 2013, 09:04 AM
#2
Re: Audio Duration
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
Last edited by dday9; Apr 30th, 2013 at 09:29 AM.
Reason: Corrected the method name, still can't find documentation on it though.
-
Apr 30th, 2013, 09:59 AM
#3
Thread Starter
Addicted Member
Re: Audio Duration
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
-
Apr 30th, 2013, 11:28 AM
#4
Thread Starter
Addicted Member
Re: Audio Duration
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
-
Apr 30th, 2013, 12:05 PM
#5
Re: Audio Duration
lblPlayer1Duration.Text = TimeSpan.FromSeconds(t).ToString.Substring(0, 8)
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Apr 30th, 2013, 12:11 PM
#6
Thread Starter
Addicted Member
Re: Audio Duration
Perfect! Thank you so much for your help!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|