Exoplayer consumes too much data while playing online video

Viewed 68

I'm making an app which plays videos from a URL. I'm using Exoplayer, but I noticed that when I play an online video in Exoplayer, it consumes too much data. For example, when I play a movie URL, it just loads for 2-3 seconds and my Exoplayer consumes around 400mb, and I'm not sure why.

This my video playing method in Exoplayer. Is there something I did wrong?

private void playvideo() {

        String MOVIEURL = getIntent().getStringExtra("playthis");
Uri uri = Uri.parse(MOVIEURL);
player = new SimpleExoPlayer.Builder(this).setSeekForwardIncrementMs(10000).setSeekBackIncrementMs(10000).build();

        DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(
                this, Util.getUserAgent(this , "app"));
concatenatingMediaSource = new ConcatenatingMediaSource();

//  app:rewind_increment="1e000"
//    app:fastforward_increment="10000"

        MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
                .createMediaSource(MediaItem.fromUri(Uri.parse(String.valueOf(uri))));

        concatenatingMediaSource.addMediaSource(mediaSource);
        playerView.setPlayer(player);
        playerView.setKeepScreenOn(true);
        player.prepare(concatenatingMediaSource);
        player.seekTo(position , C.TIME_UNSET);
        playError();
        

    }

    private void playError() {
        player.addListener(new Player.Listener() {
            @Override
            public void onPlayerError(PlaybackException error) {
                Toast.makeText(video_player.this, "Error", Toast.LENGTH_SHORT).show();
            }
        });


0 Answers
Related