fethica / FRadioPlayer

A simple radio player framework for iOS, macOS, tvOS.

Home Page:https://fethica.github.io/FRadioPlayer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Impossible to restart stream after lost connection

romain25 opened this issue · comments

Hello and thank for you Librairie and SwiftRadioPro, I have a trouble, I think it's a bad integration, but I don't understand.
Everything is ok when I play and stop, and start and stop with music controller, when I receive cellular call, change with another application, when we lose network for few seconds. So it's really fine.
But when I loose connection when I drive for example or when I try with Network Link Conditionner, it's impossible to play, I need to kill app to replay.
Do you have an idea ?

I need to reset player ? Other thing ? Use delegate, other ?

And I test another thing with simple implementation
I have the same problem with simple implementation of AVPlayer

        let urlString = StreamUrl
        guard let url = URL.init(string: urlString)
            else {
                return
        }
        let playerItem = AVPlayerItem.init(url: url)
        player = AVPlayer.init(playerItem: playerItem)

And it's impossible for me to play after this warning

2021-04-27 23:12:37.786986+0200 XXX[5725:3210729] [Symptoms] {
  "transportType" : "HTTP Live Stream",
  "mediaType" : "HTTP Live Stream",
  "BundleID" : "XXX",
  "name" : "MEDIA_PLAYBACK_STALL",
  "interfaceType" : "Other"
}

Thanks in advance. Romain

I continue my tracking.
I have handle notification and I have this. Not really clear. But after this message impossible to restart stream

Error Domain=AVFoundationErrorDomain Code=-11800 "L’opération n’a pas pu être effectuée." UserInfo={NSLocalizedFailureReason=Une erreur inconnue s’est produite (-16830), NSLocalizedDescription=L’opération n’a pas pu être effectuée., NSUnderlyingError=0x600001757720 {Error Domain=NSOSStatusErrorDomain Code=-16830 "(null)"}

Ok finally after 2 days of search.

The good thing is this : before play you replacePlayerItem ....
player.replaceCurrentItem(with: item)

func play() {
        let item = AVPlayerItem(url: URL(string: StreamUrl)!)
        player.replaceCurrentItem(with: item)
        player.play()
        isPlaying = true
    }

Thanks to this project and thank you too :)
https://github.com/robertmryan/RadioPlayer

Hey @romain25 thanks for the solution, I will investigate this and add your solution to the library.