Java Code Examples for com.google.android.exoplayer2.util.Util#isLocalFileUri()

The following examples show how to use com.google.android.exoplayer2.util.Util#isLocalFileUri() . 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: DefaultDataSource.java    From K-Sonic with MIT License 6 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
  Assertions.checkState(dataSource == null);
  // Choose the correct source for the scheme.
  String scheme = dataSpec.uri.getScheme();
  if (Util.isLocalFileUri(dataSpec.uri)) {
    if (dataSpec.uri.getPath().startsWith("/android_asset/")) {
      dataSource = assetDataSource;
    } else {
      dataSource = fileDataSource;
    }
  } else if (SCHEME_ASSET.equals(scheme)) {
    dataSource = assetDataSource;
  } else if (SCHEME_CONTENT.equals(scheme)) {
    dataSource = contentDataSource;
  } else {
    dataSource = baseDataSource;
  }
  // Open the source and return.
  return dataSource.open(dataSpec);
}
 
Example 2
Source File: DefaultDataSource.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
  Assertions.checkState(dataSource == null);
  // Choose the correct source for the scheme.
  String scheme = dataSpec.uri.getScheme();
  if (Util.isLocalFileUri(dataSpec.uri)) {
    String uriPath = dataSpec.uri.getPath();
    if (uriPath != null && uriPath.startsWith("/android_asset/")) {
      dataSource = getAssetDataSource();
    } else {
      dataSource = getFileDataSource();
    }
  } else if (SCHEME_ASSET.equals(scheme)) {
    dataSource = getAssetDataSource();
  } else if (SCHEME_CONTENT.equals(scheme)) {
    dataSource = getContentDataSource();
  } else if (SCHEME_RTMP.equals(scheme)) {
    dataSource = getRtmpDataSource();
  } else if (SCHEME_UDP.equals(scheme)) {
    dataSource = getUdpDataSource();
  } else if (DataSchemeDataSource.SCHEME_DATA.equals(scheme)) {
    dataSource = getDataSchemeDataSource();
  } else if (SCHEME_RAW.equals(scheme)) {
    dataSource = getRawResourceDataSource();
  } else {
    dataSource = baseDataSource;
  }
  // Open the source and return.
  return dataSource.open(dataSpec);
}
 
Example 3
Source File: ExtendedDefaultDataSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
    Assertions.checkState(dataSource == null);
    // Choose the correct source for the scheme.
    String scheme = dataSpec.uri.getScheme();
    if (Util.isLocalFileUri(dataSpec.uri)) {
        if (dataSpec.uri.getPath().startsWith("/android_asset/")) {
            dataSource = assetDataSource;
        } else {
            if (dataSpec.uri.getPath().endsWith(".enc")) {
                dataSource = encryptedFileDataSource;
            } else {
                dataSource = fileDataSource;
            }
        }
    } else if ("tg".equals(scheme)) {
        dataSource = FileLoader.getStreamLoadOperation(listener);
    } else if (SCHEME_ASSET.equals(scheme)) {
        dataSource = assetDataSource;
    } else if (SCHEME_CONTENT.equals(scheme)) {
        dataSource = contentDataSource;
    } else {
        dataSource = baseDataSource;
    }
    // Open the source and return.
    return dataSource.open(dataSpec);
}
 
Example 4
Source File: DefaultDataSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
  Assertions.checkState(dataSource == null);
  // Choose the correct source for the scheme.
  String scheme = dataSpec.uri.getScheme();
  if (Util.isLocalFileUri(dataSpec.uri)) {
    if (dataSpec.uri.getPath().startsWith("/android_asset/")) {
      dataSource = getAssetDataSource();
    } else {
      dataSource = getFileDataSource();
    }
  } else if (SCHEME_ASSET.equals(scheme)) {
    dataSource = getAssetDataSource();
  } else if (SCHEME_CONTENT.equals(scheme)) {
    dataSource = getContentDataSource();
  } else if (SCHEME_RTMP.equals(scheme)) {
    dataSource = getRtmpDataSource();
  } else if (DataSchemeDataSource.SCHEME_DATA.equals(scheme)) {
    dataSource = getDataSchemeDataSource();
  } else if (SCHEME_RAW.equals(scheme)) {
    dataSource = getRawResourceDataSource();
  } else {
    dataSource = baseDataSource;
  }
  // Open the source and return.
  return dataSource.open(dataSpec);
}
 
