Search code examples
swiftavplayertvos

Is it possible to make preview image while scroll video timeline like in Netflix app?


Is it possible to make peview image while listing video timeline, like in Netflix App with AVPlayer? exmple here

I found that mp4 video has that preview window, but m3u8 format has not it

func playVideo(cell:  MovieCell) {
    guard let urlVideo = URL(string: cell.movieSrc) else { return }

    // Create an AVPlayer, passing it the HTTP Live Streaming URL.
    let player = AVPlayer(url: urlVideo)

    // Create a new AVPlayerViewController and pass it a reference to the player.
    let controller = AVPlayerViewController()
    controller.player = player

    // Modally present the player and call the player's play() method when complete.
    self.present(controller, animated: true) {
        player.play()
    }
}

Solution

  • This is called "Trick Play" and must be included in the HLS manifest for AVPlayer to handle this for you.

    See the Trick Play section in HLS Authoring Specification for Apple Devices:

    6.1. I-frame playlists (EXT-X-I-FRAME-STREAM-INF) MUST be provided to support scrubbing and scanning UI.