Skip to content

Instantly share code, notes, and snippets.

@Amimul100
Last active August 29, 2015 14:03
Show Gist options
  • Save Amimul100/e91f144720a965ac7895 to your computer and use it in GitHub Desktop.
Save Amimul100/e91f144720a965ac7895 to your computer and use it in GitHub Desktop.
Ti.Media.AudioPlayer error after sleep/wake fixed
Hello
We tested this issue in my device with given test code. We cant reproduces this error in following test environments. Please check your network connect and other setting. I hope it will solve your problem.
TEST ENVIRONMENT
Ti SDK 3.2.3.GA
Ti CLI 3.3.0-rc
iPad 4. iOS 7
STEP TO TEST:
1. Create a default alloy project.
2. Replace index.js with the following code:
~~~
Ti.Media.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAYBACK;
function doClick(e)
{ audioplayer.pause(); }
var audioplayer = Ti.Media.createAudioPlayer(
{url:'http://www.stephaniequinn.com/Music/Vivaldi%20-%20Spring%20from%20Four%20Seasons.mp3'}
);
audioplayer.play();
$.index.open();
~~~~
3. add the following to tiapp.xml (ios->plist->dict)
~~~
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
~~~
4. Add the following to index.xml
~~~
<Alloy>
<Window class="container">
<Button id="button" onClick="doClick" title="Pause/Play"
/>
</Window>
</Alloy>
~~~
5. Launch the app. Wait for the music to play.
6. Pause the music by clicking "Pause/Play" Go to Home.
7. Lock the device. Wait for a few seconds.
8. Unlock the device. Open the app. Resume the music by clicking "Pause/Play"
9. Audio will resume.
Thanks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment