mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Resolve locale warnings in EventLogger
Use string concatenation for Metadata.Entry instances, and add Util.formatInvariant for numerical formatting. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=190915643
This commit is contained in:
parent
39e4112e8f
commit
f634b1d4d8
12 changed files with 79 additions and 61 deletions
|
|
@ -92,6 +92,8 @@ public final class Metadata implements Parcelable {
|
|||
return Arrays.hashCode(entries);
|
||||
}
|
||||
|
||||
// Parcelable implementation.
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -117,6 +117,11 @@ public final class EventMessage implements Metadata.Entry {
|
|||
&& Util.areEqual(value, other.value) && Arrays.equals(messageData, other.messageData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EMSG: scheme=" + schemeIdUri + ", id=" + id + ", value=" + value;
|
||||
}
|
||||
|
||||
// Parcelable implementation.
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -72,6 +72,13 @@ public final class ApicFrame extends Id3Frame {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id + ": mimeType=" + mimeType + ", description=" + description;
|
||||
}
|
||||
|
||||
// Parcelable implementation.
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(mimeType);
|
||||
|
|
|
|||
|
|
@ -66,6 +66,13 @@ public final class CommentFrame extends Id3Frame {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id + ": language=" + language + ", description=" + description;
|
||||
}
|
||||
|
||||
// Parcelable implementation.
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(id);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,19 @@ public final class GeobFrame extends Id3Frame {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id
|
||||
+ ": mimeType="
|
||||
+ mimeType
|
||||
+ ", filename="
|
||||
+ filename
|
||||
+ ", description="
|
||||
+ description;
|
||||
}
|
||||
|
||||
// Parcelable implementation.
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(mimeType);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,11 @@ public abstract class Id3Frame implements Metadata.Entry {
|
|||
this.id = Assertions.checkNotNull(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,12 @@ public final class PrivFrame extends Id3Frame {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id + ": owner=" + owner;
|
||||
}
|
||||
// Parcelable implementation.
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(owner);
|
||||
|
|
|
|||
|
|
@ -61,6 +61,13 @@ public final class TextInformationFrame extends Id3Frame {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id + ": value=" + value;
|
||||
}
|
||||
|
||||
// Parcelable implementation.
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(id);
|
||||
|
|
|
|||
|
|
@ -61,6 +61,13 @@ public final class UrlLinkFrame extends Id3Frame {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id + ": url=" + url;
|
||||
}
|
||||
|
||||
// Parcelable implementation.
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(id);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,13 @@ import com.google.android.exoplayer2.metadata.Metadata;
|
|||
*/
|
||||
public abstract class SpliceCommand implements Metadata.Entry {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SCTE-35 splice command: type=" + getClass().getSimpleName();
|
||||
}
|
||||
|
||||
// Parcelable implementation.
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -31,15 +31,6 @@ import com.google.android.exoplayer2.decoder.DecoderCounters;
|
|||
import com.google.android.exoplayer2.drm.DefaultDrmSessionEventListener;
|
||||
import com.google.android.exoplayer2.metadata.Metadata;
|
||||
import com.google.android.exoplayer2.metadata.MetadataOutput;
|
||||
import com.google.android.exoplayer2.metadata.emsg.EventMessage;
|
||||
import com.google.android.exoplayer2.metadata.id3.ApicFrame;
|
||||
import com.google.android.exoplayer2.metadata.id3.CommentFrame;
|
||||
import com.google.android.exoplayer2.metadata.id3.GeobFrame;
|
||||
import com.google.android.exoplayer2.metadata.id3.Id3Frame;
|
||||
import com.google.android.exoplayer2.metadata.id3.PrivFrame;
|
||||
import com.google.android.exoplayer2.metadata.id3.TextInformationFrame;
|
||||
import com.google.android.exoplayer2.metadata.id3.UrlLinkFrame;
|
||||
import com.google.android.exoplayer2.metadata.scte35.SpliceCommand;
|
||||
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
||||
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
||||
import com.google.android.exoplayer2.source.TrackGroup;
|
||||
|
|
@ -123,9 +114,9 @@ public class EventLogger
|
|||
@Override
|
||||
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
|
||||
logd(
|
||||
"playbackParameters "
|
||||
+ String.format(
|
||||
"[speed=%.2f, pitch=%.2f]", playbackParameters.speed, playbackParameters.pitch));
|
||||
Util.formatInvariant(
|
||||
"playbackParameters [speed=%.2f, pitch=%.2f]",
|
||||
playbackParameters.speed, playbackParameters.pitch));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -476,55 +467,7 @@ public class EventLogger
|
|||
|
||||
private void printMetadata(Metadata metadata, String prefix) {
|
||||
for (int i = 0; i < metadata.length(); i++) {
|
||||
Metadata.Entry entry = metadata.get(i);
|
||||
if (entry instanceof TextInformationFrame) {
|
||||
TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
|
||||
logd(
|
||||
prefix
|
||||
+ String.format(
|
||||
"%s: value=%s", textInformationFrame.id, textInformationFrame.value));
|
||||
} else if (entry instanceof UrlLinkFrame) {
|
||||
UrlLinkFrame urlLinkFrame = (UrlLinkFrame) entry;
|
||||
logd(prefix + String.format("%s: url=%s", urlLinkFrame.id, urlLinkFrame.url));
|
||||
} else if (entry instanceof PrivFrame) {
|
||||
PrivFrame privFrame = (PrivFrame) entry;
|
||||
logd(prefix + String.format("%s: owner=%s", privFrame.id, privFrame.owner));
|
||||
} else if (entry instanceof GeobFrame) {
|
||||
GeobFrame geobFrame = (GeobFrame) entry;
|
||||
logd(
|
||||
prefix
|
||||
+ String.format(
|
||||
"%s: mimeType=%s, filename=%s, description=%s",
|
||||
geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description));
|
||||
} else if (entry instanceof ApicFrame) {
|
||||
ApicFrame apicFrame = (ApicFrame) entry;
|
||||
logd(
|
||||
prefix
|
||||
+ String.format(
|
||||
"%s: mimeType=%s, description=%s",
|
||||
apicFrame.id, apicFrame.mimeType, apicFrame.description));
|
||||
} else if (entry instanceof CommentFrame) {
|
||||
CommentFrame commentFrame = (CommentFrame) entry;
|
||||
logd(
|
||||
prefix
|
||||
+ String.format(
|
||||
"%s: language=%s, description=%s",
|
||||
commentFrame.id, commentFrame.language, commentFrame.description));
|
||||
} else if (entry instanceof Id3Frame) {
|
||||
Id3Frame id3Frame = (Id3Frame) entry;
|
||||
logd(prefix + id3Frame.id);
|
||||
} else if (entry instanceof EventMessage) {
|
||||
EventMessage eventMessage = (EventMessage) entry;
|
||||
logd(
|
||||
prefix
|
||||
+ String.format(
|
||||
"EMSG: scheme=%s, id=%d, value=%s",
|
||||
eventMessage.schemeIdUri, eventMessage.id, eventMessage.value));
|
||||
} else if (entry instanceof SpliceCommand) {
|
||||
String description =
|
||||
String.format("SCTE-35 splice command: type=%s.", entry.getClass().getSimpleName());
|
||||
logd(prefix + description);
|
||||
}
|
||||
logd(prefix + metadata.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -329,6 +329,15 @@ public final class Util {
|
|||
return text == null ? null : text.toLowerCase(Locale.US);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a string using {@link Locale#US}.
|
||||
*
|
||||
* @see String#format(String, Object...)
|
||||
*/
|
||||
public static String formatInvariant(String format, Object... args) {
|
||||
return String.format(Locale.US, format, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Divides a {@code numerator} by a {@code denominator}, returning the ceiled result.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue