解析m3u8视频url第一个切片ts的url
public class M3u8AnalysisUtil {
private static final OkHttpClient client = new OkHttpClient();
public static String getFirstTsUrl(String m3u8Url) throws IOException {
Request request = new Request.Builder()
.url(m3u8Url)
.build();
Response response = client.newCall(request).execute();
if (!response.isSuccessful()) {
throw new IOException("Unexpected code " + response);
}
String m3u8Content = response.body().string();
String[] lines = m3u8Content.split("\n");
for (String line : lines) {
line = line.trim();
if (line.endsWith(".ts") && !line.startsWith("#")) {
if (!line.startsWith("http")) {
int lastIndex = m3u8Url.lastIndexOf("/");
if (-1 != lastIndex) {