Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19519] iOS - Ti.Media.AudioPlayer - error after sleep/wake

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionDuplicate
Resolution Date2018-01-13T20:46:38.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
LabelsTCSupportTriage
ReporterShawn Lan
AssigneeHans Knöchel
Created2014-06-27T20:04:39.000+0000
Updated2018-08-06T17:41:07.000+0000

Description

I use Ti.Media.AudioPlayer to play remote mp3s. If I pause the player, lock the screen, wait for ~30 seconds, wake it up and resume the playback, the audio plays for a few seconds and then stops. This is a big issue. To reproduce: 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) ~~~ UIBackgroundModes audio ~~~ 4. Launch the app. Wait for the music to play. 5. Pause the music by clicking "Hello, World." 6. Go to Home (optional) 7. Lock the device. Wait for ~30 seconds. 8. Unlock the device. Open the app. Resume the music by clicking "Hello, World." 9. The audio plays for a few seconds and then stop. Error: No audio data found. 10. Sometimes the error doesn't show up (rarely). Repeat from 5 - 9 until the error shows. This test is run on an iPad 4. iOS 8. SDK 4.1.0.

Comments

  1. Mauro Parra-Miranda 2014-06-30

    Hello [~shawnlan]! Can you please provide a testcase for this issue? So we can reproduce it and move this issue to Platform. Thanks a lot!
  2. Shawn Lan 2014-06-30

    I updated the description to include steps to reproduce the issue. Please take a look. Thanks.
  3. Shawn Lan 2014-06-30

    I also found that it couldn't play a remote mp3 longer than 10 minutes in the background, if I locked the screen manually during the audio playing. At some point the audio stopped and received the error.
  4. Shawn Lan 2014-07-09

    Try which one?
  5. Mauro Parra-Miranda 2014-07-09

    [~shawnlan] sorry, internal comment.
  6. Mostafizur Rahman 2014-07-12

    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
  7. Shawn Lan 2014-08-14

    Thanks for your response. Like I said, sometimes it works. If the audio resumes, all you need is repeat steps 6 through 8 a few times until the error comes up. Please test it again. Thanks.
  8. Mauro Parra-Miranda 2014-08-14

    Hello [~shawnlan]! As you can see, we created a testcase. Please help us doing couple of things: - Use 3.3.0.GA - Please try to reproduce the issue with the testcase that we provided. - If we are failing in any of the steps or the code, please help us to generate a testcase that will show the issue, so we can move this into Platform. Thanks a lot!
  9. Shawn Lan 2014-08-14

    okay I'll do and then let you know. Just so you know, I've tested my test case on different internet network as well as different devices, such iPad 4 and iPhone 5. Anyway, I'll test your test case and let you know. Thanks.
  10. Shawn Lan 2014-08-19

    Hi I tested it: SDK 3.3.0 iPad 4 iOS 7 The issue persists. I did try several times to get it. Like I said, you have to repeat steps 6 through 8. If you still can't reproduce it, maybe wait for a while, or reinstall the app, etc. I'm not sure what causes it, but if you keep trying it, you'll get it. It's not that hard to reproduce the issue. Usually I get it by repeating steps 6 through 8 twice. Thanks.
  11. kosso 2014-12-11

    I think the bigger issue here is that there is no error event for AudioPlayer. If a stream fails to start() the "File Error: Unable to configure network read stream" alert pops up and there's no way get rid of that, or catch anything to provide a better message/retry.
  12. Shawn Lan 2015-08-27

    In SDK 4.1.0 there is the error event, which you can listen to. However, the original issue persists. I think the audio player stops buffering data in this test case, which makes sense. But it should resume loading the data from where it last left off when user resumes the playback. Otherwise the playback stops, which is a bad user experience.
  13. Shawn Lan 2015-08-27

    I updated the environment and description for SDK 4.1.0.
  14. kosso 2015-08-28

    A lot of the problems with Ti.Media.audioPlayer is that it's based on Matt Gallagher's old AudioStreamer project. This was written when the iPhone 3GS came out. Things have changed .What do we need to support? Since this issue, and others Ive had similar and related, I've built a module using AVFoundation's AVPlayer to do what I need : https://github.com/kosso/TiAVPlayer I had to build an Android audio module too, in order to provide some updated parity with the cross-platform app I've had to build. Fun. Hmm. ;)
  15. Shawn Lan 2015-08-28

    Looking forward to it! When do you plan to have a production release? For iOS, will you include Control Center functionalities? For Android, Titanium's audio player is still lacking. For example, running as a foreground service, etc. Check [here](http://developer.android.com/guide/topics/media/mediaplayer.html) for a complete guide. Thanks!
  16. Hans Knöchel 2018-01-13

    Will be resolved as part of TIMOB-24909.
  17. Eric Merriman 2018-08-06

    Closing as a duplicate. If this is in error, please reopen.

JSON Source