Game Development Community

mp3 not playing in 1.3

by Isaac Barbosa · in iTorque 2D · 03/20/2010 (1:05 pm) · 10 replies

Hello,

I´m using

%loop = true;
$musicStreamFile = "~/data/audio/KingdomMemoriesMusicBox.mp3";
$musicStreamHandle = startiPhoneAudioStream($musicStreamFile,%loop);

to play an mp3 file and this is not working on 1.3 despite it works perfectly on previous versions... what could be wrong here?

Thanks!

#1
03/20/2010 (4:52 pm)
First for the sake of completeness, let me make sure your trying to get mp3 to play on the iPhone, itouch, or simulator. Because you cannot play MP3's on the MAC. But I figure you know this already.

Second your not crazy because that should work. :)

I just tried it on 1.3.1 and it works for me. So my first guess as to what could cause the problem is maybe the MP3 has not been added to the project. I would check the package content of your iPhone build and make sure the audio file is there.

Once you double check that it is there, let me know and we can go from there.
#2
03/20/2010 (5:15 pm)
Hi Christopher,

Yeah, I´m tryng on my iPod. Not Mac ;)

What is weird is that this was working on previous games... (solitaire siege and smart drop are playing mp3 and wav files). But now, no matter if mp3 or wav... there is no sounds in the game once in the ipod... maybe it has something to with the fact that a video was previously reproduced and once the video is played something goes broken? If not, I don´t have idea on what could be wrong since even sounds through alxplay are not working (only on the ipod, on the PC are working as expected).

Thanks
#3
03/20/2010 (5:37 pm)
its potentially possible that the audio is not correctly restored / paused for the duration of the video play, that would have to be checked.

guess most so far used it for the intro before any audio is actually used so the initialized audio devices aren't trashed by the mediaplayer framework
#4
03/21/2010 (8:29 am)
Marc,

Yeah, tt´s caused because a video was played. The function to play the mp3 is called after the video was finished, so I have no idea on how to clean or release the device to be able to play music again. Please give a path to follow!

Thanks
#5
03/21/2010 (10:00 am)
You would have to reinit the device.

the simple solution likely would be using a boolean flag thats set to true whenever a video is played. the audio commands then would check for this flag before starting to play and if it is true, reinit the audio and set the flag to false again

I think that should work
#6
03/21/2010 (11:16 am)
@Marc,

Thanks for the reply. Sadly, I don´t know what to do to reinit the audio. I´ve tried exeing the audio.cs file again, but that doesn´t works. Are you talking about dealing with C? If so, I´m lost... well, anyway I´m lost! Can you be more detailed please? A specific code snipet? I can´t believe that this is not yet adressed into the docs... well, I can believe it since the documentation is not updated as should.

Thanks

Isaac
#7
03/21/2010 (11:33 am)
Right, its pure Objc - C++ you have to work, you have to work with the audio device initialization code.
you can do your work basing on the code thats already present to do the init "the first time" and tell it to do it again if a video was played
#8
03/22/2010 (8:52 am)
@Marc,

Again, thanks for your answer.

Well, that doesn´t make me happy. It make me feel really mad and angry because of the fact that actually this is screwed and not suitable for me. I mean: I can´t deal with Objc - C++! And I can´t understand why sound device goes mute after playing a video. Why is this still unresolved? This means that iTGB will be always limited to a certain functions and that fully supports means you deal alone (or only with community support, that sometimes is like being alone anyway)?

Please help me to fix this since I don´t have the knowledge to deal with C++.

Luma: Support this please!
Thanks
#9
03/22/2010 (9:48 am)
The video playback is a community feature that was integrated with 1.3.0 so you don't have to hack around anymore to get it in :)
#10
03/22/2010 (9:58 am)
Ah, I understand.

Well, due to my lack of knowledge, I will do the following:

1. Get rid of the video since it screw the device sounds ability.
and
2. I will do the video animation using iTGB editor.

Thanks