赞
踩
使用ExoPlayer首先要创建一个playerr实例
SimpleExoPlayer exoPlayer=new SimpleExoPlayer.Builder(getApplicationContext()).build();
有了播放器实例我们要在哪里播放
exoPlayer.setVideoSurface(surfaceView.getHolder().getSurface());
还需要一个播放源
- DefaultDataSourceFactory factory=new DefaultDataSourceFactory(this,Util.getUserAgent(this, this.getPackageName())
- HlsMediaSource.Factory factory= new HlsMediaSource.Factory(factory);
- exoPlayer.prepare(factory.createMediaSource(Uri.parse("url")));
此时就可以播放了
exoPlayer.setPlayWhenReady(true);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。