mci status

Just starting out? Need help? Post your questions and find answers here.
khalidel
User
User
Posts: 17
Joined: Sat Mar 23, 2019 7:45 pm

mci status

Post by khalidel »

hello friends, please can someone debug this piece of code

Code: Select all

If file
IF mci("status "+file) = mci_mode_play
mci("pause "+file)
elseif mci("status "+file) = mci_mode_pause
mci("resume "+file)
endif
endif
i don't know how to combine mci_status_mode with the constant mci_mode_play or pause to work on purebasic. thank you in advance
infratec
Always Here
Always Here
Posts: 6867
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: mci status

Post by infratec »

Sorry, no.

Because this code is not working.
So what should I debug :?:
khalidel
User
User
Posts: 17
Joined: Sat Mar 23, 2019 7:45 pm

Re: mci status

Post by khalidel »

infratec wrote:Sorry, no.

Because this code is not working.
So what should I debug :?:
hello, to debug means make it work using mci_status_mode and mci_mode_play or pause using the correct pb code. i found examples in other programming languages but not in pb. the aim is to pause a sound when it's played and resume it when it's suspended. this piece of code is related to a menuitem action.
User avatar
the.weavster
Addict
Addict
Posts: 1537
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: mci status

Post by the.weavster »

PureBasic doesn't have a command named mci.
infratec
Always Here
Always Here
Posts: 6867
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: mci status

Post by infratec »

So you mean not debug,
you mean:

Show me a working example code which makes use of the status mciSendString_() parameter.

Is this correct?

You know that this will never work with the Demo version of PB?
khalidel
User
User
Posts: 17
Joined: Sat Mar 23, 2019 7:45 pm

Re: mci status

Post by khalidel »

infratec wrote:So you mean not debug,
you mean:

Show me a working example code which makes use of the status mciSendString_() parameter.

Is this correct?

You know that this will never work with the Demo version of PB?
debug is to correct wrong code of a program. yes, i know that. am not on demo. i want to know the correct code of using mci-status-mode. i tried to adapt other languages examples to pb but no result till now.
infratec
Always Here
Always Here
Posts: 6867
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: mci status

Post by infratec »

Hi,

a fast coded test:

Code: Select all

#Filename$ = "c:\tmp\bkk.wav"



mciSendString_("close MediaFile", #Null, 0, #Null)


error = mciSendString_("open " + #DQUOTE$ + #FileName$ + #DQUOTE$ + " alias MediaFile", #Null, 0, #Null)
If error = 0
  
  error = mciSendString_("play MediaFile", #Null, 0, #Null)
  If error = 0
    Delay(1000)
    
    *Buffer = AllocateMemory(1024)
    error = mciSendString_("status MediaFile mode" , *Buffer, 512, #Null)
    Debug PeekS(*Buffer)
    FreeMemory(*Buffer)
    
    Delay(2000)
    
    error = mciSendString_("pause MediaFile", #Null, 0, #Null)
    
    *Buffer = AllocateMemory(1024)
    error = mciSendString_("status MediaFile mode" , *Buffer, 512, #Null)
    Debug PeekS(*Buffer)
    FreeMemory(*Buffer)
    
    Delay(1000)
    
    error = mciSendString_("resume MediaFile", #Null, 0, #Null)
    
    *Buffer = AllocateMemory(1024)
    error = mciSendString_("status MediaFile mode" , *Buffer, 512, #Null)
    Debug PeekS(*Buffer)
    FreeMemory(*Buffer)
    
    Delay(3000)
    
    error = mciSendString_("stop MediaFile", #Null, 0, #Null)
    
    *Buffer = AllocateMemory(1024)
    error = mciSendString_("status MediaFile mode" , *Buffer, 512, #Null)
    Debug PeekS(*Buffer)
    FreeMemory(*Buffer)
    
    mciSendString_("close MediaFile", #Null, 0, #Null)
    
  Else
    *Buffer = AllocateMemory(1024)
    mciGetErrorString_(error, *Buffer, 512)
    Debug PeekS(*Buffer)
    FreeMemory(*Buffer)
  EndIf
Else
  
  *Buffer = AllocateMemory(1024)
    mciGetErrorString_(error, *Buffer, 512)
    Debug PeekS(*Buffer)
    FreeMemory(*Buffer)
  
EndIf
Of course you have to use an other filename :wink:
And it should be longer then 8 seconds.
khalidel
User
User
Posts: 17
Joined: Sat Mar 23, 2019 7:45 pm

Re: mci status

Post by khalidel »

infratec wrote:Hi,

a fast coded test:

Code: Select all

#Filename$ = "c:\tmp\bkk.wav"



mciSendString_("close MediaFile", #Null, 0, #Null)


error = mciSendString_("open " + #DQUOTE$ + #FileName$ + #DQUOTE$ + " alias MediaFile", #Null, 0, #Null)
If error = 0
  
  error = mciSendString_("play MediaFile", #Null, 0, #Null)
  If error = 0
    Delay(1000)
    
    *Buffer = AllocateMemory(1024)
    error = mciSendString_("status MediaFile mode" , *Buffer, 512, #Null)
    Debug PeekS(*Buffer)
    FreeMemory(*Buffer)
    
    Delay(2000)
    
    error = mciSendString_("pause MediaFile", #Null, 0, #Null)
    
    *Buffer = AllocateMemory(1024)
    error = mciSendString_("status MediaFile mode" , *Buffer, 512, #Null)
    Debug PeekS(*Buffer)
    FreeMemory(*Buffer)
    
    Delay(1000)
    
    error = mciSendString_("resume MediaFile", #Null, 0, #Null)
    
    *Buffer = AllocateMemory(1024)
    error = mciSendString_("status MediaFile mode" , *Buffer, 512, #Null)
    Debug PeekS(*Buffer)
    FreeMemory(*Buffer)
    
    Delay(3000)
    
    error = mciSendString_("stop MediaFile", #Null, 0, #Null)
    
    *Buffer = AllocateMemory(1024)
    error = mciSendString_("status MediaFile mode" , *Buffer, 512, #Null)
    Debug PeekS(*Buffer)
    FreeMemory(*Buffer)
    
    mciSendString_("close MediaFile", #Null, 0, #Null)
    
  Else
    *Buffer = AllocateMemory(1024)
    mciGetErrorString_(error, *Buffer, 512)
    Debug PeekS(*Buffer)
    FreeMemory(*Buffer)
  EndIf
Else
  
  *Buffer = AllocateMemory(1024)
    mciGetErrorString_(error, *Buffer, 512)
    Debug PeekS(*Buffer)
    FreeMemory(*Buffer)
  
EndIf
Of course you have to use an other filename :wink:
And it should be longer then 8 seconds.
ok i'll test it asap
Post Reply