Mp3 Player
Verfasst: 20.12.2005 15:40
wie kann ich dort am besten eine Playlist einfügen???
würde mir bitte jemand helfen den wenn er die Playlist hat dann ist er so wie ich ihn mir vorgestellt hab!!!
Vorstellen würd ich mir das so das wenn ich auf "MP3 Laden" drück das er dann den oder die Titel in die Playlist einfügt oder sie irgendwie reinzieht!!!
Ich bitte um jede hilfe!!!
würde mir bitte jemand helfen den wenn er die Playlist hat dann ist er so wie ich ihn mir vorgestellt hab!!!
Vorstellen würd ich mir das so das wenn ich auf "MP3 Laden" drück das er dann den oder die Titel in die Playlist einfügt oder sie irgendwie reinzieht!!!
Ich bitte um jede hilfe!!!
Code: Alles auswählen
;- MP3 TAGs Structure
Structure ID3v2
Title.s
Artist.s
Album.s
Comment.s
Year.s
Genre.s
Composer.s
URL.s
OrgArtist.s
Copyright.s
EncodedBy.s
Encoder.s
Track.s
EndStructure
Global TagID3v2.ID3v2
Declare.l GetID3v2Tag(FileName.s)
;- MCI-MP3-Commands
Enumeration 0
#MP3_Unknown
#MP3_Stopped
#MP3_Playing
#MP3_Paused
EndEnumeration
Procedure MP3_GetStatus(Nb)
Result=#MP3_Unknown
a$=Space(#MAX_PATH)
i=mciSendString_("status MP3_"+Str(Nb)+" mode",@a$,#MAX_PATH,0)
If i=0
Debug a$
Select a$
Case "stopped":Result=#MP3_Stopped
Case "playing":Result=#MP3_Playing
Case "paused":Result=#MP3_Paused
EndSelect
EndIf
ProcedureReturn Result
EndProcedure
Procedure MP3_Load(Nb,MP3File.s)
;i=mciSendString_("open Sequencer!"+Chr(34)+MP3File+Chr(34)+" alias mid"+Str(Nb),0,0,0)
i=mciSendString_("OPEN "+Chr(34)+MP3File+Chr(34)+" Type MPEGVIDEO ALIAS MP3_"+Str(Nb),0,0,0)
If i=0
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure MP3_Play(Nb)
i=mciSendString_("play MP3_"+Str(Nb),0,0,0)
ProcedureReturn i
EndProcedure
Procedure MP3_PlayStart(Nb)
i=mciSendString_("play MP3_"+Str(Nb)+" from "+Str(0),0,0,0)
ProcedureReturn i
EndProcedure
Procedure MP3_PlayPart(Nb,Start,endPos)
i=mciSendString_("play MP3_"+Str(Nb)+" from "+Str(Start)+" to "+Str(endPos),0,0,0)
ProcedureReturn i
EndProcedure
Procedure MP3_Pause(Nb)
i=mciSendString_("pause MP3_"+Str(Nb),0,0,0)
ProcedureReturn i
EndProcedure
Procedure MP3_Resume(Nb)
i=mciSendString_("resume MP3_"+Str(Nb),0,0,0)
ProcedureReturn i
EndProcedure
Procedure MP3_Stop(Nb)
i=mciSendString_("stop MP3_"+Str(Nb),0,0,0)
ProcedureReturn i
EndProcedure
Procedure MP3_Free(Nb)
i=mciSendString_("close MP3_"+Str(Nb),0,0,0)
ProcedureReturn i
EndProcedure
Procedure MP3_SetVolume(Nb,volume)
i=mciSendString_("SetAudio MP3_"+Str(Nb)+" volume to "+Str(volume),0,0,0)
ProcedureReturn i
EndProcedure
Procedure MP3_GetVolume(Nb)
a$=Space(#MAX_PATH)
i=mciSendString_("status MP3_"+Str(Nb)+" volume",@a$,#MAX_PATH,0)
ProcedureReturn Val(a$)
EndProcedure
Procedure MP3_SetSpeed(Nb,Tempo)
i=mciSendString_("set MP3_"+Str(Nb)+" Speed "+Str(Tempo),0,0,0)
ProcedureReturn i
EndProcedure
Procedure MP3_GetSpeed(Nb)
a$=Space(#MAX_PATH)
i=mciSendString_("status MP3_"+Str(Nb)+" Speed",@a$,#MAX_PATH,0)
ProcedureReturn Val(a$)
EndProcedure
Procedure MP3_GetLength(Nb)
a$=Space(#MAX_PATH)
i=mciSendString_("status MP3_"+Str(Nb)+" length",@a$,#MAX_PATH,0)
ProcedureReturn Val(a$)
EndProcedure
Procedure MP3_GetPosition(Nb)
a$=Space(#MAX_PATH)
i=mciSendString_("status MP3_"+Str(Nb)+" position",@a$,#MAX_PATH,0)
ProcedureReturn Val(a$)
EndProcedure
Procedure MP3_Seek(Nb,pos)
i=mciSendString_("Seek MP3_"+Str(Nb)+" to "+Str(pos),0,0,0)
ProcedureReturn i
EndProcedure
Procedure.s MP3_TimeString(Time)
Time/1000
sek=Time%60:Time/60
min=Time%60:Time/60
EndProcedure
;- Enumeration
Enumeration 1
#gadget_Titel
#gadget_Interpret
#gadget_Album
#gadget_Genre
#gadget_Track
#gadget_Year
#Gadget_VolumeTxt
#Gadget_Volume
#Gadget_SpeedTxt
#Gadget_Speed
#Gadget_PositionTxt
#Gadget_Position
#Gadget_Load
#Gadget_Play
#Gadget_Stop
#Gadget_Pause
#Gadget_Resume
#Gadget_Laden
#Gadget_Spielen
#Gadget_ZeitFG
#Gadget_ZeitTG
#Gadget_ZeitTG2
#Gadget_ZeitTG3
#Gadget_ZeitTG4
#Gadget_ZeitTG5
EndEnumeration
;- Fonts
Global FontID1
FontID1 = LoadFont(1, "Ellis", 12)
Global FontID2
FontID2 = LoadFont(2, "Arial Black", 16)
Global FontID3
FontID3 = LoadFont(3, "Marlett", 28, #PB_Font_Bold)
Global FontID4
FontID4 = LoadFont(4, "Puppylike", 18)
;- Set Vol Speed Position
Procedure SetVol(x)
SetGadgetText(#Gadget_VolumeTxt,"Volume:"+Str(x))
SetGadgetState(#Gadget_Volume,x)
EndProcedure
Procedure SetSpeed(x)
SetGadgetText(#Gadget_SpeedTxt,"Speed:"+Str(x))
SetGadgetState(#Gadget_Speed,x)
EndProcedure
Procedure SetPosition(x,max)
SetGadgetText(#Gadget_PositionTxt,"Position:"+MP3_TimeString(x)+" : "+MP3_TimeString(max))
If max>0
SetGadgetState(#Gadget_Position,x*1000/max)
Else
SetGadgetState(#Gadget_Position,0)
EndIf
EndProcedure
;- Window
If OpenWindow(0, 216, 0, 600, 391, #PB_Window_SystemMenu |#PB_Window_ScreenCentered| #PB_Window_MinimizeGadget, "MP3 Player")
If CreateGadgetList(WindowID())
top=5
TextGadget (#gadget_Titel ,10, 10, 200, 20, " Titel:")
TextGadget (#gadget_Interpret ,10, 30, 200, 20, "Interpret:")
TextGadget (#gadget_Album ,210,10, 200, 20, "Album:")
TextGadget (#gadget_Genre ,210,30, 200, 20, "Genre:")
TextGadget (#gadget_Track ,410,10, 170, 20, "Track:")
TextGadget (#gadget_Year ,410,30, 170, 20, " Jahr:")
TextGadget (#Gadget_VolumeTxt, 10, 70, 140, 20, "Lautstärke :")
TrackBarGadget(#Gadget_Volume ,10, 100, 580, 20,0,100)
TextGadget (#Gadget_SpeedTxt ,10, 130, 140, 20, "Geschwindigkeit :")
TrackBarGadget(#Gadget_Speed ,10, 160, 580, 20,0,200)
TextGadget (#Gadget_PositionTxt,10, 190, 140, 20, "Position :")
TrackBarGadget(#Gadget_Position ,10, 220, 580, 20,0,1000)
ButtonGadget (#Gadget_Load ,20, 270, 170, 50, "MP3 Laden")
SetGadgetFont(#Gadget_Load, FontID1)
ButtonGadget (#Gadget_Play ,210, 270, 100, 50, "I>")
SetGadgetFont(#Gadget_Play, FontID2)
ButtonGadget (#Gadget_Pause ,210, 320, 100, 50, "II")
SetGadgetFont(#Gadget_Pause, FontID2)
ButtonGadget (#Gadget_Resume ,20, 320, 170, 50, "Neu Laden")
SetGadgetFont(#Gadget_Resume, FontID1)
ButtonGadget (#Gadget_Stop ,320, 270, 60, 100, "g")
SetGadgetFont(#Gadget_Stop, FontID3)
Frame3DGadget(#Gadget_Laden, 10, 240, 190, 140, "Laden")
Frame3DGadget(#Gadget_Spielen, 200, 240, 190, 140, "Spielen")
Frame3DGadget(#Gadget_ZeitFG, 390, 240, 200, 140, "Zeit")
TextGadget(#Gadget_ZeitTG, 400, 260, 180, 20, "Aktuelle Zeit: Restzeit:")
TextGadget(#Gadget_ZeitTG2, 400, 320, 180, 20, "Insgesamte Zeit:")
TextGadget(#Gadget_ZeitTG3, 400, 280, 70, 30, "0:00")
SetGadgetFont(#Gadget_ZeitTG3, FontID4)
TextGadget(#Gadget_ZeitTG4, 400, 340, 180, 30, "0:00")
SetGadgetFont(#Gadget_ZeitTG4, FontID4)
TextGadget(#Gadget_ZeitTG5, 500, 280, 80, 30, "-0:00")
SetGadgetFont(#Gadget_ZeitTG5, FontID4)
loaded=#False
Quit=#False
MP3MiPos.l = 0
;- Anfang repeat schleife
Repeat
EventID.l = WindowEvent()
;- Zeitanzeigen
MP3SePosGROSS.l=MP3_GetPosition(1)
MP3SePos.l=MP3SePosGROSS.l/1000
If Mp3MiPos.l = 1
MP3SePos.l=MP3SePos.l-60
ElseIf Mp3MiPos.l = 2
MP3SePos.l=MP3SePos.l-120
ElseIf Mp3MiPos.l = 3
MP3SePos.l=MP3SePos.l-180
ElseIf Mp3MiPos.l = 4
MP3SePos.l=MP3SePos.l-240
ElseIf Mp3MiPos.l = 5
MP3SePos.l=MP3SePos.l-300
ElseIf Mp3MiPos.l = 6
MP3SePos.l=MP3SePos.l-360
ElseIf Mp3MiPos.l = 7
MP3SePos.l=MP3SePos.l-420
ElseIf Mp3MiPos.l = 8
MP3SePos.l=MP3SePos.l-480
ElseIf Mp3MiPos.l = 9
MP3SePos.l=MP3SePos.l-540
ElseIf Mp3MiPos.l = 10
MP3SePos.l=MP3SePos.l-600
ElseIf Mp3MiPos.l = 11
MP3SePos.l=MP3SePos.l-660
ElseIf Mp3MiPos.l = 12
MP3SePos.l=MP3SePos.l-720
ElseIf Mp3MiPos.l = 13
MP3SePos.l=MP3SePos.l-780
EndIf
If MP3SePos.l < 10
MP3SePos$=Str(MP3SePos.l)
MP3SePos$ = "0"+MP3SePos$
MP3MiPos$=Str(MP3MiPos.l)
ElseIf MP3SePos.l > 09
MP3SePos$=Str(MP3SePos.l)
MP3MiPos$=Str(MP3MiPos.l)
EndIf
If MP3SePosGROSS.l > 1
MP3MiPos.l = MP3SePosGROSS.l / 60000
EndIf
MP3MiPos$=Str(MP3MiPos.l)
SetGadgetText(#Gadget_ZeitTG3,MP3MiPos$+":"+MP3SePos$)
MP3SeLenGROSS.l=MP3_GetLength(1)
MP3SeLen.l=MP3SeLenGROSS.l/1000
If Mp3MiLen.l = 1
MP3SeLen.l=MP3SeLen.l-60
ElseIf Mp3MiLen.l = 2
MP3SeLen.l=MP3SeLen.l-120
ElseIf Mp3MiLen.l = 3
MP3SeLen.l=MP3SeLen.l-180
ElseIf Mp3MiLen.l = 4
MP3SeLen.l=MP3SeLen.l-240
ElseIf Mp3MiLen.l = 5
MP3SeLen.l=MP3SeLen.l-300
ElseIf Mp3MiLen.l = 6
MP3SeLen.l=MP3SeLen.l-360
ElseIf Mp3MiLen.l = 7
MP3SeLen.l=MP3SeLen.l-420
ElseIf Mp3MiLen.l = 8
MP3SeLen.l=MP3SeLen.l-480
ElseIf Mp3MiLen.l = 9
MP3SeLen.l=MP3SeLen.l-540
ElseIf Mp3MiLen.l = 10
MP3SeLen.l=MP3SeLen.l-600
ElseIf Mp3MiLen.l = 11
MP3SeLen.l=MP3SeLen.l-660
ElseIf Mp3MiLen.l = 12
MP3SeLen.l=MP3SeLen.l-720
ElseIf Mp3MiLen.l = 13
MP3SeLen.l=MP3SeLen.l-780
EndIf
If MP3SeLen.l < 10
MP3SeLen$=Str(MP3SeLen.l)
MP3SeLen$ = "0"+MP3SeLen$
MP3MiLen$=Str(MP3MiLen.l)
ElseIf MP3SeLen.l > 09
MP3SeLen$=Str(MP3SeLen.l)
MP3MiLen$=Str(MP3MiLen.l)
EndIf
If MP3SeLenGROSS.l > 1
MP3MiLen.l = MP3SeLenGROSS.l / 60000
EndIf
MP3MiLen$=Str(MP3MiLen.l)
SetGadgetText(#Gadget_ZeitTG4,MP3MiLen$+":"+MP3SeLen$)
MP3SePosGROSS.l=MP3_GetPosition(1)
MP3SeLenGROSS.l=MP3_GetLength(1)
MP3SeRukGROSS.l=MP3SeLenGROSS.l-MP3SePosGROSS.l
MP3SeRuk.l=MP3SeRukGROSS.l/1000
If Mp3MiRuk.l = 1
MP3SeRuk.l=MP3SeRuk.l-60
ElseIf Mp3MiRuk.l = 2
MP3SeRuk.l=MP3SeRuk.l-120
ElseIf Mp3MiRuk.l = 3
MP3SeRuk.l=MP3SeRuk.l-180
ElseIf Mp3MiRuk.l = 4
MP3SeRuk.l=MP3SeRuk.l-240
ElseIf Mp3MiRuk.l = 5
MP3SeRuk.l=MP3SeRuk.l-300
ElseIf Mp3MiRuk.l = 6
MP3SeRuk.l=MP3SeRuk.l-360
ElseIf Mp3MiRuk.l = 7
MP3SeRuk.l=MP3SeRuk.l-420
ElseIf Mp3MiRuk.l = 8
MP3SeRuk.l=MP3SeRuk.l-480
ElseIf Mp3MiRuk.l = 9
MP3SeRuk.l=MP3SeRuk.l-540
ElseIf Mp3MiRuk.l = 10
MP3SeRuk.l=MP3SeRuk.l-600
ElseIf Mp3MiRuk.l = 11
MP3SeRuk.l=MP3SeRuk.l-660
ElseIf Mp3MiRuk.l = 12
MP3SeRuk.l=MP3SeRuk.l-720
ElseIf Mp3MiRuk.l = 13
MP3SeRuk.l=MP3SeRuk.l-780
EndIf
If MP3SeRuk.l < 10
MP3SeRuk$=Str(MP3SeRuk.l)
MP3SeRuk$ = "0"+MP3SeRuk$
MP3MiRuk$=Str(MP3MiRuk.l)
ElseIf MP3SeRuk.l > 09
MP3SeRuk$=Str(MP3SeRuk.l)
MP3MiRuk$=Str(MP3MiRuk.l)
EndIf
If MP3SeRukGROSS.l > 1
MP3MiRuk.l = MP3SeRukGROSS.l / 60000
EndIf
MP3MiRuk$=Str(MP3MiRuk.l)
SetGadgetText(#Gadget_ZeitTG5,MP3MiRuk$+":"+MP3SeRuk$)
;- Other
Select EventID
Case 0
If loaded And max>0
x=MP3_GetPosition(1)
If GetGadgetState(#Gadget_Position)<>x*1000/max
SetPosition(x,max)
EndIf
EndIf
Delay(100)
Case #PB_Event_CloseWindow ; If the user has pressed on the close button
Quit=#True
Case #PB_Event_Gadget
Select EventGadgetID()
Case #Gadget_Load
MP3File.s = OpenFileRequester("Select MP3 File", "", "MP3 Files (*.mp3)|*.mp3", 0)
If GetID3v2Tag(mp3file)
; display tag contents
SetGadgetText(#Gadget_Album, "Album: "+TagID3v2\Album)
SetGadgetText(#Gadget_Interpret, "Interpret: "+TagID3v2\Artist)
SetGadgetText(#Gadget_Genre, "Genre: "+TagID3v2\Genre)
SetGadgetText(#Gadget_Titel, " Titel: "+TagID3v2\Title)
SetGadgetText(#Gadget_Track, "Track: "+TagID3v2\Track)
SetGadgetText(#Gadget_Year, " Jahr: "+TagID3v2\Year)
EndIf
Mp3File$ = Mp3file.s
If MP3File$<>""
If loaded
MP3_Free(1)
loaded=#False
EndIf
If MP3_Load(1,MP3File$)
max=MP3_GetLength(1)
SetVol(MP3_GetVolume(1)/10)
SetSpeed(MP3_GetSpeed(1)/10)
SetPosition(0,max)
loaded=#True
; SetGadgetText(#gadget_File,"File:"+File$)
Else
; SetGadgetText(#gadget_File,"File")
EndIf
EndIf
Case #Gadget_Resume
If loaded
MP3_Resume(1)
EndIf
Case #Gadget_Pause
If loaded
MP3_Pause(1)
EndIf
Case #Gadget_Play
If loaded
MP3_Play(1)
EndIf
Case #Gadget_Stop
If loaded
MP3_Stop(1)
EndIf
Case #Gadget_Position
If loaded And max>0
x=GetGadgetState(#Gadget_Position)*max/1000
SetPosition(x,max)
MP3_Seek(1,x)
MP3_Resume(1)
EndIf
Case #Gadget_Volume
If loaded
x=GetGadgetState(#Gadget_Volume)
SetVol(x)
MP3_SetVolume(1,x*10)
EndIf
Case #Gadget_Speed
If loaded
x=GetGadgetState(#Gadget_Speed)
SetSpeed(x)
MP3_SetSpeed(1,x*10)
EndIf
EndSelect
EndSelect
Until Quit
If loaded
MP3_Stop(1)
MP3_Free(1)
EndIf
EndIf
EndIf
End
;- Procedure Tags
;- read ID3v2.3.x tag fields from MP3 file
Procedure.l GetID3v2Tag(FileName.s)
If FileName = ""
ProcedureReturn #False
EndIf
ReadFile(1, FileName)
ID3.s = Space(3)
ReadData(@ID3, 3)
; must be ID3v2.3.x
If ID3 = "ID3" And ReadByte() = $03
ID3Exists = #True
; skip revision and flag bytes
ReadWord()
; get tag size
ID3Size.l = 0
For Byte.l = 3 To 0 Step -1
ID3Size + (ReadByte() << (7*Byte))
Next
Else
; no ID3v2.3.x tag present
CloseFile(1)
ProcedureReturn #False
EndIf
; clear tag contents
TagID3v2\Album = ""
TagID3v2\Artist = ""
TagID3v2\Comment = ""
TagID3v2\Composer = ""
TagID3v2\Copyright = ""
TagID3v2\EncodedBy = ""
TagID3v2\Encoder = ""
TagID3v2\Genre = ""
TagID3v2\OrgArtist = ""
TagID3v2\Title = ""
TagID3v2\Track = ""
TagID3v2\URL = ""
TagID3v2\Year = ""
Size.l = 0
Repeat
; get frames until no more
FrameID.s = Space(4)
ReadData(@FrameID, 4)
If Asc(Left(FrameID, 1)) = 0
; no more frames
CloseFile(1)
ProcedureReturn #True
EndIf
; get frame size
FrameSize.l = 0
For Byte.l = 3 To 0 Step -1
FrameSize + (ReadByte() << (7*Byte))
Next
; add frame size to total size
Size + FrameSize
; skip flag and language bytes
ReadWord()
ReadByte()
; get frame contents
; subtract one for language byte
FrameSize - 1
Contents.s = Space(FrameSize)
ReadData(@Contents, FrameSize)
; put frame contents into structure
Select FrameID
Case "TALB"
TagID3v2\Album = Contents
Case "TCOM"
TagID3v2\Composer = Contents
Case "TCON"
TagID3v2\Genre = Contents
Case "TCOP"
TagID3v2\Copyright = Contents
Case "TENC"
TagID3v2\EncodedBy = Contents
Case "TIT2"
TagID3v2\Title = Contents
Case "TOPE"
TagID3v2\OrgArtist = Contents
Case "TPE1"
TagID3v2\Artist = Contents
Case "TRCK"
TagID3v2\Track = Contents
Case "TSSE"
TagID3v2\Encoder = Contents
Case "TYER"
TagID3v2\Year = Contents
Case "COMM"
TagID3v2\Comment = Contents
Case "WXXX"
TagID3v2\URL = Contents
EndSelect
; stop if tag size reached/exceeded
Until Size >= ID3Size
CloseFile(1)
ProcedureReturn #True
EndProcedure