【问题标题】:E/ExoPlayerImplInternal: Source error com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 404E/ExoPlayerImplInternal:源错误 com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException:响应代码:404
【发布时间】:2017-08-21 10:59:59
【问题描述】:

我正在尝试通过 exo Player 播放视频,但它给了我这个错误:-

E/ExoPlayerImplInternal:源错误。
InvalidResponseCodeException:响应代码:404

这是我的活动课程:-

public class VideoActivity extends AppCompatActivity implements VideoRendererEventListener {
    private String mVideoUrl;
    private SimpleExoPlayerView simpleExoPlayerView;
    private SimpleExoPlayer player;
    private static final String TAG = "AMAN";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);

    if (getIntent() != null)
        mVideoUrl = getIntent().getStringExtra("VideoUrl");




    BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
    TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);


    LoadControl loadControl = new DefaultLoadControl();


    player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
    simpleExoPlayerView = new SimpleExoPlayerView(this);
    simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.player_view);


    simpleExoPlayerView.setUseController(true);
    simpleExoPlayerView.requestFocus();


    simpleExoPlayerView.setPlayer(player);



    Uri mp4VideoUri =Uri.parse(mVideoUrl);

    DefaultBandwidthMeter bandwidthMeterA = new DefaultBandwidthMeter();

    DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "exoplayer2example"), bandwidthMeterA);

    ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();


    MediaSource videoSource = new HlsMediaSource(mp4VideoUri, dataSourceFactory, 1, null, null);
    final LoopingMediaSource loopingSource = new LoopingMediaSource(videoSource);




   player.prepare(loopingSource);
                    player.setPlayWhenReady(true);

}  

有人知道这里出了什么问题吗?

【问题讨论】:

  • 由于错误,您尝试加载的内容似乎不存在。如果您确定存在,则可能是您使用的路径/url 错误或应用程序被阻止访问资源
  • @ElmerDantas 亲爱的,当我在浏览器中点击 url 时它正在播放……但在我的应用程序中它不起作用……根据你的说法,如果 url 不正确,那么它在浏览器中也不起作用。 .这是我的网址 :- tgconnect.co.in/tgtech/uploads/video/100 crore ka Qtiyapa - Bollywood Qtiyapa (ft. Anurag Kashyap).mp4
  • 我不是 Android 开发人员,但我注意到您的响应错误代码:404。因此,由于某种原因,您的应用程序无法找到您尝试访问的资源。为什么?不幸的是,我不知道,但我相信通过一些谷歌你将能够弄清楚。
  • 它实际上不是来自 exoplayer 尝试修复你的 SSL 握手错误,
  • 您发现问题所在了吗?

标签: java android json retrofit exoplayer


【解决方案1】:

您的链接必须使用“final”修饰符。

`protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);

    final String VIDEO_URL = getIntent().getExtras().getString("URL");

    playerView = findViewById(R.id.exo_player);
    simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(this);
    playerView.setPlayer(simpleExoPlayer);
    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
            Util.getUserAgent(this, "appname"));
    MediaSource videoSource  = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(VIDEO_URL));
    simpleExoPlayer.prepare(videoSource);
    simpleExoPlayer.setPlayWhenReady(true);
}`

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-14
    • 1970-01-01
    • 1970-01-01
    • 2011-01-21
    相关资源
    最近更新 更多