Closed rezaarifian closed 7 years ago
@rezaarifian Hello ,how did you solve this problem?
add this on xcode class.m
RCT_EXPORT_METHOD(pause){
NSMutableDictionary *songInfo = [NSMutableDictionary dictionaryWithDictionary:[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo];
[songInfo setObject:[NSNumber numberWithFloat:0.0f] forKey:MPNowPlayingInfoPropertyPlaybackRate];
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = songInfo;
if(_player){
if(!_started)
[self play];
else {
[_player pause];
_paused = YES;
[self.bridge.eventDispatcher sendDeviceEventWithName:@"onPlaying" body:@{@"event": @"paused"}];
}
}
}
-(void)play
{
NSLog(@"ngPlay");
NSMutableDictionary *songInfo = [NSMutableDictionary dictionaryWithDictionary:[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo];
[songInfo setObject:[NSNumber numberWithFloat:1.0f] forKey:MPNowPlayingInfoPropertyPlaybackRate];
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = songInfo;
[_player play];
_paused = NO;
_started = YES;
[self.bridge.eventDispatcher sendDeviceEventWithName:@"onPlaying" body:@{@"event": @"playing"}];
}
add this on js
componentWillMount() {
this.onPlaying = DeviceEventEmitter.addListener("onPlaying", (trigger) => {
console.log("onPlaying", trigger.event);
if (trigger.event == 'playing') {
this.setState({ isPlaying: true });
this.setState({ miniplayer: true });
} else if (trigger.event == 'paused') {
this.setState({ isPlaying: false });
}
});
}
could you already play the audio ? this method for control resume and pause audio. I have many changes because my requirment for audio not video
Hii, After success install and playing audio, but I can't control pause, seek and onEnded not result. paused={this.state.paused} ==> nothing happen if bool true or false onEnded={this.onEnded.bind(this)} ==> {205} onBuffering={this.onBuffering.bind(this)} ==> not result onPaused={this.onPaused.bind(this)} ==> not result because state pause not work,