Comments (4)
Sounds weird. I'm currently kind of busy with my final exams, but I will look into it as soon as I finish. Stay tuned!
from afsoundmanager.
Even with slow connection I haven't been able to reproduce that bug, the completion block keeps being called till the playing stops
from afsoundmanager.
i've solved the problem doing this
if ((_audioPlayer.duration - _audioPlayer.currentTime) >= 1 ||
[_player status] != AVPlayerStatusFailed)
not tested enought.
doesn't work.
from afsoundmanager.
-(void)startStreamingRemoteAudioFromURL:(NSString *)url andBlock:(progressBlock)block {
NSURL *streamingURL = [NSURL URLWithString:url];
NSError *error = nil;
_player = [[AVPlayer alloc]initWithURL:streamingURL];
[_player play];
_status = AFSoundManagerStatusPlaying;
[_delegate currentPlayingStatusChanged:AFSoundManagerStatusPlaying];
if (!error) {
__block int percentage = 0;
_timer = [NSTimer scheduledTimerWithTimeInterval:1 block:^{
#ifdef DEBUG
NSLog(@"player status %i", [_player status]);
NSLog(@"currenTime %d", _audioPlayer.currentTime);
NSLog(@"duration %i", _audioPlayer.duration);
#endif
if ([_player status] == AVPlayerStatusUnknown || _audioPlayer.currentTime == 79609804) {
return;
}
percentage = (int)((CMTimeGetSeconds(_player.currentItem.currentTime) * 100)/CMTimeGetSeconds(_player.currentItem.duration));
if (percentage != 100) {
int timeRemaining = CMTimeGetSeconds(_player.currentItem.duration) - CMTimeGetSeconds(_player.currentItem.currentTime);
if (block) {
block(percentage, CMTimeGetSeconds(_player.currentItem.currentTime), timeRemaining, error, NO);
}
} else {
int timeRemaining = CMTimeGetSeconds(_player.currentItem.duration) - CMTimeGetSeconds(_player.currentItem.currentTime);
if (block) {
block(100, CMTimeGetSeconds(_player.currentItem.currentTime), timeRemaining, error, YES);
}
[_timer invalidate];
_status = AFSoundManagerStatusFinished;
[_delegate currentPlayingStatusChanged:AFSoundManagerStatusFinished];
}
} repeats:YES];
} else {
if (block) {
block(0, 0, 0, error, YES);
}
[_audioPlayer stop];
}
}
this works.
from afsoundmanager.
Related Issues (20)
- Weird Sounds
- How to seek when using a queue? HOT 1
- Buffer size when playing a remote file HOT 1
- sound's metadata not accurate
- swift 2.0 Version
- After interruption not start play automatically
- get timer update in all ViewControllers
- Time duration wrong
- can i provide track duration at time of starting
- how to check is playing or not
- how to check is playing or not ?
- can't get duration HOT 2
- Once internet connection lost than not able to reply song
- How to switch between headphone and speaker while playing?
- bug for short music in queue HOT 1
- Some URL program can flash back
- Warning - AVAudioRecorder
- Streaming and caching HOT 1
- how to remove listener
- Y
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from afsoundmanager.