A while back I enquirer on here about how to get a video to play. I was given a link and used it. I have figured out how to get the video to show, but I need a way to have buttons play, pause, go to the beginning or go to the end.
def showVideo(video, viewToShowOn): i=AVPlayerItem.playerItemWithAsset_(video) p=AVPlayer.playerWithPlayerItem_(i) name = str(i) videolayer=AVPlayerLayer.playerLayerWithPlayer_(p) V=ObjCInstance(viewToShowOn) videolayer.frame=V.bounds() V.layer().addSublayer_(videolayer)
This is the function I use to set the video. How would I go about calling that layer to use the play? Here is the link I was given to add the video.
I need to set up a button to play. But I don’t know how to call the player to have it play from outside the showVideo() function
If you look back at the original, you will notice the p.play().
It is often helpful to go into the console, and let autocomplete should you what methods exist -- for instance typing
p.shows that there is a play(), pause(), and other methods.
Ok. But how would I set p.play outside that def
you just need to store a reference to your player. For instance it could be an instance variable of your root view:
Or, in your button action:
Thank you sooooo much!!!!