Exoplayer playing m3u8 files Android

前端 未结 5 480
滥情空心
滥情空心 2020-12-14 18:56

After trying multiple ways of playing m3u8 files using videoview and mediaplayer I decided to give up. Everytime i play the m3u8 file I only hear the voice.

5条回答
  •  孤城傲影
    2020-12-14 19:41

    This is the simplest way to stream m3u8 files using ExoPlayer Lib hope to help https://github.com/karim23/SimpleStreamPlayer/tree/master

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = getApplicationContext();
        setContentView(R.layout.activity_main);
        //change the live streaming URL with yours. 
        contentUri = "http://abclive.abcnews.com/i/abc_live4@136330/index_1200_av-b.m3u8?sd=10&b=1200&rebase=on";
        // contentType = DemoUtil.TYPE_HLS;
        final Intent intent = new Intent(context, VideoPlayerActivity.class).setData(Uri.parse(contentUri))
                .putExtra(VideoPlayerActivity.CONTENT_ID_EXTRA, -1)
                //Change the type according to the live streaming extension.
                .putExtra(VideoPlayerActivity.CONTENT_TYPE_EXTRA, DemoUtil.TYPE_HLS);
        liveStreamingTv =(TextView)findViewById(R.id.mainActivity_liveStreamingTv);
        liveStreamingTv.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View v) {
                startActivity(intent);
            }
        });
    }
    

提交回复
热议问题