How to make player resume from the newest frame?

178 views Asked by At

I use ijkplayer to play the live video in my ios app.

Here is the code for player initialization

    let options = IJKFFOptions.byDefault()
    let streamUrl:String = "http://xxxxxxxxx.com/test/7777.flv"
    let player = IJKFFMoviePlayerController(contentURLString: streamUrl, with: options)
    let autoresize = UIViewAutoresizing.flexibleWidth.rawValue | UIViewAutoresizing.flexibleHeight.rawValue
    player?.view.autoresizingMask = UIViewAutoresizing(rawValue: autoresize)
    player?.view.frame = CGRect(x: 0, y: 0, width: 1, height: 1)
    let gesture = UITapGestureRecognizer(target: self, action: #selector(self.compressExpand(_:)))
    player?.view.addGestureRecognizer(gesture)
    player?.view.backgroundColor = UIColor.black
    player?.scalingMode = .aspectFit
    player?.shouldAutoplay = false
    self.player = player
    self.player.shouldShowHudView = true
    self.player.setPlayerOptionIntValue(1000, forKey: "max_cached_duration")

The issue is I use player.pause() to resume the player for some time. Then I use player.play() to resume playing. Live video then playing from the frame where paused, what I want is to resume the video from the latest or newest frame.

1

There are 1 answers

0
AudioBubble On BEST ANSWER

You can release the player, and initiate it again. This should play the demo from the latest frame. This may be not the best solution.