probleme de sons pour un lecteur movie!!!!
pareil
j'ai trouver un code qui marche je le donne pour ce qui en auront besoin.
Le premier corespond au code pour la progression et le deuxieme au programe ou je l'ai trouver.Maintenant il me reste à l'adapter au mien.
Le premier corespond au code pour la progression et le deuxieme au programe ou je l'ai trouver.Maintenant il me reste à l'adapter au mien.
Code : Tout sélectionner
Procedure MP3_Load(Nb,file.s)
i=mciSendString_("OPEN "+Chr(34)+file+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_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
;Example
Enumeration 1
#gadget_File
#Gadget_PositionTxt
#Gadget_Position
#Gadget_Load
#Gadget_Play
EndEnumeration
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
If OpenWindow(0, 100, 200, 310,310, #PB_Window_SystemMenu |#PB_Window_ScreenCentered, "Simple MP3-Player")
If CreateGadgetList(WindowID())
top=5
TextGadget (#gadget_File ,5,top,300,20,"File:"):top+25
TextGadget (#Gadget_PositionTxt,5,top,300,20,"Position"):top+20
TrackBarGadget(#Gadget_Position ,5,top,300,25,0,1000):top+30
ButtonGadget (#Gadget_Load ,5,top,300,20,"Load"):top+25
ButtonGadget (#Gadget_Play ,5,top,300,20,"Play"):top+25
loaded=#False
Quit=#False
Repeat
EventID.l = WindowEvent()
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
File$=OpenFileRequester("","","Media (Wave,MP3,OGG)|*.wav;*.ogg;*.mp3|Wave|*.wav|mp3|*.mp3|OGG|*.OGG|ALL|*.*",0)
If File$<>""
If loaded
loaded=#False
EndIf
If MP3_Load(1,File$)
max=MP3_GetLength(1)
SetPosition(0,max)
loaded=#True
SetGadgetText(#gadget_File,"File:"+File$)
Else
SetGadgetText(#gadget_File,"File")
EndIf
EndIf
Case #Gadget_Play
If loaded
MP3_Play(1)
EndIf
Case #Gadget_Position
If loaded And max>0
x=GetGadgetState(#Gadget_Position)*max/1000
SetPosition(x,max)
MP3_Seek(1,x)
EndIf
EndSelect
EndSelect
Until Quit
EndIf
EndIf
End
Code : Tout sélectionner
; German forum: http://robsite.de/php/pureboard/viewtopic.php?t=2786&highlight=
; Author: GPI
; Date: 09. November 2003
;Info: 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,file.s)
;i=mciSendString_("open Sequencer!"+Chr(34)+file+Chr(34)+" alias mid"+Str(Nb),0,0,0)
i=mciSendString_("OPEN "+Chr(34)+file+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
;Example
Enumeration 1
#gadget_File
#Gadget_VolumeTxt
#Gadget_Volume
#Gadget_SpeedTxt
#Gadget_Speed
#Gadget_PositionTxt
#Gadget_Position
#Gadget_Load
#Gadget_Play
#Gadget_Stop
#Gadget_Pause
#Gadget_Resume
EndEnumeration
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
If OpenWindow(0, 100, 200, 310,310, #PB_Window_SystemMenu |#PB_Window_ScreenCentered, "Simple MP3-Player")
If CreateGadgetList(WindowID())
top=5
TextGadget (#gadget_File ,5,top,300,20,"File:"):top+25
TextGadget (#Gadget_VolumeTxt, 5,top,300,20,"Volume"):top+20
TrackBarGadget(#Gadget_Volume ,5,top,300,25,0,100):top+30
TextGadget (#Gadget_SpeedTxt ,5,top,300,20,"Speed"):top+20
TrackBarGadget(#Gadget_Speed ,5,top,300,25,0,200):top+30
TextGadget (#Gadget_PositionTxt,5,top,300,20,"Position"):top+20
TrackBarGadget(#Gadget_Position ,5,top,300,25,0,1000):top+30
ButtonGadget (#Gadget_Load ,5,top,300,20,"Load"):top+25
ButtonGadget (#Gadget_Play ,5,top,300,20,"Play"):top+25
ButtonGadget (#Gadget_Pause ,5,top,300,20,"Pause"):top+25
ButtonGadget (#Gadget_Resume ,5,top,300,20,"Resume"):top+25
ButtonGadget (#Gadget_Stop ,5,top,300,20,"Stop"):top+25
loaded=#False
Quit=#False
Repeat
EventID.l = WindowEvent()
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
File$=OpenFileRequester("","","Media (Wave,MP3,OGG)|*.wav;*.ogg;*.mp3|Wave|*.wav|mp3|*.mp3|OGG|*.OGG|ALL|*.*",0)
If File$<>""
If loaded
MP3_Free(1)
loaded=#False
EndIf
If MP3_Load(1,File$)
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
; ExecutableFormat=Windows
; EnableXP
; EOF
C'est pas qu'on veuille pas vous aider, mais il faudrait qu'on sache sur quoi, exactement, vous êtes bloqués.
Les deux codes que vous avez postés fonctionnent, donc, on a rien à dire dessus. C'est logique!
Par contre, si vous mettez un bout de code en disant "Voilà. On est bloqué à tel endroit, Comment faire pour faire tel ou tel truc", là on peut vous aider!
On est pas derrière vos ordinateurs, donc, on ne voit pas vos codes et on ne peut pas savoir à quel endroit vous avez un problème!
Vous n'êtes pas obligé de mettre tout votre code!
Vous pouvez poster juste un petit code d'exemple avec uniquement la fonction qui vous manque, et là, on pourra (peut-être) vous aider.
Chris

Les deux codes que vous avez postés fonctionnent, donc, on a rien à dire dessus. C'est logique!
Par contre, si vous mettez un bout de code en disant "Voilà. On est bloqué à tel endroit, Comment faire pour faire tel ou tel truc", là on peut vous aider!
On est pas derrière vos ordinateurs, donc, on ne voit pas vos codes et on ne peut pas savoir à quel endroit vous avez un problème!
Vous n'êtes pas obligé de mettre tout votre code!
Vous pouvez poster juste un petit code d'exemple avec uniquement la fonction qui vous manque, et là, on pourra (peut-être) vous aider.
Chris

bah je vais vous donnez la partie du prog
voici le programe on arrive pas a adapter le "gadget_progresion" avec la progression de la muzik
j'espere que vous trouverez
merci d'avance
Code : Tout sélectionner
; PureBasic Visual Designer v3.80 build 1249
; PureBasic Visual Designer v3.80 build 1249
;- Window Constants
;
Enumeration
#Window_principal
#Window_apropos
EndEnumeration
;- MenuBar Constants
;
Enumeration
#MenuBar_0
EndEnumeration
Enumeration
#MENU_ouvrir
#MENU_fermer
#MENU_option
#MENU_aide
#MENU_propos
EndEnumeration
;- Gadget Constants
;
Enumeration
#Gadget_Commande
#Gadget_ouvrir
#Gadget_arret
#Gadget_lire
#Gadget_pause
#Gadget_progresion
#Gadget_volume
#Gadget_7
#Gadget_8
#Gadget_9
#Gadget_10
#Gadget_11
EndEnumeration
Dim Language$(21)
; BalloonTip Constants
#TOOLTIP_NO_ICON = 0
#TOOLTIP_INFO_ICON = 1
#TOOLTIP_WARNING_ICON = 2
#TOOLTIP_ERROR_ICON = 3
Procedure BalloonTip(WindowID, Gadget, Text$ , Title$, Icon)
ToolTip=CreateWindowEx_(0,"ToolTips_Class32","",#WS_POPUP | #TTS_NOPREFIX | #TTS_BALLOON,0,0,0,0,WindowID(WindowID),0,GetModuleHandle_(0),0)
SendMessage_(ToolTip,#TTM_SETTIPTEXTCOLOR,GetSysColor_(#COLOR_INFOTEXT),0)
SendMessage_(ToolTip,#TTM_SETTIPBKCOLOR,GetSysColor_(#COLOR_INFOBK),0)
SendMessage_(ToolTip,#TTM_SETMAXTIPWIDTH,0,180)
Balloon.TOOLINFO\cbSize=SizeOf(TOOLINFO)
Balloon\uFlags=#TTF_IDISHWND | #TTF_SUBCLASS
Balloon\hWnd=GadgetID(Gadget)
Balloon\uId=GadgetID(Gadget)
Balloon\lpszText=@Text$
SendMessage_(ToolTip, #TTM_ADDTOOL, 0, Balloon)
If Title$ > ""
SendMessage_(ToolTip, #TTM_SETTITLE, Icon, @Title$)
EndIf
EndProcedure
Procedure Open_Window_principal()
If OpenWindow(#Window_principal, 0, 46, 342, 136, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_WindowCentered , "Audio Pocket")
If CreateMenu(#MenuBar_0, WindowID())
MenuTitle(Language$(0))
MenuItem(#MENU_ouvrir, Language$(1))
MenuBar()
MenuItem(#MENU_fermer, Language$(2))
MenuTitle(Language$(3))
MenuItem(#MENU_option, Language$(4))
MenuTitle(Language$(5))
MenuItem(#MENU_aide, Language$(6))
MenuBar()
MenuItem(#MENU_propos, Language$(7))
EndIf
If CreateGadgetList(WindowID())
Frame3DGadget(#Gadget_Commande, 10, 10, 320, 50, Language$(8))
ButtonGadget(#Gadget_ouvrir, 20, 30, 60, 20, Language$(9))
BalloonTip(WindowID(), #Gadget_ouvrir, Language$(10), "", #TOOLTIP_NO_ICON)
ButtonGadget(#Gadget_arret, 260, 30, 60, 20, Language$(11))
BalloonTip(WindowID(), #Gadget_arret, Language$(12), "", #TOOLTIP_NO_ICON)
ButtonGadget(#Gadget_lire, 100, 30, 60, 20, Language$(13))
BalloonTip(WindowID(), #Gadget_lire, Language$(14), "", #TOOLTIP_NO_ICON)
ButtonGadget(#Gadget_pause, 180, 30, 60, 20, Language$(15))
BalloonTip(WindowID(), #Gadget_pause, Language$(16), "", #TOOLTIP_NO_ICON)
TrackBarGadget(#Gadget_progresion, 20, 70, 300, 20, 0, 100)
TrackBarGadget(#Gadget_volume, 50, 90, 240, 20, 0, 100)
SetGadgetState(#Gadget_volume, 50)
EndIf
EndIf
EndProcedure
Procedure Open_Window_apropos()
If OpenWindow(#Window_apropos , 311, 251, 200, 240, #PB_Window_WindowCentered , "A propos")
If CreateGadgetList(WindowID())
ButtonGadget(#Gadget_7, 70, 210, 50, 20, Language$(17))
HyperLinkGadget(#Gadget_8, 50, 180, 90, 20, Language$(18), RGB(0, 0, 0))
TextGadget(#Gadget_9, 170, 10, 20, 20, Language$(19), #PB_Text_Center)
TextGadget(#Gadget_10, 10, 50, 180, 30, Language$(20), #PB_Text_Center)
TextGadget(#Gadget_11, 10, 110, 180, 30, Language$(21), #PB_Text_Center)
EndIf
EndIf
EndProcedure
Procedure ReadCatalog(Filename$)
If ReadFile(0, Filename$)
If ReadString() = "Catalog"
For k=0 To 21
Language$(k) = ReadString()
Next
EndIf
CloseFile(0)
EndIf
EndProcedure
Restore BaseLanguage
For k=0 To 21
Read Language$(k)
Next
DataSection
BaseLanguage:
Data$ "Fichier"
Data$ "Ouvrir"
Data$ "Fermer"
Data$ "Outils"
Data$ "Options"
Data$ "?"
Data$ "Rubrique d'aide"
Data$ "A propos"
Data$ "Commande"
Data$ "Ouvrir"
Data$ "Ouvrir le media"
Data$ "Arrêt"
Data$ "Arreter le media"
Data$ "Lire"
Data$ "lire le media"
Data$ "Pause"
Data$ "Mettre en pause"
Data$ "OK"
Data$ "www.teamXS.com"
Data$ "XS"
Data$ "Nous vous remercions d'avoir telecharger notre programme"
Data$ "Ce logiciel est un creation des programmeur de la team XS"
EndDataSection
Open_Window_principal()
If InitMovie() = 0
MessageRequester("Erreur", "Impossible d'initialiser !", 0)
EndIf
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventMenu
MenuID = EventMenuID()
If MenuID = #MENU_ouvrir
Audio$ = OpenFileRequester("Ouvrir", "", "Fichier Audio|*.wma;*.mp3;*.wav", 0)
If Audio$
If LoadMovie(0, Audio$)
MovieLoaded = 1
MovieState = 0
PlayMovie(0, WindowID())
EndIf
EndIf
EndIf
ElseIf MenuID = #MENU_fermer
If MenuID = #MENU_fermer
End
EndIf
ElseIf MenuID = #MENU_option
Debug "GadgetID: #MENU_option"
ElseIf MenuID = #MENU_aide
Debug "GadgetID: #MENU_aide"
ElseIf MenuID = #MENU_propos
Open_Window_apropos ()
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventGadget
GadgetID = EventGadgetID()
If GadgetID = #Gadget_7
CloseWindow (#Window_apropos)
ElseIf GadgetID = #Gadget_8
EndIf
EndIf
Until Event = #PB_EventCloseWindow
EndIf
If Event = #PB_EventGadget
GadgetID = EventGadgetID()
EventID.l = WindowEvent()
If GadgetID = #Gadget_ouvrir
Audio$ = OpenFileRequester("Ouvrir", "", "Fichier Audio|*.wma;*.mp3;*.wav", 0)
If Audio$
If LoadMovie(0, Audio$)
MovieLoaded = 1
MovieState = 0
PlayMovie(0, WindowID())
EndIf
EndIf
EndIf
ElseIf GadgetID = #Gadget_arret
If MovieLoaded And MovieState = 0
StopMovie()
MovieState = 2 ; Stopper
EndIf
ElseIf GadgetID = #Gadget_lire
If MovieLoaded And MovieState = 1
ResumeMovie()
MovieState = 0
EndIf
If MovieLoaded And MovieState = 2
PlayMovie(0,WindowID())
MovieState = 1 ; Pause
EndIf
ElseIf GadgetID = #Gadget_pause
If MovieLoaded And MovieState = 0
PauseMovie()
MovieState = 1 ; Pause
EndIf
ElseIf GadgetID = #Gadget_progresion
ElseIf GadgetID = #Gadget_volume
MovieAudio(GetGadgetState(#Gadget_volume), 0)
EndIf
Until Event = #PB_EventCloseWindow
End
j'espere que vous trouverez
merci d'avance