kodeco.com Forums

Video Tutorial: Beginning Video with AVFoundation Part 1: Video Playback

In this video you'll learn the essentials of video playback with AVKit using AVPlayerViewController.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4033-beginning-video-with-avfoundation/lessons/2

I cannot get any videos to play from a URL. The AVPlayerViewController appears but without the video.

Any suggestions? I have researched the issue but have not been able to find a solution.

Just tried to do this using Xcode 9… nothing works… it’s a horrible experience :frowning:

I could fix some things… but am completely flummoxed by

func previewImageFromVideo(url: NSURL) → UIImage? {
let asset = AVAsset(url: url as URL)

Throws an error…

2017-09-24 17:07:38.661784+1000 QuickPlay[6342:1352041] CredStore - performQuery - Error copying matching creds. Error=-25300, query={
class = inet;
“m_Limit” = “m_LimitAll”;
“r_Attributes” = 1;
sync = syna;
}

Following some stack overflow articles I done this on the textfields…

       textField.autocorrectionType = .no
        textField.spellCheckingType  = .no

Still nothing…

Pity - the course looks great - but it’s a very frustrating thing at the moment :frowning:

Failed to build on the first updates for playVidoeClip method.
Any plans to update course to be compatible with at least Swift 3?

@skyrocketsw Can you please help with this when you get a chance? Thank you - much appreciated! :]

ha ha, you just need add transport permisstion in infor.plist like this
NSAppTransportSecurity

NSAllowsArbitraryLoads

Hey guys I found a fix on stack overflow:

Here’s the update in Swift 3.3

You need to do 2 things:

  • Add the permission key for access to the media/photo library
  • Run a check permissions
    extension ViewController {
    // https://stackoverflow.com/a/47343280/1492368
    func checkPhotoPermission(handler: @escaping () -> Void) {
        let photoAuthorizationStatus = PHPhotoLibrary.authorizationStatus()
        switch photoAuthorizationStatus {
        case .authorized:
            // Access is already granted by user
            handler()
        case .notDetermined:
            PHPhotoLibrary.requestAuthorization { (newStatus) in
                if newStatus == PHAuthorizationStatus.authorized {
                    // Access is granted by user
                    handler()
                }
            }
        default:
            print("Error: no access to photo album.")
        }
    }
    }

Love this series!

The code used to generate preview from assets doesn’t work in swift. Is there a work around. Cant find one myself

@skyrocketsw Do you have any feedback regarding this? Thank you - much appreciated! :]