Sign in to follow this  
Followers 0
NegativeNrG

detect length of song?

9 posts in this topic

hi, its me again. i was wondering is it possible to detect length of the currently playing song? i made my own Media Player and i added a progress bar. so i want the progress bar to go with the song.

ok so when i click the browse button and browse for a song, it then plays it, and i want the progress bar to get the length of the song(time) and keeps going up until the song finishes.


[size=20]My File Upload[/size]Register at my site and upload.

Share this post


Link to post
Share on other sites



gafrost has a % progress bar in his signature I believe. I haven't looked at it, but my first guess would be maybe looking at FileGetSize() in the help file.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

i could use, filegetsize($song) where $song = fileopendialog etc..

but i dont know how to make the progress bar get the size( or length(time)) of the *.mp3,*.midi etc. when i open the chosen song.


[size=20]My File Upload[/size]Register at my site and upload.

Share this post


Link to post
Share on other sites

Well...

What I would do, is find a song I know the "length" of, then use FileGetSize() on it, then divide the length by the size to get a percentage to base my "lenght" and "size" %'s off of. Although, I'm answering in an area, I've never even thought of before...


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

thanks larry, i dont know what to add though, too much words, im not that much of an autoit user. maybe you can help me add?

heres the source:

;Created by NegativeNrG

#include <GUIConstants.au3>
#notrayicon
$Form1 = GUICreate("NegativeNrG's Media Player", 307, 197, 236, 222)
$play = GUICtrlCreateButton("Play", 32, 32, 59, 25)
$filemenu = GUictrlcreatemenu ("File")
$Filexit = Guictrlcreatemenuitem ("Exit", $filemenu)
$1filemenu = Guictrlcreatemenu ("?")
$filemenu = Guictrlcreatemenuitem ("About",$1filemenu)
$stop = GUICtrlCreateButton("Stop", 96, 32, 59, 25)
$browse = GUICtrlCreateButton("Browse", 160, 32, 59, 25)
$exit = GUICtrlCreateButton("Exit", 224, 32, 59, 25)
$mute = GUICtrlCreateButton("Mute", 96, 72, 59, 25)
$unmute = GUICtrlCreateButton("Unmute", 160, 72, 59, 25)
$volup = GUICtrlCreateButton("Volume up", 224, 72, 59, 25)
$voldown = GUICtrlCreateButton("Volume Down", 224, 104, 75, 25)
$Button9 = GUICtrlCreateButton("About", 32, 72, 59, 25)
$Label1 = GUICtrlCreateLabel("Made by NegativeNrG, ", 16, 112, 171, 33)
$Progress1 = GUICtrlCreateProgress(8, 152, 286, 17)
GUICtrlSetColor(-1, 0x0D0000)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
Case $msg = $play
Soundplay ($songs)

Case $msg = $mute
Send ("{VOLUME_MUTE}")

Case $msg = $Button9
msgbox (0, "NegativeNrG's Media Player","Created by NegativeNrG.")

Case $msg = $unmute
Send ("{VOLUME_UP}")

Case $msg = $filemenu
msgbox (0, "NegativeNrG's Media Player", " Created by NegativeNrG, More updates coming soon")

Case $msg = $filexit
exit

Case $msg = $volup
send ("{VOLUME_UP}")

Case $msg = $voldown
send ("{VOLUME_DOWN}")


Case $msg = $stop
soundplay("C:\some.mp3")

Case $msg = $browse
$songs = FileOpenDialog ("choose music", "", "musicfiles(*.mp3;*.wma;*.wav;*.wave;*.mid;*)",4)
Soundplay ($songs)

Case $msg = $exit
exit 0
    Case Else
   ;;;;;;;
    EndSelect
WEnd
Exit
Edited by NegativeNrG

[size=20]My File Upload[/size]Register at my site and upload.

Share this post


Link to post
Share on other sites

Looks like it's pretty much set up for you.. just add the directory of where the song is you want to play and replace this like with it:

soundplay("C:\some.mp3")

So if the file I want to play was in my Program Files, in Folder MP3 and the name was MY.mp3 as an example, I would just put the path:

soundplay(@ProgramFilesDir & "\MP3\My.mp3")

On my computer means:

soundplay("C:\Program Files\MP3\My.mp3")


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

look into help file B) . There is GUICtrlCreateProgress() example.

Share this post


Link to post
Share on other sites

noo, what im saying is, can you add the "required" stuff to my code(down the bottom) to make my progress bar go with the song like in this code:

http://www.autoitscript.com/forum/index.php?showtopic=8492

^ his code.

and this is MY code:

;Created by NegativeNrG

#include <GUIConstants.au3>
#notrayicon
$Form1 = GUICreate("NegativeNrG's Media Player", 307, 197, 236, 222)
$play = GUICtrlCreateButton("Play", 32, 32, 59, 25)
$filemenu = GUictrlcreatemenu ("File")
$Filexit = Guictrlcreatemenuitem ("Exit", $filemenu)
$1filemenu = Guictrlcreatemenu ("?")
$filemenu = Guictrlcreatemenuitem ("About",$1filemenu)
$stop = GUICtrlCreateButton("Stop", 96, 32, 59, 25)
$browse = GUICtrlCreateButton("Browse", 160, 32, 59, 25)
$exit = GUICtrlCreateButton("Exit", 224, 32, 59, 25)
$mute = GUICtrlCreateButton("Mute", 96, 72, 59, 25)
$unmute = GUICtrlCreateButton("Unmute", 160, 72, 59, 25)
$volup = GUICtrlCreateButton("Volume up", 224, 72, 59, 25)
$voldown = GUICtrlCreateButton("Volume Down", 224, 104, 75, 25)
$Button9 = GUICtrlCreateButton("About", 32, 72, 59, 25)
$Label1 = GUICtrlCreateLabel("Made by NegativeNrG, ", 16, 112, 171, 33)
$Progress1 = GUICtrlCreateProgress(8, 152, 286, 17)
GUICtrlSetColor(-1, 0x0D0000)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
Case $msg = $play
Soundplay ($songs)

Case $msg = $mute
Send ("{VOLUME_MUTE}")

Case $msg = $Button9
msgbox (0, "NegativeNrG's Media Player","Created by NegativeNrG.")

Case $msg = $unmute
Send ("{VOLUME_UP}")

Case $msg = $filemenu
msgbox (0, "NegativeNrG's Media Player", " Created by NegativeNrG, More updates coming soon")

Case $msg = $filexit
exit

Case $msg = $volup
send ("{VOLUME_UP}")

Case $msg = $voldown
send ("{VOLUME_DOWN}")


Case $msg = $stop
soundplay("C:\some.mp3")

Case $msg = $browse
$songs = FileOpenDialog ("choose music", "", "musicfiles(*.mp3;*.wma;*.wav;*.wave;*.mid;*)",4)
Soundplay ($songs)

Case $msg = $exit
exit 0
    Case Else
  ;;;;;;;
    EndSelect
WEnd
Exit

and once again, can someone add the block of code which is needed to make my progress bar go with the song for me?


[size=20]My File Upload[/size]Register at my site and upload.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0