0

if i use the first one from the following codes, the 1.m3u8 type songs are running. if i use the second one, mp3 and the other songs are running.

Is there one code series that can run these formats in one? Maybe it is a simple coding but i couldn t do that. Please help me.

 @Override
    protected String doInBackground(String... a) {

        String s = Constant.arrayList_play.get(Constant.playPos).getMp3Url().replace(" ","%20");
        try {


            DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

            DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory((MainActivity)Constant.context,
                    Util.getUserAgent((MainActivity)Constant.context, "onlinemp3"), bandwidthMeter);

            ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();

            MediaSource videoSource = new ExtractorMediaSource(Uri.parse(s),
                    dataSourceFactory, extractorsFactory, null, null);

            Constant.exoPlayer.prepare(videoSource);

            Constant.exoPlayer.setPlayWhenReady(true);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

1 Answers1

0

May be you need to read here about exoplayer's supported formats.

Jayesh Rathod
  • 600
  • 1
  • 5
  • 18