Jump to content

detect length of song?


Recommended Posts

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.

Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
Share on other sites

  • Moderators

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...

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Moderators

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")

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.

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...