Example 5
Source File: ExtendedDefaultDataSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
    Assertions.checkState(dataSource == null);
    // Choose the correct source for the scheme.
    String scheme = dataSpec.uri.getScheme();
    if (Util.isLocalFileUri(dataSpec.uri)) {
        if (dataSpec.uri.getPath().startsWith("/android_asset/")) {
            dataSource = assetDataSource;
        } else {
            if (dataSpec.uri.getPath().endsWith(".enc")) {
                dataSource = encryptedFileDataSource;
            } else {
                dataSource = fileDataSource;
            }
        }
    } else if ("tg".equals(scheme)) {
        dataSource = FileLoader.getStreamLoadOperation(listener);
    } else if (SCHEME_ASSET.equals(scheme)) {
        dataSource = assetDataSource;
    } else if (SCHEME_CONTENT.equals(scheme)) {
        dataSource = contentDataSource;
    } else {
        dataSource = baseDataSource;
    }
    // Open the source and return.
    return dataSource.open(dataSpec);
}
 
Example 6
Source File: DefaultDataSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
  Assertions.checkState(dataSource == null);
  // Choose the correct source for the scheme.
  String scheme = dataSpec.uri.getScheme();
  if (Util.isLocalFileUri(dataSpec.uri)) {
    if (dataSpec.uri.getPath().startsWith("/android_asset/")) {
      dataSource = getAssetDataSource();
    } else {
      dataSource = getFileDataSource();
    }
  } else if (SCHEME_ASSET.equals(scheme)) {
    dataSource = getAssetDataSource();
  } else if (SCHEME_CONTENT.equals(scheme)) {
    dataSource = getContentDataSource();
  } else if (SCHEME_RTMP.equals(scheme)) {
    dataSource = getRtmpDataSource();
  } else if (DataSchemeDataSource.SCHEME_DATA.equals(scheme)) {
    dataSource = getDataSchemeDataSource();
  } else if (SCHEME_RAW.equals(scheme)) {
    dataSource = getRawResourceDataSource();
  } else {
    dataSource = baseDataSource;
  }
  // Open the source and return.
  return dataSource.open(dataSpec);
}
 
Example 7
Source File: ExtendedDefaultDataSource.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
    Assertions.checkState(dataSource == null);
    // Choose the correct source for the scheme.
    String scheme = dataSpec.uri.getScheme();
    if (Util.isLocalFileUri(dataSpec.uri)) {
        String uriPath = dataSpec.uri.getPath();
        if (uriPath != null && uriPath.startsWith("/android_asset/")) {
            dataSource = getAssetDataSource();
        } else {
            if (dataSpec.uri.getPath().endsWith(".enc")) {
                dataSource = getEncryptedFileDataSource();
            } else {
                dataSource = getFileDataSource();
            }
        }
    } else if ("tg".equals(scheme)) {
        dataSource = getStreamDataSource();
    } else if (SCHEME_ASSET.equals(scheme)) {
        dataSource = getAssetDataSource();
    } else if (SCHEME_CONTENT.equals(scheme)) {
        dataSource = getContentDataSource();
    } else if (SCHEME_RTMP.equals(scheme)) {
        dataSource = getRtmpDataSource();
    } else if (DataSchemeDataSource.SCHEME_DATA.equals(scheme)) {
        dataSource = getDataSchemeDataSource();
    } else if (SCHEME_RAW.equals(scheme)) {
        dataSource = getRawResourceDataSource();
    } else {
        dataSource = baseDataSource;
    }
    // Open the source and return.
    return dataSource.open(dataSpec);
}
 
