I am using AVPlayer to play a live stream from the Internet using the following code :
    NSString *u = @"http://192.192.192.192:8036";
NSURL *url = [NSURL URLWithString:u];
radiosound = [[AVPlayer alloc] initWithURL:url];
    [radiosound play]; 
And I have one button play :
[radiosound play]; 
and Pause :
[radiosound pause]; 
My issue is that I want to use only one button Play/Pause, but when I am using this code
if (radiosound.isPlaying) {         
    [radiosound pause]; 
} else {                
     [radiosound play]; 
}
My app crashes, because AVPlayer doesn´t recognize "isPlaying".
Any tips?
AVPlayer doesn't have an isPlaying property. Use the rate property (0.0 means stopped, 1.0 playing).
if (radiosound.rate == 1.0) {         
    [radiosound pause]; 
} else {                
     [radiosound play]; 
}
You can look at the AVPlayer class reference here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With