当前位置: 首页>>代码示例>>Java>>正文


Java Util.constrainValue方法代码示例

本文整理汇总了Java中com.google.android.exoplayer2.util.Util.constrainValue方法的典型用法代码示例。如果您正苦于以下问题:Java Util.constrainValue方法的具体用法?Java Util.constrainValue怎么用?Java Util.constrainValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.exoplayer2.util.Util的用法示例。


在下文中一共展示了Util.constrainValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawPlayhead

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
private void drawPlayhead(Canvas canvas) {
  if (duration <= 0) {
    return;
  }
  int playheadX = Util.constrainValue(scrubberBar.right, scrubberBar.left, progressBar.right);
  int playheadY = scrubberBar.centerY();
  if (scrubberDrawable == null) {
    int scrubberSize = (scrubbing || isFocused()) ? scrubberDraggedSize
        : (isEnabled() ? scrubberEnabledSize : scrubberDisabledSize);
    int playheadRadius = scrubberSize / 2;
    canvas.drawCircle(playheadX, playheadY, playheadRadius, scrubberPaint);
  } else {
    int scrubberDrawableWidth = scrubberDrawable.getIntrinsicWidth();
    int scrubberDrawableHeight = scrubberDrawable.getIntrinsicHeight();
    scrubberDrawable.setBounds(
        playheadX - scrubberDrawableWidth / 2,
        playheadY - scrubberDrawableHeight / 2,
        playheadX + scrubberDrawableWidth / 2,
        playheadY + scrubberDrawableHeight / 2);
    scrubberDrawable.draw(canvas);
  }
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:23,代码来源:DefaultTimeBar.java

示例2: scrubIncrementally

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
/**
 * Incrementally scrubs the position by {@code positionChange}.
 *
 * @param positionChange The change in the scrubber position, in milliseconds. May be negative.
 * @return Returns whether the scrubber position changed.
 */
private boolean scrubIncrementally(long positionChange) {
  if (duration <= 0) {
    return false;
  }
  long scrubberPosition = getScrubberPosition();
  scrubPosition = Util.constrainValue(scrubberPosition + positionChange, 0, duration);
  if (scrubPosition == scrubberPosition) {
    return false;
  }
  if (!scrubbing) {
    startScrubbing();
  }
  for (OnScrubListener listener : listeners) {
    listener.onScrubMove(this, scrubPosition);
  }
  update();
  return true;
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:25,代码来源:DefaultTimeBar.java

示例3: drawPlayhead

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
private void drawPlayhead(Canvas canvas) {
    if (duration <= 0) {
        return;
    }
    int playheadX = Util.constrainValue(scrubberBar.right, scrubberBar.left, progressBar.right);
    int playheadY = scrubberBar.centerY();
    if (scrubberDrawable == null) {
        int scrubberSize = (scrubbing || isFocused()) ? scrubberDraggedSize
                : (isEnabled() ? scrubberEnabledSize : scrubberDisabledSize);
        int playheadRadius = scrubberSize / 2;
        canvas.drawCircle(playheadX, playheadY, playheadRadius, scrubberPaint);
    } else {
        int scrubberDrawableWidth = scrubberDrawable.getIntrinsicWidth();
        int scrubberDrawableHeight = scrubberDrawable.getIntrinsicHeight();
        scrubberDrawable.setBounds(
                playheadX - scrubberDrawableWidth / 2,
                playheadY - scrubberDrawableHeight / 2,
                playheadX + scrubberDrawableWidth / 2,
                playheadY + scrubberDrawableHeight / 2);
        scrubberDrawable.draw(canvas);
    }
}
 
开发者ID:rubensousa,项目名称:PreviewSeekBar,代码行数:23,代码来源:CustomTimeBar.java

示例4: scrubIncrementally

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
/**
 * Incrementally scrubs the position by {@code positionChange}.
 *
 * @param positionChange The change in the scrubber position, in milliseconds. May be negative.
 * @return Returns whether the scrubber position changed.
 */
private boolean scrubIncrementally(long positionChange) {
    if (duration <= 0) {
        return false;
    }
    long scrubberPosition = getScrubberPosition();
    scrubPosition = Util.constrainValue(scrubberPosition + positionChange, 0, duration);
    if (scrubPosition == scrubberPosition) {
        return false;
    }
    if (!scrubbing) {
        startScrubbing();
    }
    for (OnScrubListener listener : listeners) {
        listener.onScrubMove(this, scrubPosition);
    }
    update();
    return true;
}
 
开发者ID:rubensousa,项目名称:PreviewSeekBar,代码行数:25,代码来源:CustomTimeBar.java

示例5: scrubIncrementally

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
/**
 * Incrementally scrubs the position by {@code positionChange}.
 *
 * @param positionChange The change in the scrubber position, in milliseconds. May be negative.
 * @return Returns whether the scrubber position changed.
 */
private boolean scrubIncrementally(long positionChange) {
    if (duration <= 0) {
        return false;
    }
    long scrubberPosition = getScrubberPosition();
    scrubPosition = Util.constrainValue(scrubberPosition + positionChange, 0, duration);
    if (scrubPosition == scrubberPosition) {
        return false;
    }
    if (!scrubbing) {
        startScrubbing();
    }

    for (OnScrubListener listener : listeners) {
        listener.onScrubMove(this, scrubPosition);
    }
    update();
    return true;
}
 
开发者ID:hongcwamazing,项目名称:PreviewSeekBar-master,代码行数:26,代码来源:CustomTimeBar.java

示例6: drawTimeBar

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
private void drawTimeBar(Canvas canvas) {
  int progressBarHeight = progressBar.height();
  int barTop = progressBar.centerY() - progressBarHeight / 2;
  int barBottom = barTop + progressBarHeight;
  if (duration <= 0) {
    canvas.drawRect(progressBar.left, barTop, progressBar.right, barBottom, unplayedPaint);
    return;
  }
  int bufferedLeft = bufferedBar.left;
  int bufferedRight = bufferedBar.right;
  int progressLeft = Math.max(Math.max(progressBar.left, bufferedRight), scrubberBar.right);
  if (progressLeft < progressBar.right) {
    canvas.drawRect(progressLeft, barTop, progressBar.right, barBottom, unplayedPaint);
  }
  bufferedLeft = Math.max(bufferedLeft, scrubberBar.right);
  if (bufferedRight > bufferedLeft) {
    canvas.drawRect(bufferedLeft, barTop, bufferedRight, barBottom, bufferedPaint);
  }
  if (scrubberBar.width() > 0) {
    canvas.drawRect(scrubberBar.left, barTop, scrubberBar.right, barBottom, playedPaint);
  }
  int adMarkerOffset = adMarkerWidth / 2;
  for (int i = 0; i < adGroupCount; i++) {
    long adGroupTimeMs = Util.constrainValue(adGroupTimesMs[i], 0, duration);
    int markerPositionOffset =
        (int) (progressBar.width() * adGroupTimeMs / duration) - adMarkerOffset;
    int markerLeft = progressBar.left + Math.min(progressBar.width() - adMarkerWidth,
        Math.max(0, markerPositionOffset));
    Paint paint = playedAdGroups[i] ? playedAdMarkerPaint : adMarkerPaint;
    canvas.drawRect(markerLeft, barTop, markerLeft + adMarkerWidth, barBottom, paint);
  }
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:33,代码来源:DefaultTimeBar.java

示例7: drawTimeBar

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
private void drawTimeBar(Canvas canvas) {
    int progressBarHeight = progressBar.height();
    int barTop = progressBar.centerY() - progressBarHeight / 2;
    int barBottom = barTop + progressBarHeight;
    if (duration <= 0) {
        canvas.drawRect(progressBar.left, barTop, progressBar.right, barBottom, unplayedPaint);
        return;
    }
    int bufferedLeft = bufferedBar.left;
    int bufferedRight = bufferedBar.right;
    int progressLeft = Math.max(Math.max(progressBar.left, bufferedRight), scrubberBar.right);
    if (progressLeft < progressBar.right) {
        canvas.drawRect(progressLeft, barTop, progressBar.right, barBottom, unplayedPaint);
    }
    bufferedLeft = Math.max(bufferedLeft, scrubberBar.right);
    if (bufferedRight > bufferedLeft) {
        canvas.drawRect(bufferedLeft, barTop, bufferedRight, barBottom, bufferedPaint);
    }
    if (scrubberBar.width() > 0) {
        canvas.drawRect(scrubberBar.left, barTop, scrubberBar.right, barBottom, playedPaint);
    }
    int adMarkerOffset = adMarkerWidth / 2;
    for (int i = 0; i < adGroupCount; i++) {
        long adGroupTimeMs = Util.constrainValue(adGroupTimesMs[i], 0, duration);
        int markerPositionOffset =
                (int) (progressBar.width() * adGroupTimeMs / duration) - adMarkerOffset;
        int markerLeft = progressBar.left + Math.min(progressBar.width() - adMarkerWidth,
                Math.max(0, markerPositionOffset));
        Paint paint = playedAdGroups[i] ? playedAdMarkerPaint : adMarkerPaint;
        canvas.drawRect(markerLeft, barTop, markerLeft + adMarkerWidth, barBottom, paint);
    }
}
 
开发者ID:rubensousa,项目名称:PreviewSeekBar,代码行数:33,代码来源:CustomTimeBar.java

示例8: drawPlayhead

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
private void drawPlayhead(Canvas canvas) {
    if (duration <= 0) {
        return;
    }
    int scrubberSize = (scrubbing || isFocused()) ? scrubberDraggedSize
            : (isEnabled() ? scrubberEnabledSize : scrubberDisabledSize);
    int playheadRadius = scrubberSize / 2;
    int playheadCenter = Util.constrainValue(scrubberBar.right, scrubberBar.left,
            progressBar.right);
    canvas.drawCircle(playheadCenter, scrubberBar.centerY(), playheadRadius, scrubberPaint);
}
 
开发者ID:hongcwamazing,项目名称:PreviewSeekBar-master,代码行数:12,代码来源:CustomTimeBar.java

示例9: ensureSpaceForPeek

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
/**
 * Ensures {@code peekBuffer} is large enough to store at least {@code length} bytes from the
 * current peek position.
 */
private void ensureSpaceForPeek(int length) {
  int requiredLength = peekBufferPosition + length;
  if (requiredLength > peekBuffer.length) {
    int newPeekCapacity = Util.constrainValue(peekBuffer.length * 2,
        requiredLength + PEEK_MIN_FREE_SPACE_AFTER_RESIZE, requiredLength + PEEK_MAX_FREE_SPACE);
    peekBuffer = Arrays.copyOf(peekBuffer, newPeekCapacity);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:13,代码来源:DefaultExtractorInput.java

示例10: decodeInitializationData

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
private void decodeInitializationData(List<byte[]> initializationData) {
  if (initializationData != null && initializationData.size() == 1
      && (initializationData.get(0).length == 48 || initializationData.get(0).length == 53)) {
    byte[] initializationBytes = initializationData.get(0);
    defaultFontFace = initializationBytes[24];
    defaultColorRgba = ((initializationBytes[26] & 0xFF) << 24)
        | ((initializationBytes[27] & 0xFF) << 16)
        | ((initializationBytes[28] & 0xFF) << 8)
        | (initializationBytes[29] & 0xFF);
    String fontFamily = new String(initializationBytes, 43, initializationBytes.length - 43);
    defaultFontFamily = TX3G_SERIF.equals(fontFamily) ? C.SERIF_NAME : C.SANS_SERIF_NAME;
    //font size (initializationBytes[25]) is 5% of video height
    calculatedVideoTrackHeight = 20 * initializationBytes[25];
    customVerticalPlacement = (initializationBytes[0] & 0x20) != 0;
    if (customVerticalPlacement) {
      int requestedVerticalPlacement = ((initializationBytes[10] & 0xFF) << 8)
          | (initializationBytes[11] & 0xFF);
      defaultVerticalPlacement = (float) requestedVerticalPlacement / calculatedVideoTrackHeight;
      defaultVerticalPlacement = Util.constrainValue(defaultVerticalPlacement, 0.0f, 0.95f);
    } else {
      defaultVerticalPlacement = DEFAULT_VERTICAL_PLACEMENT;
    }
  } else {
    defaultFontFace = DEFAULT_FONT_FACE;
    defaultColorRgba = DEFAULT_COLOR;
    defaultFontFamily = DEFAULT_FONT_FAMILY;
    customVerticalPlacement = false;
    defaultVerticalPlacement = DEFAULT_VERTICAL_PLACEMENT;
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:31,代码来源:Tx3gDecoder.java

示例11: decode

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
@Override
protected Subtitle decode(byte[] bytes, int length, boolean reset)
    throws SubtitleDecoderException {
  parsableByteArray.reset(bytes, length);
  String cueTextString = readSubtitleText(parsableByteArray);
  if (cueTextString.isEmpty()) {
    return Tx3gSubtitle.EMPTY;
  }
  // Attach default styles.
  SpannableStringBuilder cueText = new SpannableStringBuilder(cueTextString);
  attachFontFace(cueText, defaultFontFace, DEFAULT_FONT_FACE, 0, cueText.length(),
      SPAN_PRIORITY_LOW);
  attachColor(cueText, defaultColorRgba, DEFAULT_COLOR, 0, cueText.length(),
      SPAN_PRIORITY_LOW);
  attachFontFamily(cueText, defaultFontFamily, DEFAULT_FONT_FAMILY, 0, cueText.length(),
      SPAN_PRIORITY_LOW);
  float verticalPlacement = defaultVerticalPlacement;
  // Find and attach additional styles.
  while (parsableByteArray.bytesLeft() >= SIZE_ATOM_HEADER) {
    int position = parsableByteArray.getPosition();
    int atomSize = parsableByteArray.readInt();
    int atomType = parsableByteArray.readInt();
    if (atomType == TYPE_STYL) {
      assertTrue(parsableByteArray.bytesLeft() >= SIZE_SHORT);
      int styleRecordCount = parsableByteArray.readUnsignedShort();
      for (int i = 0; i < styleRecordCount; i++) {
        applyStyleRecord(parsableByteArray, cueText);
      }
    } else if (atomType == TYPE_TBOX && customVerticalPlacement) {
      assertTrue(parsableByteArray.bytesLeft() >= SIZE_SHORT);
      int requestedVerticalPlacement = parsableByteArray.readUnsignedShort();
      verticalPlacement = (float) requestedVerticalPlacement / calculatedVideoTrackHeight;
      verticalPlacement = Util.constrainValue(verticalPlacement, 0.0f, 0.95f);
    }
    parsableByteArray.setPosition(position + atomSize);
  }
  return new Tx3gSubtitle(new Cue(cueText, null, verticalPlacement, Cue.LINE_TYPE_FRACTION,
      Cue.ANCHOR_TYPE_START, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.DIMEN_UNSET));
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:40,代码来源:Tx3gDecoder.java

示例12: positionScrubber

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
private void positionScrubber(float xPosition) {
  scrubberBar.right = Util.constrainValue((int) xPosition, progressBar.left, progressBar.right);
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:4,代码来源:DefaultTimeBar.java

示例13: positionScrubber

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
private void positionScrubber(float xPosition) {
    scrubberBar.right = Util.constrainValue((int) xPosition, progressBar.left, progressBar.right);
}
 
开发者ID:rubensousa,项目名称:PreviewSeekBar,代码行数:4,代码来源:CustomTimeBar.java

示例14: setSpeed

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
/**
 * Sets the playback speed. The new speed will take effect after a call to {@link #flush()}.
 *
 * @param speed The requested new playback speed.
 * @return The actual new playback speed.
 */
public float setSpeed(float speed) {
  this.speed = Util.constrainValue(speed, MINIMUM_SPEED, MAXIMUM_SPEED);
  return this.speed;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:11,代码来源:SonicAudioProcessor.java

示例15: setPitch

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
/**
 * Sets the playback pitch. The new pitch will take effect after a call to {@link #flush()}.
 *
 * @param pitch The requested new pitch.
 * @return The actual new pitch.
 */
public float setPitch(float pitch) {
  this.pitch = Util.constrainValue(pitch, MINIMUM_PITCH, MAXIMUM_PITCH);
  return pitch;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:11,代码来源:SonicAudioProcessor.java


注:本文中的com.google.android.exoplayer2.util.Util.constrainValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。