HHK1 / PryntTrimmerView

A set of tools to trim, crop and select frames inside a video
MIT License
835 stars 198 forks source link

position bar is not moving while video is playing #16

Closed ajay2c9 closed 6 years ago

ajay2c9 commented 6 years ago

Hi, I am using the PryntTrimmerView in my app my project is in objective-c and i am using Xcode 8.3.3. I am facing a problem position bar . Position bar is not moving. I implemented the code like this.After downloading the video from URL in to local path, i call a method in that

trimView.handleColor = [UIColor whiteColor]; trimView.mainColor = [UIColor darkGrayColor]; trimView.positionBarColor = [UIColor whiteColor]; [trimView setMinDuration:4.0]; [trimView setMaxDuration:25.0]; seekBarView.hidden=NO; trimView.hidden=NO; FBVideoAsset = [AVAsset assetWithURL:[NSURL fileURLWithPath:filePath isDirectory:YES]]; trimView.asset =FBVideoAsset; trimView.delegate=self;

FBVideoItem =[[AVPlayerItem alloc]initWithAsset:FBVideoAsset]; fbVideoPlayer=nil; fbVideoPlayer = [[AVPlayer alloc]initWithPlayerItem:FBVideoItem]; AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:fbVideoPlayer]; fbPlayerView.backgroundColor=[UIColor clearColor]; [playerLayer removeFromSuperlayer]; [fbPlayerView.layer addSublayer:playerLayer]; playerLayer.contentsGravity = AVLayerVideoGravityResizeAspectFill; [playerLayer setFrame:trimVCDelegate.fbPlayerView.frame]; [fbPlayerView.layer addSublayer:playerLayer]; [fbVideoPlayer play];

Delegate methods are calling when left and right handles are moving. Start and end points are also not getting. please give suggestion for moving the position bar while playing the video and getting the Start and end points values.

Thank you

HHK1 commented 6 years ago

For the position bar

Take a look in the example app at the VideoTrimmerViewController: https://github.com/prynt/PryntTrimmerView/blob/master/Example/PryntTrimmerView/VideoTrimmerViewController.swift

It uses a timer to check regularly the currentTime of the player:

let playBackTime = player.currentTime()
trimmerView.seek(to: playBackTime)

Please check the VideoTrimmerViewController for a complete implementation.

For the startTime and endTime: Can you please put a breakPoint inside the AVAssetTimeSelector class, in the method getTime(from position: CGFloat), and check the values for the following:

  1. asset
  2. position
  3. asset.duration
  4. the durationSize