本文整理了Java中com.google.android.exoplayer2.util.Util
类的一些代码示例,展示了Util
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util
类的具体详情如下:
包路径:com.google.android.exoplayer2.util.Util
类名称:Util
[英]Miscellaneous utility methods.
[中]各种实用方法。
代码示例来源:origin: google/ExoPlayer
public PlayerManager(Context context) {
String adTag = context.getString(R.string.ad_tag_url);
adsLoader = new ImaAdsLoader(context, Uri.parse(adTag));
dataSourceFactory =
new DefaultDataSourceFactory(
context, Util.getUserAgent(context, context.getString(R.string.application_name)));
}
代码示例来源:origin: google/ExoPlayer
/**
* Makes a best guess to infer the type from a {@link Uri}.
*
* @param uri The {@link Uri}.
* @param overrideExtension If not null, used to infer the type.
* @return The content type.
*/
@C.ContentType
public static int inferContentType(Uri uri, String overrideExtension) {
return TextUtils.isEmpty(overrideExtension)
? inferContentType(uri)
: inferContentType("." + overrideExtension);
}
代码示例来源:origin: google/ExoPlayer
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
CommentFrame other = (CommentFrame) obj;
return Util.areEqual(description, other.description) && Util.areEqual(language, other.language)
&& Util.areEqual(text, other.text);
}
代码示例来源:origin: google/ExoPlayer
/**
* Adjusts ClearKey request data obtained from the Android ClearKey CDM to be spec compliant.
*
* @param request The request data.
* @return The adjusted request data.
*/
public static byte[] adjustRequestData(byte[] request) {
if (Util.SDK_INT >= 27) {
return request;
}
// Prior to O-MR1 the ClearKey CDM encoded the values in the "kids" array using Base64 encoding
// rather than Base64Url encoding. See [Internal: b/64388098]. We know the exact request format
// from the platform's InitDataParser.cpp. Since there aren't any "+" or "/" symbols elsewhere
// in the request, it's safe to fix the encoding by replacement through the whole request.
String requestString = Util.fromUtf8Bytes(request);
return Util.getUtf8Bytes(base64ToBase64Url(requestString));
}
代码示例来源:origin: google/ExoPlayer
private static void setSampleDuration(byte[] subripSampleData, long durationUs,
String timecodeFormat, int endTimecodeOffset, long lastTimecodeValueScalingFactor,
byte[] emptyTimecode) {
byte[] timeCodeData;
if (durationUs == C.TIME_UNSET) {
timeCodeData = emptyTimecode;
} else {
int hours = (int) (durationUs / (3600 * C.MICROS_PER_SECOND));
durationUs -= (hours * 3600 * C.MICROS_PER_SECOND);
int minutes = (int) (durationUs / (60 * C.MICROS_PER_SECOND));
durationUs -= (minutes * 60 * C.MICROS_PER_SECOND);
int seconds = (int) (durationUs / C.MICROS_PER_SECOND);
durationUs -= (seconds * C.MICROS_PER_SECOND);
int lastValue = (int) (durationUs / lastTimecodeValueScalingFactor);
timeCodeData = Util.getUtf8Bytes(String.format(Locale.US, timecodeFormat, hours, minutes,
seconds, lastValue));
}
System.arraycopy(timeCodeData, 0, subripSampleData, endTimecodeOffset, emptyTimecode.length);
}
代码示例来源:origin: google/ExoPlayer
public WebvttCssStyle setFontFamily(String fontFamily) {
this.fontFamily = Util.toLowerInvariant(fontFamily);
return this;
}
代码示例来源:origin: google/ExoPlayer
/**
* Returns the index of the chunk that contains the specified time.
*
* @param timeUs The time in microseconds.
* @return The index of the corresponding chunk.
*/
public int getChunkIndex(long timeUs) {
return Util.binarySearchFloor(chunkStartTimesUs, timeUs, true, true);
}
代码示例来源:origin: google/ExoPlayer
return new Point(3840, 2160);
} else if (("NVIDIA".equals(Util.MANUFACTURER) && Util.MODEL.contains("SHIELD"))
|| ("philips".equals(Util.toLowerInvariant(Util.MANUFACTURER))
&& (Util.MODEL.startsWith("QM1")
|| Util.MODEL.equals("QV151E")
String[] sysDisplaySizeParts = split(sysDisplaySize.trim(), "x");
if (sysDisplaySizeParts.length == 2) {
int width = Integer.parseInt(sysDisplaySizeParts[0]);
getDisplaySizeV23(display, displaySize);
} else if (Util.SDK_INT >= 17) {
getDisplaySizeV17(display, displaySize);
} else if (Util.SDK_INT >= 16) {
getDisplaySizeV16(display, displaySize);
} else {
getDisplaySizeV9(display, displaySize);
代码示例来源:origin: google/ExoPlayer
return null;
codec = Util.toLowerInvariant(codec.trim());
if (codec.startsWith("avc1") || codec.startsWith("avc3")) {
return MimeTypes.VIDEO_H264;
if (objectTypeString.length() >= 2) {
try {
String objectTypeHexString = Util.toUpperInvariant(objectTypeString.substring(0, 2));
int objectTypeInt = Integer.parseInt(objectTypeHexString, 16);
mimeType = getMimeTypeFromMp4ObjectType(objectTypeInt);
代码示例来源:origin: google/ExoPlayer
private static void assertParseStringToLong(
long expected, ParsingLoadable.Parser<Long> parser, String data) throws IOException {
long actual = parser.parse(null, new ByteArrayInputStream(Util.getUtf8Bytes(data)));
assertThat(actual).isEqualTo(expected);
}
}
代码示例来源:origin: google/ExoPlayer
/**
* Parses the number of channels from the value attribute of an AudioElementConfiguration with
* schemeIdUri "tag:dolby.com,2014:dash:audio_channel_configuration:2011", as defined by table E.5
* in ETSI TS 102 366.
*
* @param xpp The parser from which to read.
* @return The parsed number of channels, or {@link Format#NO_VALUE} if the channel count could
* not be parsed.
*/
protected static int parseDolbyChannelConfiguration(XmlPullParser xpp) {
String value = Util.toLowerInvariant(xpp.getAttributeValue(null, "value"));
if (value == null) {
return Format.NO_VALUE;
}
switch (value) {
case "4000":
return 1;
case "a000":
return 2;
case "f801":
return 6;
case "fa01":
return 8;
default:
return Format.NO_VALUE;
}
}
代码示例来源:origin: google/ExoPlayer
/**
* Obtains the index of the chunk corresponding to a given time.
*
* @param timeUs The time, in microseconds.
* @return The index of the corresponding chunk.
*/
public int getChunkIndex(long timeUs) {
return Util.binarySearchFloor(timesUs, timeUs, true, true);
}
代码示例来源:origin: CarGuo/GSYVideoPlayer
private DataSource.Factory getHttpDataSourceFactory(Context context, boolean preview) {
DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(context,
TAG), preview ? null : new DefaultBandwidthMeter());
if (mMapHeadData != null && mMapHeadData.size() > 0) {
for (Map.Entry<String, String> header : mMapHeadData.entrySet()) {
dataSourceFactory.getDefaultRequestProperties().set(header.getKey(), header.getValue());
}
}
return dataSourceFactory;
}
代码示例来源:origin: google/ExoPlayer
/**
* Makes a best guess to infer the type from a {@link Uri}.
*
* @param uri The {@link Uri}.
* @return The content type.
*/
@C.ContentType
public static int inferContentType(Uri uri) {
String path = uri.getPath();
return path == null ? C.TYPE_OTHER : inferContentType(path);
}
代码示例来源:origin: google/ExoPlayer
@Override
public boolean equals(@Nullable Object obj) {
if (!(obj instanceof SchemeData)) {
return false;
}
if (obj == this) {
return true;
}
SchemeData other = (SchemeData) obj;
return Util.areEqual(licenseServerUrl, other.licenseServerUrl)
&& Util.areEqual(mimeType, other.mimeType)
&& Util.areEqual(uuid, other.uuid)
&& Arrays.equals(data, other.data);
}
代码示例来源:origin: google/ExoPlayer
@Config(sdk = 26)
@Test
public void testAdjustRequestDataV26() {
// We expect "+" and "/" to be replaced with "-" and "_" respectively, for "kids".
byte[] expected =
Util.getUtf8Bytes(
"{"
+ "\"kids\":["
+ "\"abc-def_\","
+ "\"ab-cde_f\""
+ "],"
+ "\"type\":\"temporary\""
+ "}");
assertThat(ClearKeyUtil.adjustRequestData(KEY_REQUEST)).isEqualTo(expected);
}
代码示例来源:origin: google/ExoPlayer
/**
* Derives a DRM {@link UUID} from {@code drmScheme}.
*
* @param drmScheme A UUID string, or {@code "widevine"}, {@code "playready"} or {@code
* "clearkey"}.
* @return The derived {@link UUID}, or {@code null} if one could not be derived.
*/
public static @Nullable UUID getDrmUuid(String drmScheme) {
switch (Util.toLowerInvariant(drmScheme)) {
case "widevine":
return C.WIDEVINE_UUID;
case "playready":
return C.PLAYREADY_UUID;
case "clearkey":
return C.CLEARKEY_UUID;
default:
try {
return UUID.fromString(drmScheme);
} catch (RuntimeException e) {
return null;
}
}
}
代码示例来源:origin: google/ExoPlayer
@Override
protected int getChildIndexByPeriodIndex(int periodIndex) {
return Util.binarySearchFloor(firstPeriodInChildIndices, periodIndex + 1, false, false);
}
代码示例来源:origin: lipangit/JiaoZiVideoPlayer
Util.getUserAgent(context, context.getResources().getString(R.string.app_name)));
代码示例来源:origin: CarGuo/GSYVideoPlayer
@C.ContentType
public static int inferContentType(Uri uri, @Nullable String overrideExtension) {
return Util.inferContentType(uri, overrideExtension);
}
内容来源于网络,如有侵权,请联系作者删除!