Java Code Examples for com.google.android.exoplayer2.C#ContentType

The following examples show how to use com.google.android.exoplayer2.C#ContentType . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MediaSourceCreator.java    From ExoVideoView with Apache License 2.0 6 votes vote down vote up
public MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    @C.ContentType int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri)
            : Util.inferContentType("." + overrideExtension);
    switch (type) {
        case C.TYPE_SS:
            SsMediaSource.Factory factory = new SsMediaSource.Factory(buildDataSourceFactory(false));
            factory.createMediaSource(uri);
            return factory.createMediaSource(uri);
        case C.TYPE_DASH:
            DashMediaSource.Factory factory1 = new DashMediaSource.Factory(buildDataSourceFactory(false));
            return factory1.createMediaSource(uri);
        case C.TYPE_HLS:
            HlsMediaSource.Factory factory2 = new HlsMediaSource.Factory(buildDataSourceFactory(false));
            return factory2.createMediaSource(uri);
        case C.TYPE_OTHER:
            ProgressiveMediaSource.Factory factory3 = new ProgressiveMediaSource.Factory(buildDataSourceFactory(false));
            return factory3.createMediaSource(uri);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
 
Example 2
Source File: Util.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Makes a best guess to infer the type from a file name.
 *
 * @param fileName Name of the file. It can include the path of the file.
 * @return The content type.
 */
@C.ContentType
public static int inferContentType(String fileName) {
  fileName = toLowerInvariant(fileName);
  if (fileName.endsWith(".mpd")) {
    return C.TYPE_DASH;
  } else if (fileName.endsWith(".m3u8")) {
    return C.TYPE_HLS;
  } else if (fileName.matches(".*\\.ism(l)?(/manifest(\\(.+\\))?)?")) {
    return C.TYPE_SS;
  } else {
    return C.TYPE_OTHER;
  }
}
 
Example 3
Source File: Util.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Makes a best guess to infer the type from a file name.
 *
 * @param fileName Name of the file. It can include the path of the file.
 * @return The content type.
 */
@C.ContentType
public static int inferContentType(String fileName) {
  fileName = toLowerInvariant(fileName);
  if (fileName.endsWith(".mpd")) {
    return C.TYPE_DASH;
  } else if (fileName.endsWith(".m3u8")) {
    return C.TYPE_HLS;
  } else if (fileName.matches(".*\\.ism(l)?(/manifest(\\(.+\\))?)?")) {
    return C.TYPE_SS;
  } else {
    return C.TYPE_OTHER;
  }
}
 
Example 4
Source File: Util.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Makes a best guess to infer the type from a file name.
 *
 * @param fileName Name of the file. It can include the path of the file.
 * @return The content type.
 */
@C.ContentType
public static int inferContentType(String fileName) {
  fileName = toLowerInvariant(fileName);
  if (fileName.endsWith(".mpd")) {
    return C.TYPE_DASH;
  } else if (fileName.endsWith(".m3u8")) {
    return C.TYPE_HLS;
  } else if (fileName.matches(".*\\.ism(l)?(/manifest(\\(.+\\))?)?")) {
    return C.TYPE_SS;
  } else {
    return C.TYPE_OTHER;
  }
}
 
Example 5
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Makes a best guess to infer the type from a file name.
 *
 * @param fileName Name of the file. It can include the path of the file.
 * @return The content type.
 */
@C.ContentType
public static int inferContentType(String fileName) {
  fileName = Util.toLowerInvariant(fileName);
  if (fileName.endsWith(".mpd")) {
    return C.TYPE_DASH;
  } else if (fileName.endsWith(".m3u8")) {
    return C.TYPE_HLS;
  } else if (fileName.matches(".*\\.ism(l)?(/manifest(\\(.+\\))?)?")) {
    return C.TYPE_SS;
  } else {
    return C.TYPE_OTHER;
  }
}
 
Example 6
Source File: ExoSourceManager.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
@SuppressLint("WrongConstant")
@C.ContentType
public static int inferContentType(String fileName, @Nullable String overrideExtension) {
    fileName = Util.toLowerInvariant(fileName);
    if (fileName.startsWith("rtmp:")) {
        return TYPE_RTMP;
    } else {
        return inferContentType(Uri.parse(fileName), overrideExtension);
    }
}
 
Example 7
Source File: ExoSourceManager.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
@C.ContentType
public static int inferContentType(Uri uri, @Nullable String overrideExtension) {
    return Util.inferContentType(uri, overrideExtension);
}
 
Example 8
Source File: Util.java    From Telegram with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 9
Source File: Util.java    From MediaSDK with Apache License 2.0 3 votes vote down vote up
/**
 * 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, @Nullable String overrideExtension) {
  return TextUtils.isEmpty(overrideExtension)
      ? inferContentType(uri)
      : inferContentType("." + overrideExtension);
}
 
Example 10
Source File: Util.java    From Telegram-FOSS with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 11
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: AdsLoader.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the supported content types for ad media. Must be called before the first call to {@link
 * #start(EventListener, AdViewProvider)}. Subsequent calls may be ignored. Called on the main
 * thread by {@link AdsMediaSource}.
 *
 * @param contentTypes The supported content types for ad media. Each element must be one of
 *     {@link C#TYPE_DASH}, {@link C#TYPE_HLS}, {@link C#TYPE_SS} and {@link C#TYPE_OTHER}.
 */
void setSupportedContentTypes(@C.ContentType int... contentTypes);
 
Example 13
Source File: MediaSourceFactory.java    From MediaSDK with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the {@link C.ContentType content types} supported by media sources created by this
 * factory.
 */
@C.ContentType
int[] getSupportedTypes();
 
Example 14
Source File: Util.java    From K-Sonic with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source File: AdsLoader.java    From Telegram with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the supported content types for ad media. Must be called before the first call to {@link
 * #start(EventListener, AdViewProvider)}. Subsequent calls may be ignored. Called on the main
 * thread by {@link AdsMediaSource}.
 *
 * @param contentTypes The supported content types for ad media. Each element must be one of
 *     {@link C#TYPE_DASH}, {@link C#TYPE_HLS}, {@link C#TYPE_SS} and {@link C#TYPE_OTHER}.
 */
void setSupportedContentTypes(@C.ContentType int... contentTypes);
 
Example 16
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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);
}
 
Example 17
Source File: AdsLoader.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the supported content types for ad media. Must be called before the first call to
 * {@link #attachPlayer(ExoPlayer, EventListener, ViewGroup)}. Subsequent calls may be ignored.
 *
 * @param contentTypes The supported content types for ad media. Each element must be one of
 *     {@link C#TYPE_DASH}, {@link C#TYPE_HLS}, {@link C#TYPE_SS} and {@link C#TYPE_OTHER}.
 */
void setSupportedContentTypes(@C.ContentType int... contentTypes);
 
Example 18
Source File: Util.java    From Telegram with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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);
}
 
Example 19
Source File: AdsLoader.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the supported content types for ad media. Must be called before the first call to
 * {@link #attachPlayer(ExoPlayer, EventListener, ViewGroup)}. Subsequent calls may be ignored.
 *
 * @param contentTypes The supported content types for ad media. Each element must be one of
 *     {@link C#TYPE_DASH}, {@link C#TYPE_HLS}, {@link C#TYPE_SS} and {@link C#TYPE_OTHER}.
 */
void setSupportedContentTypes(@C.ContentType int... contentTypes);
 
Example 20
Source File: Util.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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);
}