Search code examples
titaniumtitanium-mobileappceleratorappcelerator-mobile

Titanium audio player stops playing mp3 after a moment


In my Titanium iOS app I'm using the Ti audio player:

var mp3URL = "http://www.noiseaddicts.com/samples/47.mp3";

var audioPlayer = Ti.Media.createAudioPlayer({ 
    url: mp3URL,
    allowBackground: true
});

I borrowed this boilerplate code and am using it unchanged, aside from minor UI tweaks: http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Media.AudioPlayer

When I click the Play button, it begins to play the clip (I can hear it, and it's correct), but then automatically stops a split-second later. I can replicate this 100% of the time and it always happens. I am not double-clicking the button or anything. Quick single click.

My full source code (excluding some of the UI stuff) for the audio piece is here: http://pastie.org/9624811

I am using Titanium SDK 3.4.0 GA, targeting iPhone 4S (v. 8.0) with XCode 6.0.1.

This gets logged in the output:

[INFO] :   State: starting (1)
[INFO] :   State: waiting_for_data (2)
[INFO] :   State: unknown (9)
[INFO] :   State: waiting_for_queue (3)
[INFO] :   State: stopping (6)
[INFO] :   State: stopped (7)
[INFO] :   State: initialized (0)

Any ideas?


Solution

  • The AudioPlayer has a problem playing that specific MP3 file. I found this Titanium ticket that's been open for a long time.

    https://jira.appcelerator.org/browse/TIMOB-4992

    I tried a sample MP3 from this site and it worked perfectly:

    http://www.stephaniequinn.com/samples.htm