muhmuuh Posted September 14, 2009 Share Posted September 14, 2009 Hello! I'm trying to create my own MP3 player but I found few bugs. expandcollapse popup#include <GUIConstants.au3> #include <Sound.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #NoTrayIcon #Region ### START Koda GUI section ### Global $Form1 = GUICreate("muh's mp3 player", 366, 315, 372, 229) GUISetBkColor(0xA6CAF0) $Button1 = GUICtrlCreateButton("Play", 192, 24, 57, 33, 0) $Button2 = GUICtrlCreateButton("Stop", 296, 24, 57, 33, 0) $Button3 = GUICtrlCreateButton("Player repeat mode", 224, 80, 89, 41, $BS_MULTILINE) $Slider1 = GUICtrlCreateSlider(184, 168, 169, 25) GUICtrlsetBkColor(-1, 0xA6CAF0) GUICtrlSetData(-1, 100) $Label1 = GUICtrlCreateLabel("Volume", 240, 144, 58, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Pic1 = GUICtrlCreatePic(@ScriptDir & "\pic.jpg", 8, 8, 169, 241, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $Label2 = GUICtrlCreateLabel("File selected: ", 8, 264, 387, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $MenuItem3 = GUICtrlCreateMenu("&File") $MenuItem4 = GUICtrlCreateMenuItem("Load file", $MenuItem3) $MenuItem2 = GUICtrlCreateMenu("&Settings") $MenuItem5 = GUICtrlCreateMenuItem("Exit", $MenuItem2) $MenuItem1 = GUICtrlCreateMenu("&Help") $MenuItem6 = GUICtrlCreateMenuItem("About us", $MenuItem1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $snd="" Global $rpd=True; true - repeat song, false - dont repeat Global $poss[21] Global $len="a" SoundSetWaveVolume(100) Global $fp="a" While 1 $nMsg = GUIGetMsg() $pos=_SoundPos($snd, 2) If $pos>0 And $pos==$len Then _SoundStop($snd) If $rpd==True Then _SoundPlay($snd) EndIf EndIf Switch $nMsg Case $GUI_EVENT_CLOSE _SoundClose($snd) Exit Case $MenuItem4 $fp=FileOpenDialog("Music file", @ScriptDir, "MP3 Files (*.mp3)") $snd=_SoundOpen($fp) GUICtrlSetData($Label2, "File selected: " & $fp) Case $Button1 _SoundPlay($snd) $len=_SoundLength($snd, 2) Case $Button2 _SoundStop($snd) Case $Slider1 $vm=GUICtrlRead($Slider1) SoundSetWaveVolume($vm) Case $MenuItem5 _SoundStop($snd) Exit Case $MenuItem6 MsgBox(0, "About us", "This is my first MP3 player yeeeeeey") Case $Button3 $rpd=Not $rpd EndSwitch WEnd I want the player to repeat the song in a loop so I use $pos=_SoundPos($snd, 2) If $pos>0 And $pos==$len Then _SoundStop($snd) If $rpd==True Then _SoundPlay($snd) EndIf EndIf But for some MP3 $pos exceeds $len In that case $len=_SoundLength($snd, 2) $len is much shorter than the length of the song, $pos exceeds it and the song never repeats Also I can play other MP3. The functions don't return error. It successfully opens them, but does not want to play them and it says that the length is 0. What could have caused those problems and how can I fix them? Thank you very much for your time I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more. Link to comment Share on other sites More sharing options...
muhmuuh Posted September 14, 2009 Author Share Posted September 14, 2009 anyone? just a little hint? I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more. Link to comment Share on other sites More sharing options...
BrettF Posted September 15, 2009 Share Posted September 15, 2009 Set it to be greater or equal to... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
muhmuuh Posted September 16, 2009 Author Share Posted September 16, 2009 (edited) Set it to be greater or equal to... that will make it stop before the end of the song. _Soundlength returns a value, corresponding to something about the middle of the song and when $pos is greater than the half of the song the program will stop it. Anyway, I found my own solution Global $poss[21] $pos=_SoundPos($snd, 2) $poss[1]=$poss[2] $poss[2]=$poss[3] $poss[3]=$poss[4] $poss[4]=$poss[5] $poss[5]=$poss[6] $poss[6]=$poss[7] $poss[7]=$poss[8] $poss[8]=$poss[9] $poss[9]=$poss[10] $poss[10]=$poss[11] $poss[11]=$poss[12] $poss[12]=$poss[13] $poss[13]=$poss[14] $poss[14]=$poss[15] $poss[15]=$poss[16] $poss[16]=$poss[17] $poss[17]=$poss[18] $poss[18]=$poss[19] $poss[19]=$poss[20] $poss[20]=$pos $poss[20]=$pos If $pos>0 And $pos==$len Then _SoundStop($snd) _SoundPlay($snd) ElseIf $pos>$len And $poss[1]==$poss[2] And $poss[1]==$poss[3] And $poss[1]==$poss[4] And $poss[1]==$poss[5] And $poss[1]==$poss[6] And $poss[1]==$poss[7] And $poss[1]==$poss[8] And $poss[1]==$poss[9] And $poss[1]==$poss[10] And $poss[1]==$poss[11] And $poss[1]==$poss[12] And $poss[1]==$poss[13] And $poss[1]==$poss[14] And $poss[1]==$poss[15] And $poss[1]==$poss[16] And $poss[1]==$poss[17] And $poss[1]==$poss[18] And $poss[1]==$poss[19] And $poss[1]==$poss[20] Then _SoundStop($snd) _SoundPlay($snd) EndIf p.s. Sorry for my English. I couldn't found a better way to express my thoughts but I think you'll get what I've ment Edited September 16, 2009 by muhmuuh I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now