apache / cordova-plugin-media

Apache Cordova Media Plugin
https://cordova.apache.org/
Apache License 2.0
387 stars 765 forks source link

Stalled Playback on iOS in sleep mode after a few seconds of streaming large audio file #281

Open dave3vans opened 4 years ago

dave3vans commented 4 years ago

Bug Report

Problem

If I stream a large (40mb, 1 hour AAC) file from a URL, then put the device into sleep mode, it stops playback after around 20 seconds, with 'Stalled Playback' message.

What is expected to happen?

Should continue to play. Playing smaller files (e.g. 20MB. 30 minute AAC) works fine.

What does actually happen?

See above.

Information

I have playAudioWhenScreenIsLocked set to true, and also in plist file UIBackgroundModes set to audio and fetch, as well as UIRequiresPersistentWiFi set to true.

iOS is closing the network connection, but I thought with UIRequiresPersistentWiFi it shouldn't?

Command or Code

this.mediaObject.play({ playAudioWhenScreenIsLocked: true });

Environment, Platform, Device

Test device: iPhone 7, iOS 13.5.1

Version information

Ionic:

   Ionic CLI                     : 6.10.0 (C:\Users\dave\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 4.11.10
   @angular-devkit/build-angular : 0.13.10
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.0.0, browser 6.0.0, ios 5.1.1

cordova-android-support-gradle-release 3.0.1 "cordova-android-support-gradle-release"
cordova-annotated-plugin-android 1.0.4 "cordova-annotated-plugin-android"
cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx"
cordova-plugin-androidx-adapter 1.1.1 "cordova-plugin-androidx-adapter"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-doze-optimize 0.1.3 "DozeOptimize"
cordova-plugin-facebook4 6.4.0 "Facebook Connect"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-firebasex 9.1.1 "Google Firebase Plugin"
cordova-plugin-googleplus 8.5.0 "Google SignIn"
cordova-plugin-inappbrowser 3.2.0 "InAppBrowser"
cordova-plugin-ionic 5.4.7 "cordova-plugin-ionic"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 5.0.0 "cordova-plugin-ionic-webview"
cordova-plugin-media 5.0.3 "Media"
cordova-plugin-music-controls2 3.0.4 "Music Controls"
cordova-plugin-network-information 2.0.2 "Network Information"
cordova-plugin-purchases 1.1.0 "Purchases"
cordova-plugin-screen-orientation 3.0.2 "Screen Orientation"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"

Utility:

   cordova-res : 0.14.0
   native-run  : 1.0.0

System:

   Android SDK Tools : 26.1.1 (C:\Users\dave\AppData\Local\Android\Sdk)
   NodeJS            : v10.16.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.9.0
   OS                : Windows 10

Checklist

21pg commented 4 years ago

any solution here ? I am facing same issue..

capiztrr commented 4 years ago

did you enable background mode -> audio on xcode capabilities?

george19gt commented 4 years ago

Hi @21pg

It's works for me:

On xCode check Signing & Capabilities -> Background Modes

you have to enable the option Audio, AirPlay, and Picture in Picture

pslyman commented 3 years ago

Anybody find a solution to this? Updating Capabilities in XCode doesn't help.