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


Java Util类代码示例

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


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

示例1: buildMediaSource

import com.google.android.exoplayer2.util.Util; //导入依赖的package包/类
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
            : uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, null);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
 
开发者ID:12d,项目名称:react-native-videoplayer,代码行数:21,代码来源:ReactExoplayerView.java

示例2: open

import com.google.android.exoplayer2.util.Util; //导入依赖的package包/类
@Override
public long open(DataSpec dataSpec) throws IOException {
    Assertions.checkState(dataSource == null);
    String scheme = dataSpec.uri.getScheme();
    if (Util.isLocalFileUri(dataSpec.uri)) {
        if (dataSpec.uri.getPath().startsWith("/android_asset/")) {
            dataSource = getAssetDataSource();
        } else {
            dataSource = getFileDataSource();
        }
    } else if (SCHEME_ASSET.equals(scheme)) {
        dataSource = getAssetDataSource();
    } else if (SCHEME_CONTENT.equals(scheme)) {
        dataSource = getContentDataSource();
    } else if (SCHEME_RTMP.equals(scheme)) {
        dataSource = getRtmpDataSource();
    } else {
        dataSource = baseDataSource;
    }
    // Open the source and return.
    return dataSource.open(dataSpec);
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:23,代码来源:MyDefaultDataSource.java

示例3: buildMediaSource

import com.google.android.exoplayer2.util.Util; //导入依赖的package包/类
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
	DataSource.Factory mediaDataSourceFactory = buildDataSourceFactory(true);
	int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri)
			: Util.inferContentType("." + overrideExtension);
	switch (type) {
		case C.TYPE_SS:
			return new SsMediaSource(uri, buildDataSourceFactory(false),
					new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
		case C.TYPE_DASH:
			return new DashMediaSource(uri, buildDataSourceFactory(false),
					new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
		case C.TYPE_HLS:
			return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, null);
		case C.TYPE_OTHER:
			return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
					mainHandler, null);
		default: {
			throw new IllegalStateException("Unsupported type: " + type);
		}
	}
}
 
开发者ID:NiciDieNase,项目名称:chaosflix,代码行数:22,代码来源:PlayerActivity.java

示例4: onInitializeAccessibilityNodeInfo

import com.google.android.exoplayer2.util.Util; //导入依赖的package包/类
@TargetApi(21)
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setClassName(com.google.android.exoplayer2.ui.DefaultTimeBar.class.getCanonicalName());
    info.setContentDescription(getProgressText());
    if (duration <= 0) {
        return;
    }
    if (Util.SDK_INT >= 21) {
        info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD);
        info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD);
    } else if (Util.SDK_INT >= 16) {
        info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
        info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
    }
}
 
开发者ID:rubensousa,项目名称:PreviewSeekBar,代码行数:18,代码来源:CustomTimeBar.java

示例5: 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

示例6: 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

示例7: doInBackground

import com.google.android.exoplayer2.util.Util; //导入依赖的package包/类
@Override
protected List<SampleGroup> doInBackground(String... uris) {
  List<SampleGroup> result = new ArrayList<>();
  Context context = getApplicationContext();
  String userAgent = Util.getUserAgent(context, "ExoPlayerDemo");
  DataSource dataSource = new DefaultDataSource(context, null, userAgent, false);
  for (String uri : uris) {
    DataSpec dataSpec = new DataSpec(Uri.parse(uri));
    InputStream inputStream = new DataSourceInputStream(dataSource, dataSpec);
    try {
      readSampleGroups(new JsonReader(new InputStreamReader(inputStream, "UTF-8")), result);
    } catch (Exception e) {
      Log.e(TAG, "Error loading sample list: " + uri, e);
      sawError = true;
    } finally {
      Util.closeQuietly(dataSource);
    }
  }
  return result;
}
 
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:21,代码来源:SampleChooserActivity.java

示例8: 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

示例9: buildMediaSource

import com.google.android.exoplayer2.util.Util; //导入依赖的package包/类
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
            : uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, eventLogger);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
 
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:21,代码来源:PlayerActivity.java

示例10: load

