looping music?
Blitz3D Forums/Blitz3D Beginners Area/looping music?
| ||
| I tried looping music, but failed. If anyone could give me some code for looping music, also for changing the music being played at any time, I'd appreciate it a lot. Thanks in advance. |
| ||
Try the following:
bkmusic=LoadSound("music.ogg") : If Not bkmusic Then RuntimeError "Cannot found music"
LoopSound(bkmusic)
PlaySound(bkmusic)
That should work |
| ||
| if you wanna change volume you'll need to investigate the channelvolume, channelpan etc commands. Above code would then be the same except for the last bit: global musicvolume#=0.75 channelbkmusic = PlaySound(bkmusic) channelvolume channelbkmusic,musicvolume As with most of the numbers in the audio channel commands, numbers need to be floating points, in order to give a range between 0 and 1 or -1 and 1 channelvolume works between 0 and 1 so ensure when you use a variable you globalise it as a float or it wonyt' fade at all. channelpan channelbkmusic, -1 ; for left channelpan channelbkmusic, 0 ; for centre channelpan channelbkmusic, 1 ; for right Channel allows for quite a lot of control - check these commands as follows: StopChannel PauseChannel ResumeChannel ChannelPitch ChannelVolume ChannelPan ChannelPlaying IPete2. |
| ||
| Thanks guys. IPete2 : I think you misunderstood me, I meant change what song is playing, not modify the playback. Didn't want to use the loopsound playsound method because changing songs would be difficult, I was hoping to use the channel methods |
| ||
try this tooo
music = playmusic("music.mp3")
while not keydown(1)
updatemusic(music)
wend
function updatemusic(music)
if not channelplaying(music)
music=playmusic(music)
endif
end function
|
| ||
| Sorry chwaga - twice in one week - doh! ;) IPete2. |
| ||
| http://www.blitzbasic.com/Community/posts.php?topic=69887 BASS_StreamCreate / BASS_SAMPLE_LOOP BASS_ChannelIsActive You can try this, examples are included. bye |