【问题标题】:How can I stream an m4v url from Google Cloud Platform using Exoplayer如何使用 Exoplayer 从 Google Cloud Platform 流式传输 m4v url
【发布时间】: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


    【解决方案1】:

    AFAIK,您需要使用 gsutil cp 将流传输到 ExoPlayer。
    我对整个过程了解不多,但我找到了documentation,它可能会向您发送正确的方向。

    【讨论】:

    • 我不明白引用文档中写的任何内容。此外,我只是发现 exoplayer 代码适用于一些谷歌云 URL 并为其他人抛出错误。我似乎无法理解为什么。
    • 需要更多详细信息才能更进一步,您在尝试时会看到哪种错误?可能是权限问题,启用 API 等请分享更多详细信息
    • 谢谢@Bruno,但我已经解决了。显然,Exoplayer 运行良好,只是我的一些云存储链接出现了一些问题。
    猜你喜欢
    • 1970-01-01
    • 2014-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多