Zin Mar Htet Zin Mar Htet - 7 months ago 424
Swift Question

Embedded AVPlayer is not playing video

I am trying to embed video player using Swift. When I run the app, I can see the video player but video is not playing. Could you check out any missing point, please? Thanks in advance.

var playerItem: AVPlayerItem?
var player: AVPlayer?

if let videoLink = newLaunch.videoLinks where newLaunch.videoLinks!.count > 0{

let videoUrl = videoLink[0]
let streamingURL: NSURL = NSURL(fileURLWithPath: videoUrl)
player = AVPlayer(URL: streamingURL)
let playerController = AVPlayerViewController()
playerController.player = player
playerController.view.frame = self.videoContainerView.bounds

enter image description here


I think there is no way apart from UIWebView to play youtube video inside iOS application. Also you can redirect to youtube application by passing your video url.So youtube application will handle rest of the things.

You can read the guidelines of YouTube section 2 point 10 :https://developers.google.com/youtube/terms?hl=en

You can use youtube player : https://developers.google.com/youtube/v3/guides/ios_youtube_helper#installation