You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by al...@apache.org on 2016/08/25 14:26:28 UTC
cordova-plugin-media git commit: CB-10849 (ios) Fixed a crash when
playing soundfiles consecutively
Repository: cordova-plugin-media
Updated Branches:
refs/heads/master 2491782b5 -> 948fe3597
CB-10849 (ios) Fixed a crash when playing soundfiles consecutively
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/948fe359
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/tree/948fe359
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/diff/948fe359
Branch: refs/heads/master
Commit: 948fe35979e9985cc0df3039eb51fae108a8605f
Parents: 2491782
Author: Alexander Sorokin <al...@akvelon.com>
Authored: Mon Aug 22 16:43:20 2016 +0300
Committer: Alexander Sorokin <al...@akvelon.com>
Committed: Thu Aug 25 17:02:47 2016 +0300
----------------------------------------------------------------------
src/ios/CDVSound.m | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/948fe359/src/ios/CDVSound.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVSound.m b/src/ios/CDVSound.m
index 92d5f91..1b1f568 100644
--- a/src/ios/CDVSound.m
+++ b/src/ios/CDVSound.m
@@ -477,15 +477,20 @@
audioFile.player.currentTime = 0;
jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
}
+ // seek to start and pause
if (avPlayer.currentItem && avPlayer.currentItem.asset) {
- NSLog(@"Stopped playing audio sample '%@'", audioFile.resourcePath);
- [avPlayer seekToTime: kCMTimeZero
- toleranceBefore: kCMTimeZero
- toleranceAfter: kCMTimeZero
- completionHandler: ^(BOOL finished){
- if (finished) [avPlayer pause];
- }];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
+ BOOL isReadyToSeek = (avPlayer.status == AVPlayerStatusReadyToPlay) && (avPlayer.currentItem.status == AVPlayerItemStatusReadyToPlay);
+ if (isReadyToSeek) {
+ [avPlayer seekToTime: kCMTimeZero
+ toleranceBefore: kCMTimeZero
+ toleranceAfter: kCMTimeZero
+ completionHandler: ^(BOOL finished){
+ if (finished) [avPlayer pause];
+ }];
+ jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
+ } else {
+ // cannot seek, do nothing
+ }
}
// ignore if no media playing
if (jsString) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org