Example 8
Source File: DefaultDataSource.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
  Assertions.checkState(dataSource == null);
  // Choose the correct source for the scheme.
  String scheme = dataSpec.uri.getScheme();
  if (Util.isLocalFileUri(dataSpec.uri)) {
    String uriPath = dataSpec.uri.getPath();
    if (uriPath != null && uriPath.startsWith("/android_asset/")) {
      dataSource = getAssetDataSource();
    } else {
      dataSource = getFileDataSource();
    }
  } else if (SCHEME_ASSET.equals(scheme)) {
    dataSource = getAssetDataSource();
  } else if (SCHEME_CONTENT.equals(scheme)) {
    dataSource = getContentDataSource();
  } else if (SCHEME_RTMP.equals(scheme)) {
    dataSource = getRtmpDataSource();
  } else if (SCHEME_UDP.equals(scheme)) {
    dataSource = getUdpDataSource();
  } else if (DataSchemeDataSource.SCHEME_DATA.equals(scheme)) {
    dataSource = getDataSchemeDataSource();
  } else if (SCHEME_RAW.equals(scheme)) {
    dataSource = getRawResourceDataSource();
  } else {
    dataSource = baseDataSource;
  }
  // Open the source and return.
  return dataSource.open(dataSpec);
}
 
Example 9
Source File: ExtendedDefaultDataSource.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
    Assertions.checkState(dataSource == null);
    // Choose the correct source for the scheme.
    String scheme = dataSpec.uri.getScheme();
    if (Util.isLocalFileUri(dataSpec.uri)) {
        String uriPath = dataSpec.uri.getPath();
        if (uriPath != null && uriPath.startsWith("/android_asset/")) {
            dataSource = getAssetDataSource();
        } else {
            if (dataSpec.uri.getPath().endsWith(".enc")) {
                dataSource = getEncryptedFileDataSource();
            } else {
                dataSource = getFileDataSource();
            }
        }
    } else if ("tg".equals(scheme)) {
        dataSource = getStreamDataSource();
    } else if (SCHEME_ASSET.equals(scheme)) {
        dataSource = getAssetDataSource();
    } else if (SCHEME_CONTENT.equals(scheme)) {
        dataSource = getContentDataSource();
    } else if (SCHEME_RTMP.equals(scheme)) {
        dataSource = getRtmpDataSource();
    } else if (DataSchemeDataSource.SCHEME_DATA.equals(scheme)) {
        dataSource = getDataSchemeDataSource();
    } else if (SCHEME_RAW.equals(scheme)) {
        dataSource = getRawResourceDataSource();
    } else {
        dataSource = baseDataSource;
    }
    // Open the source and return.
    return dataSource.open(dataSpec);
}
 
Example 10
Source File: DefaultDataSource.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
  Assertions.checkState(dataSource == null);
  // Choose the correct source for the scheme.
  String scheme = dataSpec.uri.getScheme();
  if (Util.isLocalFileUri(dataSpec.uri)) {
    String uriPath = dataSpec.uri.getPath();
    if (uriPath != null && uriPath.startsWith("/android_asset/")) {
      dataSource = getAssetDataSource();
    } else {
      dataSource = getFileDataSource();
    }
  } else if (SCHEME_ASSET.equals(scheme)) {
    dataSource = getAssetDataSource();
  } else if (SCHEME_CONTENT.equals(scheme)) {
    dataSource = getContentDataSource();
  } else if (SCHEME_RTMP.equals(scheme)) {
    dataSource = getRtmpDataSource();
  } else if (SCHEME_UDP.equals(scheme)) {
    dataSource = getUdpDataSource();
  } else if (DataSchemeDataSource.SCHEME_DATA.equals(scheme)) {
    dataSource = getDataSchemeDataSource();
  } else if (SCHEME_RAW.equals(scheme)) {
    dataSource = getRawResourceDataSource();
  } else {
    dataSource = baseDataSource;
  }
  // Open the source and return.
  return dataSource.open(dataSpec);
}