title: Create a thumbnail image for video at a current frame while sliding the player
body: <p>What I'm trying to do is to get the current frame of thumbnail image while sliding video. I expect this line could do the task:</p>
  
  <pre><code>[self.controlView.videoSlider setImage:image ? : ZFPlayerImage(@"ZFPlayer_loading_bgView")];
  </code></pre>
  
  <p>But I never get right about my <code>image</code> so always end up with <code>ZFPlayer_loading_bgView</code> </p>
  
  <p>From what I've done some research, someone says there's something to do with <code>CMTime dragedCMTime     = CMTimeMake(dragedSeconds, 1);</code> and I tried tinkering the latter number but nothing works! Could anyone tell me what I've been missing or how to figure this out?</p>
  
  <p>Here below the relevant codes:</p>
  
  <pre><code>- (void)progressSliderValueChanged:(ASValueTrackingSlider *)slider
  {
      if (self.player.currentItem.status == AVPlayerItemStatusReadyToPlay) {
          NSString *style = @"";
          CGFloat value   = slider.value - self.sliderLastValue;
          if (value &gt; 0) { style = @"&gt;&gt;"; }
          if (value &lt; 0) { style = @"&lt;&lt;"; }
          if (value == 0) { return; }
  
          self.sliderLastValue    = slider.value;
  
          [self pause];
  
          CGFloat total           = (CGFloat)_playerItem.duration.value / _playerItem.duration.timescale;
  
          NSInteger dragedSeconds = floorf(total * slider.value);
  
          CMTime dragedCMTime     = CMTimeMake(dragedSeconds, 1); 
  
          NSInteger proMin        = (NSInteger)CMTimeGetSeconds(dragedCMTime) / 60;
          NSInteger proSec        = (NSInteger)CMTimeGetSeconds(dragedCMTime) % 60;
  
          NSInteger durMin        = (NSInteger)total / 60;
          NSInteger durSec        = (NSInteger)total % 60;
  
          NSString *currentTime   = [NSString stringWithFormat:@"%02zd:%02zd", proMin, proSec];
          NSString *totalTime     = [NSString stringWithFormat:@"%02zd:%02zd", durMin, durSec];
  
          if (total &gt; 0) {
              self.controlView.videoSlider.popUpView.hidden = !self.isFullScreen;
              self.controlView.currentTimeLabel.text  = currentTime;
              if (self.isFullScreen) {
                  [self.controlView.videoSlider setText:currentTime];
                  dispatch_queue_t queue = dispatch_queue_create("com.playerPic.queue", DISPATCH_QUEUE_CONCURRENT);
                  dispatch_async(queue, ^{
                      NSError *error;
                      CMTime actualTime;
  
                      CGImageRef cgImage = [self.imageGenerator copyCGImageAtTime:dragedCMTime actualTime:&amp;actualTime error:&amp;error];
  
                      CMTimeShow(actualTime);
  
                      UIImage *image = [UIImage imageWithCGImage:cgImage];
  
                      CGImageRelease(cgImage);
  
                      dispatch_async(dispatch_get_main_queue(), ^{
                          [self.controlView.videoSlider setImage:image ? : ZFPlayerImage(@"ZFPlayer_loading_bgView")];
                      });
                  });
  
              } else {
                  self.controlView.horizontalLabel.hidden = NO;
                  self.controlView.horizontalLabel.text   = [NSString stringWithFormat:@"%@ %@ / %@",style, currentTime, totalTime];
              }
          }else {
  
              slider.value = 0;
          }
  
      }else {
  
          slider.value = 0;
      }
  }
  </code></pre>
  
  <p>Here what it looks like while scrolling the player:
  <a href="https://i.stack.imgur.com/alLxe.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/alLxe.jpg" alt="enter image description here"></a></p>