How to avoid 15 second delay/caching in Android Media Player when playing stream

后端 未结 4 2232
迷失自我
迷失自我 2021-02-15 17:57

I am implementing a media player that plays a stream from a remote machine. Via my app I can control the remote machine (e.g. seek to second). Works like charm, but: The Android

4条回答
  •  鱼传尺愫
    2021-02-15 18:35

    Try this. this will definatly help to you ::

     private class TouchandshowTask extends AsyncTask {
    
        @Override
        protected Void doInBackground(Void... arg0) {
            try {
            player.setAudioStreamType(AudioManager.STREAM_MUSIC);
            player.setDataSource("URL");
            player.prepare();
        } catch (Exception e) {
            // TODO: handle exception
        }
    
            return null;
        }
        protected void onPostExecute(final Void unused) {
    
        }
    }
    

    OnCreate()

    new TouchandshowTask().execute();
    

提交回复
热议问题