Exoplayer how to know which URL to be played with custom video view

核能气质少年 提交于 2019-12-02 10:14:34

问题


I am first time working on online Video player, I am using TextureVideoViewMute extends TextureView implements TextureView.SurfaceTextureListener custom class as custom video player.

I am having two urls in my response source_url(main url) and dash_url.Now I wanted to use ExomediaPlayer for this but I have following questions.

1.How to categories which url to be played?

2.Or Whether this will be decided by player itself while playing?

3.Or We need to use single url player automatically do his work?

4.Or is it possible combination of custom video surfaceview and SimpleExoPlayer?

The main thing I want achieve is adaptive bit rate streaming like you-tube 144p 220p 720p... etc does according to network condition

I have tried the examples provide on GIT but they are either playing dash_url or source_url

Because of poor documentation I am not able to understand how should I go for this.

Exoplayer Sample

Sample code of Exoplayer

  String videoURL = "http://blueappsoftware.in/layout_design_android_blog.mp4";

    SimpleExoPlayerView exoPlayerView = (SimpleExoPlayerView) findViewById(R.id.exo_player_view);
    try {


        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter));
        SimpleExoPlayer exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector);

        Uri videoURI = Uri.parse(videoURL);

        DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory("exoplayer_video");
        ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
        MediaSource mediaSource = new ExtractorMediaSource(videoURI, dataSourceFactory, extractorsFactory, null, null);

        exoPlayerView.setPlayer(exoPlayer);
        exoPlayer.prepare(mediaSource);
        exoPlayer.setPlayWhenReady(true);
    } catch (Exception e) {
        Log.e("MainAcvtivity", " exoplayer error " + e.toString());
    }

来源:https://stackoverflow.com/questions/48920678/exoplayer-how-to-know-which-url-to-be-played-with-custom-video-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!