piemonte / Player

▶️ Play and stream media in Swift
MIT License
2.08k stars 334 forks source link

Not working #240

Open sam961 opened 3 years ago

sam961 commented 3 years ago

Hello, I added the following code in the viewDidLoad

    override func viewDidLoad() {
        super.viewDidLoad()

        self.player.playerDelegate = self
        self.player.playbackDelegate = self
        self.player.url = URL(string: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-15.mp3")!
        self.player.playbackResumesWhenBecameActive=false

    }

and added IBaction to play the audio using the below

    @IBAction func playButtonPressed(_ sender: UIButton) {

       // print(self.player.view)
        self.player.playFromBeginning()
    }

But unfortunatley , this is not working until I add the code below

print(self.player.view)

This will load the Player class into memory and it will unlock the isViewLoaded

How can this be fixed and the audio don't play automatically unless the user click in Play Button