MP3 seeking with DirectX movie command set

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Naitfreak.

Since u can easily playback MP3's with PB's movie commands I'm woundering if the seeking does also work for MPEG 3 audio and not 'just' for video files. I tried to use the MovieSeek() but it always started playback from the beginning.

Am I doing sumthing wrong or is it simply not working with audio files?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

It wasn't intended for handling audio files, but I could take a look.

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Naitfreak.
It wasn't intended for handling audio files, but I could take a look.
In the help files the MP3 format is also mentioned with the available files that can be played back with the movie commands. I guess it just ment video files that use MP3 compression for the audio sequence, right?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tranquil.

Nop, Its meant to use mp3 audio files for playback. You may take a look on the WinampOutput Codesnip in the Tips and Tricks section. Possible it helpes you.

Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Tron.

There are some issues with these Movie commands. Fred can you please take a look at the MovieStatus() command. I need to be able to loop my MP3's during my program, but I have not been able to get this to work. I've also tried seeking to the beginning with MovieSeek(), but this doesn't seem to work for me either.

I'm looking to play a song in the background continuosly. Perhaps you could create a command called LoopMovie() that will loop the MP3 and movie files.

Does anyone have any working examples using the MovieStatus() to loop an MP3?

Thanks,
Tron

"Honesty is the best policy, but insanity is a much better defense."
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Tron.

Just out of curiosity I converted one of my MP3 files to an AVI file. Now the MovieStatus() command can tell when my file is done and I can play it over. Unfortunately, AVI files are much to large in size to be practical.

If you chould enable MovieStatus() for MP3's Fred that would be great.

"Honesty is the best policy, but insanity is a much better defense."
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Could you try the following code and tell me if it works ?

Code: Select all

InitMovie()

LoadMovie(0, "C:\Ding.mp3")

OpenWindow(0, 0,0,600, 400, #PB_Window_SystemMenu, "Hello")

PlayMovie(0, WindowID())

CreateStatusBar(0, WindowID())
  AddStatusBarField(200)
  
CreateGadgetList(WindowID())
  ButtonGadget(0, 0,0, 100, 25, "Seek 0")
  

Repeat
  Event = WindowEvent()
  
  If Event
    
    If Event = #PB_Event_Gadget
      ;StopMovie()
      MovieSeek(0)
    EndIf
    
  Else
    StatusBarText(0, 0, Str(MovieStatus()))
    Delay(20)
  EndIf
  
Until Event = #PB_Event_CloseWindow
Works fine here with an MP3. The status bar should show 0, when the mp3 is finished.

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Tron.

Fred that works great!! You gave me the inspiration I needed to fix my program. You see I am using MP3's but not on an OpenWindow. I'm using an OpenScreen, but the foundation is the same. So I ported your code to a full 32 bit screen, and it works great!!! For all of you out there banging your head like I was, here is the small code sample. This sample will loop an MP3 in the background endlessly, or until you tell it to stop with the StopMovie() command. Now we have an alternative to Mod files for games. So cool!!!


InitMovie()
InitSprite()
InitKeyboard()

LoadMovie(0, "test.mp3")

OpenScreen(640, 480, 32, "Test")

PlayMovie(0, ScreenID())

Repeat
FlipBuffers()
ClearScreen(0,0,0)
If MovieStatus() = 0
PlayMovie(0, ScreenID())
EndIf
StartDrawing(ScreenOutput())
Locate(10,10)
count.s = Str(MovieStatus())
DrawText(count)
Delay(20)
StopDrawing()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)

Thanks again for your help Fred!!
Tron

"Honesty is the best policy, but insanity is a much better defense."
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

You're welcome :).

Fred - AlphaSND
Post Reply