cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [04/13] cordova-plugin-media git commit: Implement stop() for avplayer for compliance
Date Fri, 29 Jan 2016 23:48:06 GMT
Implement stop() for avplayer for compliance

stop will now behave the same when avplayer is used to play from a
stream as when avaudioplayer is used to play from a local file.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/commit/6f3727c6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/tree/6f3727c6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/diff/6f3727c6

Branch: refs/heads/master
Commit: 6f3727c63d753cfdff15962c5f2132bac4bc47ac
Parents: 31d5362
Author: ghenry22 <ghenry22@gmail.com>
Authored: Tue Oct 13 08:59:57 2015 +0800
Committer: ghenry22 <ghenry22@gmail.com>
Committed: Tue Oct 13 08:59:57 2015 +0800

----------------------------------------------------------------------
 src/ios/CDVSound.m | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/6f3727c6/src/ios/CDVSound.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVSound.m b/src/ios/CDVSound.m
index 50b15ee..80f90da 100644
--- a/src/ios/CDVSound.m
+++ b/src/ios/CDVSound.m
@@ -458,7 +458,17 @@
         [audioFile.player stop];
         audioFile.player.currentTime = 0;
         jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova-plugin-media.Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_STOPPED];
-    }  // ignore if no media playing
+    }
+    if (avPlayer.currentItem && avPlayer.currentItem.asset) {
+        NSLog(@"Stopped playing audio sample '%@'", audioFile.resourcePath);
+        [avPlayer pause];
+        [avPlayer seekToTime: kCMTimeZero
+                     toleranceBefore: kCMTimeZero
+                      toleranceAfter: kCMTimeZero
+                   completionHandler: ^(BOOL finished)];
+        jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova-plugin-media.Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_STOPPED];
+    }
+    // ignore if no media playing
     if (jsString) {
         [self.commandDelegate evalJs:jsString];
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message