【发布时间】:2023-04-05 15:02:01
【问题描述】:
我想使用 Exoplayer 从谷歌云存储中流式传输 m4v 视频 URL 链接 https://storage.cloud.google.com/math_oneticha/Numbers/NUMBERS.m4v?authuser=2,但我的应用程序不断崩溃,因为没有可用的 Exoplayer 提取器可以读取流。当我在浏览器上使用相同的 URL 链接时,它会完美地流式传输。我还尝试使用 exoplayer 应用程序流式传输 mp4 URL https://media.publit.io/file/Mathematic/LinearEquation/Linear-Equation-4.mp4,它完美地流式传输意味着 exoplayer 应用程序只是对 m4v url 有挑战。下面是我的 exoplayer 代码
Uri videoUrl;
// Initialize Player view and variables
PlayerView player;
ProgressBar vprogressBar;
ImageView fullScreenImage, closeLecture;
SimpleExoPlayer simpleExoPlayer;
// ref Player variables
player = findViewById(R.id.playerView);
vprogressBar = findViewById(R.id.video_loading_bar);
fullScreenImage = findViewById(R.id.fullscreen_option);
closeLecture = findViewById(R.id.videoClose);
String stringUrl = "https://storage.cloud.google.com/math_oneticha/Numbers/NUMBERS.m4v?authuser=2";
videoUrl = Uri.parse(stringUrl);
LoadControl loadControl = new DefaultLoadControl();
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelector trackSelector = new DefaultTrackSelector(
new AdaptiveTrackSelection.Factory(bandwidthMeter)
);
simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(LectureActivity.this, trackSelector,loadControl);
DefaultHttpDataSourceFactory factory = new DefaultHttpDataSourceFactory("exoplayer video");
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource mediaSource = new ExtractorMediaSource(videoUrl,factory,extractorsFactory,null,null);
player.setPlayer(simpleExoPlayer);
player.setKeepScreenOn(true);
simpleExoPlayer.prepare(mediaSource);
simpleExoPlayer.setPlayWhenReady(true);
simpleExoPlayer.addListener(new Player.EventListener(){
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == Player.STATE_BUFFERING){
vprogressBar.setVisibility(View.VISIBLE);
}else if (playbackState == Player.STATE_READY){
vprogressBar.setVisibility(View.INVISIBLE);
}
}
}
下面是我的崩溃日志
E/ExoPlayerImplInternal: Source error.
com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (MatroskaExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, Ac3Extractor, TsExtractor, FlvExtractor, OggExtractor, PsExtractor, WavExtractor) could read the stream.
请问我可以做些什么不同的事情,以便我的应用可以从谷歌云存储中流式传输我的 m4v url 链接?
【问题讨论】:
标签: java android google-cloud-platform exoplayer2.x