void MediaPlayerPrivateAVFoundation::seekWithTolerance(const MediaTime& mediaTime, const MediaTime& negativeTolerance, const MediaTime& positiveTolerance)
{
    MediaTime time = mediaTime;

    if (m_seeking) {
        LOG(Media, "MediaPlayerPrivateAVFoundation::seekWithTolerance(%p) - save pending seek", this);
        m_pendingSeek = [this, time, negativeTolerance, positiveTolerance]() {
            seekWithTolerance(time, negativeTolerance, positiveTolerance);
        };
        return;
    }
    m_seeking = true;

    if (!metaDataAvailable())
        return;

    if (time > durationMediaTime())
        time = durationMediaTime();

    if (currentMediaTime() == time)
        return;

    if (currentTextTrack())
        currentTextTrack()->beginSeeking();

    LOG(Media, "MediaPlayerPrivateAVFoundation::seek(%p) - seeking to %s", this, toString(time).utf8().data());

    seekToTime(time, negativeTolerance, positiveTolerance);
}
示例#2
0
 void workForChunk(int chunk, float pts)
 {
     if (chunk == 8)
     {
         seekToTime(pts);
     }
 }
void MediaPlayerPrivateAVFoundation::seekWithTolerance(double time, double negativeTolerance, double positiveTolerance)
{
    if (m_seeking) {
        LOG(Media, "MediaPlayerPrivateAVFoundation::seekWithTolerance(%p) - save pending seek", this);
        m_pendingSeek = [this, time, negativeTolerance, positiveTolerance]() {
            seekWithTolerance(time, negativeTolerance, positiveTolerance);
        };
        return;
    }
    m_seeking = true;

    if (!metaDataAvailable())
        return;

    if (time > duration())
        time = duration();

    if (currentTime() == time)
        return;

    if (currentTrack())
        currentTrack()->beginSeeking();
    
    LOG(Media, "MediaPlayerPrivateAVFoundation::seek(%p) - seeking to %f", this, time);

    seekToTime(time, negativeTolerance, positiveTolerance);
}
void MediaPlayerPrivateAVFoundation::seek(float time)
{
    LOG(Media, "MediaPlayerPrivateAVFoundation::seek(%p) - seeking to %f", this, time);
    if (!metaDataAvailable())
        return;

    if (time > duration())
        time = duration();

    m_seekTo = time;

    seekToTime(time);
}
示例#5
0
void LadybugWidget::keyPressEvent(QKeyEvent* e)
{
  if (e->key() >= Qt::Key_1 && e->key() <= Qt::Key_5)
  {
    int i = e->key()-Qt::Key_1;

    // invert camera on/off setting
    setCameraState(i, !cameraState(i));

    if (mPaused)
      updateVideo(getSingleFrame(mCurrentFrame));
  }

  switch (e->key())
  {
    case Qt::Key_Space:
      pause();
      break;
    case Qt::Key_Left:
      seekToFrame(mCurrentFrame-1);
      break;
    case Qt::Key_Right:
      seekToFrame(mCurrentFrame+1);
      break;
    case Qt::Key_Home:
      seekToFrame(0);
      break;
    case Qt::Key_End:
      seekToFrame(mStream.framesCount()-1);
      break;
    case Qt::Key_PageUp:
      seekToFrame(mCurrentFrame-25);
      break;
    case Qt::Key_PageDown:
      seekToFrame(mCurrentFrame+25);
      break;

    // %%% seek to random position (for testing)
    case Qt::Key_S:
      {
        uint msecs = rand() % (mStream.framesCount() / 15 * 1000);
        printf("RANDOM TIME SEEK! %d ms\n", msecs);
        seekToTime(msecs);
        break;
      }
  }
}
void MediaPlayerPrivateAVFoundation::seekWithTolerance(double time, double negativeTolerance, double positiveTolerance)
{
    if (!metaDataAvailable())
        return;

    if (time > duration())
        time = duration();

    if (currentTime() == time)
        return;

    if (currentTrack())
        currentTrack()->beginSeeking();
    
    LOG(Media, "MediaPlayerPrivateAVFoundation::seek(%p) - seeking to %f", this, time);
    m_seekTo = time;

    ++m_seekCount;
    seekToTime(time, negativeTolerance, positiveTolerance);
}
示例#7
0
 void workForChunk(int chunk, float pts)
 {
     if (chunk == 1)
     {
         bool gotFrame = seekToTime(pts);
     }
     if (chunk == 2)
     {
         decoder.frameToRGB(rgb);
     }
     else if (chunk == 3)
     {
         colormap_from_rgb(colormap, rgb, 320, 200, c64_colors);
     }
     else if (chunk == 4)
     {
         bitmap_from_rgb(bitmap, rgb, colormap, mod_rgb, 320, 200, c64_colors);
     }
     else if (chunk == 8)
     {
         create_c64_bitmap(c64_bitmap, bitmap, 320, 200);
     }
 }
示例#8
0
void MediaPlayerPrivateAVFoundation::seek(float time)
{
    if (!metaDataAvailable())
        return;

    if (time > duration())
        time = duration();

    if (currentTime() == time)
        return;

#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
    // Forget any partially accumulated cue data as the seek could be to a time outside of the cue's
    // range, which will mean that the next cue delivered will result in the current cue getting the
    // incorrect duration.
    if (currentTrack())
        currentTrack()->resetCueValues();
#endif
    
    LOG(Media, "MediaPlayerPrivateAVFoundation::seek(%p) - seeking to %f", this, time);
    m_seekTo = time;

    seekToTime(time);
}