ios - Swift How to update url of video in AVPlayer when clicking on a button? -


i have video player in ios app , want update video when click on button, not see how manage this. (note : it's not list of video within queue)

here code adding avplayer:

            let url = nsurl.fileurlwithpath(path)             let player = avplayer(url: url)             let playerviewcontroller = avplayerviewcontroller()             playerviewcontroller.player = player             ..              ..             self.viewforvideo.addsubview(playerviewcontroller.view)             self.addchildviewcontroller(playerviewcontroller)              player.play() 

i have done : each time want change video create new avplayer , affect playerviewcontroller.player

                let url = nsurl.fileurlwithpath(path)                 let player = avplayer(url: url)                 playerviewcontroller.player = player 

if thinks there better way, not hesitate answer


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -