ios - AVPlayer not playing the podcast streaming audio after network connection loss and come back -
in application using avplayer
play podcast streaming audio. if internet connection lost stops playing audio, after connection come started playing audio using [avplayer play]
, audio not playing.
below code reference
- (void)preparetoplaywithurlstring:(nsstring *)urlstring { [self loadplayeritem]; [_player play]; } - (void)loadplayeritem { [self removeavplayerandplayeritemobservers]; nsurl *podcasturl = [nsurl urlwithstring:@"url string here"]; avurlasset *testurlasset = [avurlasset assetwithurl:podcasturl]; _playeritem = [avplayeritem playeritemwithasset:testurlasset]; if (nil == _player) { _player = [avplayer playerwithplayeritem:_playeritem]; } else { [_player replacecurrentitemwithplayeritem:_playeritem]; } if (system_version_greater_than_or_equal_to(@"10.0")) { _player.automaticallywaitstominimizestalling = no; } [self addavplayerandplayeritemobservers]; }
Comments
Post a Comment