Formatting tweaks for enhanced ID3 support + support in demo app.
This commit is contained in:
parent
0c6566bce7
commit
b9addf28b2
@ -26,6 +26,8 @@ import com.google.android.exoplayer.demo.player.DemoPlayer.RendererBuilder;
|
||||
import com.google.android.exoplayer.demo.player.HlsRendererBuilder;
|
||||
import com.google.android.exoplayer.demo.player.SmoothStreamingRendererBuilder;
|
||||
import com.google.android.exoplayer.demo.player.UnsupportedDrmException;
|
||||
import com.google.android.exoplayer.metadata.GeobMetadata;
|
||||
import com.google.android.exoplayer.metadata.PrivMetadata;
|
||||
import com.google.android.exoplayer.metadata.TxxxMetadata;
|
||||
import com.google.android.exoplayer.text.CaptionStyleCompat;
|
||||
import com.google.android.exoplayer.text.SubtitleView;
|
||||
@ -446,11 +448,22 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
|
||||
|
||||
@Override
|
||||
public void onId3Metadata(Map<String, Object> metadata) {
|
||||
for (int i = 0; i < metadata.size(); i++) {
|
||||
if (metadata.containsKey(TxxxMetadata.TYPE)) {
|
||||
TxxxMetadata txxxMetadata = (TxxxMetadata) metadata.get(TxxxMetadata.TYPE);
|
||||
Log.i(TAG, String.format("ID3 TimedMetadata: description=%s, value=%s",
|
||||
txxxMetadata.description, txxxMetadata.value));
|
||||
for (Map.Entry<String, Object> entry : metadata.entrySet()) {
|
||||
if (TxxxMetadata.TYPE.equals(entry.getKey())) {
|
||||
TxxxMetadata txxxMetadata = (TxxxMetadata) entry.getValue();
|
||||
Log.i(TAG, String.format("ID3 TimedMetadata %s: description=%s, value=%s",
|
||||
TxxxMetadata.TYPE, txxxMetadata.description, txxxMetadata.value));
|
||||
} else if (PrivMetadata.TYPE.equals(entry.getKey())) {
|
||||
PrivMetadata privMetadata = (PrivMetadata) entry.getValue();
|
||||
Log.i(TAG, String.format("ID3 TimedMetadata %s: owner=%s",
|
||||
PrivMetadata.TYPE, privMetadata.owner));
|
||||
} else if (GeobMetadata.TYPE.equals(entry.getKey())) {
|
||||
GeobMetadata geobMetadata = (GeobMetadata) entry.getValue();
|
||||
Log.i(TAG, String.format("ID3 TimedMetadata %s: mimeType=%s, filename=%s, description=%s",
|
||||
GeobMetadata.TYPE, geobMetadata.mimeType, geobMetadata.filename,
|
||||
geobMetadata.description));
|
||||
} else {
|
||||
Log.i(TAG, String.format("ID3 TimedMetadata %s", entry.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,9 +123,8 @@ import java.util.Locale;
|
||||
new Sample("Apple AAC media playlist",
|
||||
"https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear0/"
|
||||
+ "prog_index.m3u8", DemoUtil.TYPE_HLS),
|
||||
new Sample("Apple ID3 metadata",
|
||||
"http://devimages.apple.com/samplecode/adDemo/"
|
||||
+ "ad.m3u8", DemoUtil.TYPE_HLS),
|
||||
new Sample("Apple ID3 metadata", "http://devimages.apple.com/samplecode/adDemo/ad.m3u8",
|
||||
DemoUtil.TYPE_HLS),
|
||||
};
|
||||
|
||||
public static final Sample[] MISC = new Sample[] {
|
||||
|
@ -100,8 +100,8 @@ public class Id3Parser implements MetadataParser<Map<String, Object>> {
|
||||
String description = new String(frame, descriptionStartIndex,
|
||||
descriptionEndIndex - descriptionStartIndex, charset);
|
||||
|
||||
int objectDataSize = frameSize - 1 /* encoding byte */ - descriptionEndIndex -
|
||||
delimiterLength(encoding);
|
||||
int objectDataSize = frameSize - 1 /* encoding byte */ - descriptionEndIndex
|
||||
- delimiterLength(encoding);
|
||||
byte[] objectData = new byte[objectDataSize];
|
||||
System.arraycopy(frame, descriptionEndIndex + delimiterLength(encoding), objectData, 0,
|
||||
objectDataSize);
|
||||
@ -133,13 +133,13 @@ public class Id3Parser implements MetadataParser<Map<String, Object>> {
|
||||
int terminationPos = indexOf(data, fromIndex, (byte) 0);
|
||||
|
||||
// For single byte encoding charsets, we are done
|
||||
if(encodingByte == ID3_TEXT_ENCODING_ISO_8859_1 || encodingByte == ID3_TEXT_ENCODING_UTF_8) {
|
||||
if (encodingByte == ID3_TEXT_ENCODING_ISO_8859_1 || encodingByte == ID3_TEXT_ENCODING_UTF_8) {
|
||||
return terminationPos;
|
||||
}
|
||||
|
||||
// Otherwise, look for a two zero bytes
|
||||
while(terminationPos < data.length - 1) {
|
||||
if(data[terminationPos + 1] == (byte) 0) {
|
||||
while (terminationPos < data.length - 1) {
|
||||
if (data[terminationPos + 1] == (byte) 0) {
|
||||
return terminationPos;
|
||||
}
|
||||
terminationPos = indexOf(data, terminationPos + 1, (byte) 0);
|
||||
@ -149,8 +149,8 @@ public class Id3Parser implements MetadataParser<Map<String, Object>> {
|
||||
}
|
||||
|
||||
private static int delimiterLength(int encodingByte) {
|
||||
return (encodingByte == ID3_TEXT_ENCODING_ISO_8859_1 ||
|
||||
encodingByte == ID3_TEXT_ENCODING_UTF_8) ? 1 : 2;
|
||||
return (encodingByte == ID3_TEXT_ENCODING_ISO_8859_1
|
||||
|| encodingByte == ID3_TEXT_ENCODING_UTF_8) ? 1 : 2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user