I am trying to implement the playback of mp3 stream from the Internet through ExoPlayer. I found an example on the Internet and do it according to it, but nothing happens. Tell me where something is wrong?
public class Player extends AppCompatActivity implements View.OnClickListener { private String stream; private String radio; private int rec; private ImageButton btnStop; private ImageButton btnPLayPause; private ImageButton btnRecord; private ExoPlayer player; private PlayerControl playerControl; MediaCodecAudioTrackRenderer audioRenderer; private static final String TAG = "SimpleExoMp3"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); btnStop = (ImageButton) findViewById(R.id.btnStop); btnPLayPause = (ImageButton) findViewById(R.id.btnPLayPause); btnRecord = (ImageButton) findViewById(R.id.btnRecord); //Получаем текст из списка и ссылку на радио stream = getIntent().getExtras().getString("stream").toString().trim(); radio = getIntent().getExtras().getString("radio").toString().trim(); rec = getIntent().getExtras().getInt("rec"); //Устанавливаем заголовок Activity setTitle(radio); player = ExoPlayer.Factory.newInstance(1); String url = "http://radio.kavkaz.fm/balkarian.mp3"; //Url for your mp3 file Uri uri = Uri.parse(url); //Convert that to uri player = ExoPlayer.Factory.newInstance(1); // new Exoplayer instance, only one render, as we're playing only audio, in case of video // we need two renders, one for audio and one for video DataSource dataSource = new DefaultUriDataSource(this, TAG); // this instance is reqd to pass data to exoplayer ExtractorSampleSource extractorSampleSource = new ExtractorSampleSource(uri, dataSource, new DefaultAllocator(64 * 1024), 64 * 1024 * 256); //ExtractorSampleSource is used for mp3 or mp4, uri is passed, datasource is passed, a DefaultAllocator instance is also passed) // to know more about this go on exoplayers (see description for links) audioRenderer = new MediaCodecAudioTrackRenderer(extractorSampleSource, MediaCodecSelector.DEFAULT); //here we prepare audioRenderer by passing extractorSampleSource and MediaCodecSelector player.prepare(audioRenderer); // finally we prepare player playerControl = new PlayerControl(player); //then we get controls of the player, play and pause } @Override public void onClick(View v) { if(v.getId()==R.id.btn_play){ //on play button click if(!playerControl.isPlaying()){ player.setPlayWhenReady(true); } }else if(v.getId()==R.id.btn_pause){ //on pause button click if(playerControl.isPlaying()){ playerControl.pause(); } } } @Override protected void onDestroy() { //before destroying the app super.onDestroy(); player.release(); // important otherwise song will play even after app has closed. } } The logs only display the following
I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es I/OMXClient: MuxOMX ctor D/AudioTrack: Client defaulted notificationFrames to 3675 for frameCount 11025 In the gradle I wrote the following compile 'com.google.android.exoplayer:exoplayer:r1.5.8'
And in the manifesto added permission to the Internet