ios - [AVPlayerLayer superview]: unrecognized selector sent to instance in Swift -


in storyboard put view inside of uiviewcontroller. added necessary parameters there:

enter image description here

and connected code:

enter image description here

in code have:

import avkit import avfoundation  @iboutlet weak var yawpvideo: avplayerlayer!  override func viewdidload() {      let url:nsurl = nsurl(string: videourl)!      player = avplayer(url: url)     yawpvideo.player = player     player.play() } 

and causes error:

*** terminating app due uncaught exception  'nsinvalidargumentexception', reason: '-[avplayerlayer superview]:  unrecognized selector sent instance 0x7fe320cb2030' 

can tell me causes problem , how can fixed?

a uiview not calayer, cannot add avplayerlayer storyboard.

instead, after view has loaded, programmatically add avplayer's playerlayer uiview's layer.

change outlet uiview:

@iboutlet weak var yawpvideo: uiview! 

then, add layer:

player = avplayer(url: url) let playerlayer = avplayerlayer(player: player) yawpvideo.layer.addsublayer(playerlayer) 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -