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
Post a Comment