use of com.google.android.exoplayer2.upstream.DataSchemeDataSource in project ExoPlayer by google.
the class ImaUtil method getAdsRequestForAdTagDataSpec.
/**
* Returns an {@link AdsRequest} based on the specified ad tag {@link DataSpec}.
*/
public static AdsRequest getAdsRequestForAdTagDataSpec(ImaFactory imaFactory, DataSpec adTagDataSpec) throws IOException {
AdsRequest request = imaFactory.createAdsRequest();
if (DataSchemeDataSource.SCHEME_DATA.equals(adTagDataSpec.uri.getScheme())) {
DataSchemeDataSource dataSchemeDataSource = new DataSchemeDataSource();
try {
dataSchemeDataSource.open(adTagDataSpec);
request.setAdsResponse(Util.fromUtf8Bytes(DataSourceUtil.readToEnd(dataSchemeDataSource)));
} finally {
dataSchemeDataSource.close();
}
} else {
request.setAdTagUrl(adTagDataSpec.uri.toString());
}
return request;
}
Aggregations