import com.google.android.exoplayer2.util.Util; //导入依赖的package包/类
@Override
public final void load() throws IOException, InterruptedException {
  try {
    dataSource.open(dataSpec);
    limit = 0;
    int bytesRead = 0;
    while (bytesRead != C.RESULT_END_OF_INPUT && !loadCanceled) {
      maybeExpandData();
      bytesRead = dataSource.read(data, limit, READ_GRANULARITY);
      if (bytesRead != -1) {
        limit += bytesRead;
      }
    }
    if (!loadCanceled) {
      consume(data, limit);
    }
  } finally {
    Util.closeQuietly(dataSource);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:21,代码来源:DataChunk.java

示例11: getMaxVideoSizeInViewport

import com.google.android.exoplayer2.util.Util; //导入依赖的package包/类
/**
 * Given viewport dimensions and video dimensions, computes the maximum size of the video as it
 * will be rendered to fit inside of the viewport.
 */
private static Point getMaxVideoSizeInViewport(boolean orientationMayChange, int viewportWidth,
    int viewportHeight, int videoWidth, int videoHeight) {
  if (orientationMayChange && (videoWidth > videoHeight) != (viewportWidth > viewportHeight)) {
    // Rotation is allowed, and the video will be larger in the rotated viewport.
    int tempViewportWidth = viewportWidth;
    viewportWidth = viewportHeight;
    viewportHeight = tempViewportWidth;
  }

  if (videoWidth * viewportHeight >= videoHeight * viewportWidth) {
    // Horizontal letter-boxing along top and bottom.
    return new Point(viewportWidth, Util.ceilDivide(viewportWidth * videoHeight, videoWidth));
  } else {
    // Vertical letter-boxing along edges.
    return new Point(Util.ceilDivide(viewportHeight * videoWidth, videoHeight), viewportHeight);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:22,代码来源:DefaultTrackSelector.java

示例12: initializePlayer

import com.google.android.exoplayer2.util.Util; //导入依赖的package包/类
private void initializePlayer(Uri videoUri){
    if (mExoPlayer == null){
        TrackSelector trackSelector = new DefaultTrackSelector();
        LoadControl loadControl = new DefaultLoadControl();
        mExoPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, loadControl);
        mExoPlayer.addListener(this);
        mExoPlayer.seekTo(currentPosition);
        mPlayerView.setPlayer(mExoPlayer);
        String userAgent = Util.getUserAgent(getContext(), "Tasty");
        MediaSource mediaSource = new ExtractorMediaSource(videoUri, new DefaultDataSourceFactory(
                getContext(), userAgent), new DefaultExtractorsFactory(), null, null);
        mExoPlayer.prepare(mediaSource);
        if (playWhenReady) mExoPlayer.setPlayWhenReady(true);
        else mExoPlayer.setPlayWhenReady(false);
    }
}
 
开发者ID:harrynp,项目名称:BakingApp,代码行数:17,代码来源:StepDetailFragment.java

示例13: getTimeUs

import com.google.android.exoplayer2.util.Util; //导入依赖的package包/类
@Override
public long getTimeUs(long position) {
  if (!isSeekable() || position < firstFramePosition) {
    return 0L;
  }
  double offsetByte = 256.0 * (position - firstFramePosition) / sizeBytes;
  int previousTocPosition =
      Util.binarySearchFloor(tableOfContents, (long) offsetByte, true, false) + 1;
  long previousTime = getTimeUsForTocPosition(previousTocPosition);

  // Linearly interpolate the time taking into account the next entry.
  long previousByte = previousTocPosition == 0 ? 0 : tableOfContents[previousTocPosition - 1];
  long nextByte = previousTocPosition == 99 ? 256 : tableOfContents[previousTocPosition];
  long nextTime = getTimeUsForTocPosition(previousTocPosition + 1);
  long timeOffset = nextByte == previousByte ? 0 : (long) ((nextTime - previousTime)
      * (offsetByte - previousByte) / (nextByte - previousByte));
  return previousTime + timeOffset;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:19,代码来源:XingSeeker.java

示例14: testWidevineOfflineLicense

import com.google.android.exoplayer2.util.Util; //导入依赖的package包/类
public void testWidevineOfflineLicense() throws Exception {
  if (Util.SDK_INT < 22) {
    // Pass.
    return;
  }
  String streamName = "test_widevine_h264_fixed_offline";
  DashHostedTestEncParameters parameters = newDashHostedTestEncParameters(
      WIDEVINE_H264_MANIFEST_PREFIX, true, MimeTypes.VIDEO_H264);
  TestOfflineLicenseHelper helper = new TestOfflineLicenseHelper(parameters);
  try {
    byte[] keySetId = helper.downloadLicense();
    testDashPlayback(getActivity(), streamName, null, true, parameters,
        WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, false, keySetId, WIDEVINE_H264_CDD_FIXED);
    helper.renewLicense();
  } finally {
    helper.releaseResources();
  }
}
 
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:19,代码来源:DashTest.java

示例15: testWidevineOfflineLicenseExpiresOnPause

import com.google.android.exoplayer2.util.Util; //导入依赖的package包/类
public void testWidevineOfflineLicenseExpiresOnPause() throws Exception {
  if (Util.SDK_INT < 22) {
    // Pass.
    return;
  }
  String streamName = "test_widevine_h264_fixed_offline";
  DashHostedTestEncParameters parameters = newDashHostedTestEncParameters(
      WIDEVINE_H264_MANIFEST_PREFIX, true, MimeTypes.VIDEO_H264);
  TestOfflineLicenseHelper helper = new TestOfflineLicenseHelper(parameters);
  try {
    byte[] keySetId = helper.downloadLicense();
    // During playback pause until the license expires then continue playback
    Pair<Long, Long> licenseDurationRemainingSec = helper.getLicenseDurationRemainingSec();
    long licenseDuration = licenseDurationRemainingSec.first;
    assertTrue("License duration should be less than 30 sec. "
        + "Server settings might have changed.", licenseDuration < 30);
    ActionSchedule schedule = new ActionSchedule.Builder(TAG)
        .delay(3000).pause().delay(licenseDuration * 1000 + 2000).play().build();
    // DefaultDrmSessionManager should renew the license and stream play fine
    testDashPlayback(getActivity(), streamName, schedule, true, parameters,
        WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, false, keySetId, WIDEVINE_H264_CDD_FIXED);
  } finally {
    helper.releaseResources();
  }
}
 
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:26,代码来源:DashTest.java


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