From 43d57ca34d02178bae6487da58207e268362fb44 Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen Date: Mon, 9 Jul 2018 22:56:02 -0700 Subject: [PATCH] CB-13445 (iOS) Streaming media can take up to 8-10 seconds to start (#169) * iOS streaming media can take up to 8-10 seconds to start. This fix allows streaming media to start right away. Caveat: on a slow internet connection there might be pauses for buffering (depends on size+length of media). * include check for iOS version so we don\'t break iOS<10. Thanks @ghenry22 * bump travis CI xcode versions --- .travis.yml | 4 ++-- src/ios/CDVSound.m | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f39fe518..7b2ebfb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,12 +26,12 @@ matrix: node_js: '6.14.2' - env: PLATFORM=ios-9.3 os: osx - osx_image: xcode7.3 + osx_image: xcode8.3 language: node_js node_js: '6.14.2' - env: PLATFORM=ios-10.0 os: osx - osx_image: xcode7.3 + osx_image: xcode8.3 language: node_js node_js: '6.14.2' - env: PLATFORM=android-4.4 diff --git a/src/ios/CDVSound.m b/src/ios/CDVSound.m index 7a00eadf..d63b0ab2 100644 --- a/src/ios/CDVSound.m +++ b/src/ios/CDVSound.m @@ -265,7 +265,11 @@ - (void)create:(CDVInvokedUrlCommand*)command // Pass the AVPlayerItem to a new player avPlayer = [[AVPlayer alloc] initWithPlayerItem:playerItem]; - //avPlayer = [[AVPlayer alloc] initWithURL:resourceUrl]; + // Avoid excessive buffering so streaming media can play instantly on iOS + // Removes preplay delay on ios 10+, makes consistent with ios9 behaviour + if ([NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10,0,0}]) { + avPlayer.automaticallyWaitsToMinimizeStalling = NO; + } } self.currMediaId = mediaId;