AVPlayerView Question. .canBeginTrimming == false

55 Views Asked by At

I am using an AVPlayerView and I'm trying to call the beginTrimming method. However it isn't working (ie. not entering trimming mode), so I checked its .canBeginTrimming property and found that it is false.

The .mov files I am using are local and I'm accessing them via their urls. They load and play properly, I just can't enter trimming mode. (Also, if I open the same files in QuickTimePlayer I can trim them.)

The research I've found says:"This property value is false if the current controls style doesn’t support trimming, the media is content protected, or when playing HTTP Live Streaming media.

The .mov files I am using are local and I'm accessing them via their urls. They load and play properly, I just can't enter trimming mode. (Also, if I open the same files in QuickTimePlayer I can trim them.)

I have an outlet to the AVPlayerView in my view controller. The control's style is set to default and "show buttons" is set to Frame Stepping.

enter image description here

Why might the player I have set up not allow trimming?

Here is where I am loading the mov file, checking whether trimming is allowed and attempting to enter trimming mode:

    func tableViewSelectionDidChange(_ notification: Notification) {
        let row = movTableView.selectedRow
        guard row != -1 else { return }
        let selectedURL = movDict[allFilenames[row]]
        print(selectedURL)
        if let selectedURL {
            let player = AVPlayer(url: selectedURL)
            movPlayerView.player = player
            if movPlayerView.canBeginTrimming {
                print("medial player supports trimming")
            } else {
                print("media player does NOT support trimming")
            }
            movPlayerView.beginTrimming { result in
                if result == .okButton {
                    print("trimming ended. ok pressed")
                } else {
                    print("cancel pressed.")
                }
            }
        }
    }

The AVPlayerView is set up as a control in my main view and I have connected it to an outlet in my ViewController:

    @IBOutlet weak var movPlayerView: AVPlayerView!

I haven't done any further setup or modification to the control in code – I've only set its properties initially in the storyboard.

0

There are 0 best solutions below