Playmusic with mp3

Blitz3D Forums/Blitz3D Programming/Playmusic with mp3

_PJ_(Posted 2003) [#1]
I have noticed a strange quirk.

I have tested the following, and I still don't understand why. The online help doc's state that Playmusic will play .mp3 files however:


PlayMusic ("My Sound.mp3")



does NOT play, unlike:


Music=LoadSound ("My Sound.mp3")

PlaySound Music



Any suggestions?


(edit to add: I use Blitz v1.83)


GfK(Posted 2003) [#2]
Channel = PlayMusic("my sound.mp3")



Sir Gak(Posted 2003) [#3]
The Blitz help points out that you MUST use a variable:
PlayMusic (filename$)
Definition
Loads and begins playing a piece of music.  

Parameters
filename$ - name of music file. Formats supported: raw/mod/s3m/xm/it/mid/rmi/wav/mp2/mp3/ogg/wma/asf  

Description
This command will load and play a music file. 

You MUST use a channel variable in order to stop or adjust the music playing. You may use StopChannel, PauseChannel, ResumeChannel, etc. with this command. 

You can't 'preload' the audio like you can a sound sample via the LoadSound command. Every time you call the PlayMusic command, the file is reloaded and played. This means that if you use the command while some graphics are moving on-screen, you may get a slight pause when the hard drive seeks and grabs the music file. To avoid this, you might want to use the PlaySound/LoopSound commands instead.  

Example
; Load and play the background music 

chnBackground=PlayMusic("musicackground.wav") 



Tricky(Posted 2003) [#4]
Variable or not doesn't matter...

I encountered the same problem...

Local Music = PlayMusic("Music.mp3")


According to the manual you should have music with that, but not one single thing happens (To me it didn't at least)....

The line in the top post didn't use a var, but that doesn't make any diffrence in this problem... If the line without var was assinged to a MIDI file, it would have worked...


(tu) sinu(Posted 2003) [#5]
strange, i use

PlayMusic("track.mp3")

which works.


Hotcakes(Posted 2003) [#6]
Yeh, PlayMusic("blah.mp3") is just the same as 'PlayMusic "blah.mp3"' - it just discards the result - as does 'result = PlayMusic "blah.mp3"' also returns 0, but should still work.

Is it happenning with any mp3 (I'm guessing yeh)... It's a very strange problem you're having...


yinch(Posted 2003) [#7]
One thing that I notice is that Music and Sound are handled differently by Blitz.

Sounds can be preloaded and then played (therefore requiring a soundchannel)

Whereas music is not and cannot be preloaded.

Hence there is a LoadSound AND a PlaySound command but there is only a PlayMusic command (i.e. no LoadMusic)

The reason I mention this is that an MP3 file is actually much more like a Sound than a Music file (e.g. MIDI). SO, I wonder if depending on what file associations you have for your operating system - Blitz might be identifying the MP3 as a sound data file and it helpfully invokes LoadSound although you called PlayMusic.

I admit this is a bit of a long shot - but maybe it'll help somebody else come up with the actual explanation and a solution.

yinch'03


Hotcakes(Posted 2003) [#8]
channel=PlayMusic("sound.mp3")
PauseChannel channel

I'm under the impression that's a good way to 'preload' a music file...

I can confirm this bug, it's in B3D (havn't tested B+) v1.83. Ogg files also don't play anymore via PlaySound. Yikes.


_PJ_(Posted 2004) [#9]
Has this been fixed at all?


GfK(Posted 2004) [#10]
Has this been fixed at all?
It was never broken here.


Paolo(Posted 2004) [#11]
Malice,
why not upgrade b3d? it might work better in a later version...


_PJ_(Posted 2004) [#12]
I will - soon as I get my PC out of storage - shouldnt be loing now... we found a house!!!!!!!!!!!!!!!

I think its at 1.85, what version are we up to now?


Paolo(Posted 2004) [#13]
v1.88


John Blackledge(Posted 2004) [#14]
Just a thought, could it be that control is being handed over to DirectX, which might need a more explicit path?

For these functions I ususally use
"\Product\Music\music.mp3" (or some such) which works fine, and suggests that the current drive remains the same without needing to restate it within the filename, but if only the current drive is known to DirectX, then it might also need a more explicit path....?


RGR(Posted 2004) [#15]
;-


Uber Lieutenant(Posted 2004) [#16]
IF I recall correctly, the demo version of Blitz3D has MP3 support disabled. Maybe that's the problem?


_PJ_(Posted 2004) [#17]
Ive never used the demo version