Skip to content

Commit

Permalink
[TIMOB-16102] iOS: AudioPlayer progress event not firing
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelkPetkov committed Apr 27, 2016
1 parent e0ac5a8 commit be3085b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion iphone/Classes/TiMediaAudioPlayerProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
double volume;
double duration;
AudioStreamer *player;
BOOL progress;
NSTimer *timer;
}

Expand Down
17 changes: 7 additions & 10 deletions iphone/Classes/TiMediaAudioPlayerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@ -(void)_listenerAdded:(NSString *)type count:(int)count
{
if (count == 1 && [type isEqualToString:@"progress"])
{
progress = YES;
timer = [[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateProgress:) userInfo:nil repeats:YES] retain];
}
}

-(void)_listenerRemoved:(NSString *)type count:(int)count
{
if (count == 0 && [type isEqualToString:@"progress"])
{
progress = NO;
if (timer!=nil)
{
[timer invalidate];
RELEASE_TO_NIL(timer);
}
}
}

Expand All @@ -72,15 +76,8 @@ -(AudioStreamer*)player
}
player = [[AudioStreamer alloc] initWithURL:url];
[player setDelegate:self];
[player setBufferSize:bufferSize];
[player setBufferSize:bufferSize];
[player setVolume:volume];

if (progress)
{
// create progress callback timer that fires once per second. we might want to eventually make this
// more configurable but for now that's sufficient for most apps that want to display progress updates on the stream
timer = [[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateProgress:) userInfo:nil repeats:YES] retain];
}
}
return player;
}
Expand Down

0 comments on commit be3085b

Please sign in to comment.