Fixed chapters of non-content uris
This commit is contained in:
parent
1800704ec2
commit
b1ef9f424f
|
@ -1,5 +1,6 @@
|
||||||
package de.danoeh.antennapod.core.util;
|
package de.danoeh.antennapod.core.util;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -13,6 +14,7 @@ import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -78,8 +80,13 @@ public class ChapterUtils {
|
||||||
Log.d(TAG, "Reading id3 chapters from item " + p.getEpisodeTitle());
|
Log.d(TAG, "Reading id3 chapters from item " + p.getEpisodeTitle());
|
||||||
CountingInputStream in = null;
|
CountingInputStream in = null;
|
||||||
try {
|
try {
|
||||||
|
if (p.getStreamUrl().startsWith(ContentResolver.SCHEME_CONTENT)) {
|
||||||
Uri uri = Uri.parse(p.getStreamUrl());
|
Uri uri = Uri.parse(p.getStreamUrl());
|
||||||
in = new CountingInputStream(context.getContentResolver().openInputStream(uri));
|
in = new CountingInputStream(context.getContentResolver().openInputStream(uri));
|
||||||
|
} else {
|
||||||
|
URL url = new URL(p.getStreamUrl());
|
||||||
|
in = new CountingInputStream(url.openStream());
|
||||||
|
}
|
||||||
List<Chapter> chapters = readChaptersFrom(in);
|
List<Chapter> chapters = readChaptersFrom(in);
|
||||||
if (!chapters.isEmpty()) {
|
if (!chapters.isEmpty()) {
|
||||||
p.setChapters(chapters);
|
p.setChapters(chapters);
|
||||||
|
@ -147,8 +154,13 @@ public class ChapterUtils {
|
||||||
}
|
}
|
||||||
InputStream input = null;
|
InputStream input = null;
|
||||||
try {
|
try {
|
||||||
|
if (media.getStreamUrl().startsWith(ContentResolver.SCHEME_CONTENT)) {
|
||||||
Uri uri = Uri.parse(media.getStreamUrl());
|
Uri uri = Uri.parse(media.getStreamUrl());
|
||||||
input = context.getContentResolver().openInputStream(uri);
|
input = context.getContentResolver().openInputStream(uri);
|
||||||
|
} else {
|
||||||
|
URL url = new URL(media.getStreamUrl());
|
||||||
|
input = url.openStream();
|
||||||
|
}
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
readOggChaptersFromInputStream(media, input);
|
readOggChaptersFromInputStream(media, input);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue