第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

mediaplayer 不播放廣播電臺流

mediaplayer 不播放廣播電臺流

翻翻過去那場雪 2022-06-23 20:11:10
我正在嘗試安裝一個可以與廣播鏈接一起使用的流媒體播放器,但它對我不起作用。我想知道錯誤可能是什么,我附上了代碼和鏈接。謝謝你。public class PrincipalActivity extends Activity {    //creando botones    Button btnPlay, btnRecargar, btnParar, btnTop, btnNosotros, btnSalir;    MediaPlayer mediaPlayer; // creando clase mediaPlayer para reproducir archivos.    String stream = "http://stream.dancefm.cl:9332"; //variable para la ulr streamingboolean prepared, started = false; // 2 boleano para el estado del reproductor    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_principal);        //instanciando botones creados arriba con los botones fisicos.        btnPlay = (Button) findViewById(R.id.btnPlay);        btnRecargar = (Button) findViewById(R.id.btnRecargar);        btnParar = (Button) findViewById(R.id.btnStop);        btnTop = (Button) findViewById(R.id.btnTop);        btnNosotros = (Button) findViewById(R.id.btnNosotros);        btnSalir = (Button) findViewById(R.id.btnSalir);        WebView myWebbView = (WebView) this.findViewById(R.id.webprincipal); //creando e instanciando webview        myWebbView.loadUrl("https://www.dancefm.cl/noticias/");//Cargando webview        Toast toast = Toast.makeText(getApplicationContext(), "Esperando respuesta del servidor...", Toast.LENGTH_LONG);         toast.show(); //arriba creamos un toast para mostrar un mensaje y aqui abajo lo mostramos.        //Asignando estado a los botones... esto para que mientras este cargando no se utilzen estos botones.        btnPlay.setEnabled(false);        btnParar.setEnabled(false);        btnRecargar.setEnabled(false);        mediaPlayer = new MediaPlayer();        mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);        new PlayerTask().execute(stream); //llamara a quien reproducira el audio    }任何合作將不勝感激,因?yàn)槲抑幌M纛l流開始
查看完整描述

2 回答

?
忽然笑

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超5個贊

您可以使用prepareAsyc()準(zhǔn)備mediaplyer。


試試這個代碼。


//creando botones

Button btnPlay, btnRecargar, btnParar, btnTop, btnNosotros, btnSalir;


MediaPlayer mediaPlayer; // creando clase mediaPlayer para reproducir archivos.


String stream = "http://stream.dancefm.cl:9332"; //variable para la ulr streaming

boolean prepared, started = false; // 2 boleano para el estado del reproductor



@Override

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_principal);


    //instanciando botones creados arriba con los botones fisicos.

    btnPlay = (Button) findViewById(R.id.btnPlay);

    btnRecargar = (Button) findViewById(R.id.btnRecargar);

    btnParar = (Button) findViewById(R.id.btnStop);

    btnTop = (Button) findViewById(R.id.btnTop);

    btnNosotros = (Button) findViewById(R.id.btnNosotros);

    btnSalir = (Button) findViewById(R.id.btnSalir);


    WebView myWebbView = (WebView) this.findViewById(R.id.webprincipal); //creando e instanciando webview


    myWebbView.loadUrl("https://www.dancefm.cl/noticias/");//Cargando webview


    Toast toast = Toast.makeText(getApplicationContext(), "Esperando respuesta del servidor...", Toast.LENGTH_LONG);

    toast.show(); //arriba creamos un toast para mostrar un mensaje y aqui abajo lo mostramos.


    //Asignando estado a los botones... esto para que mientras este cargando no se utilzen estos botones.

    btnPlay.setEnabled(false);

    btnParar.setEnabled(false);

    btnRecargar.setEnabled(false);


    mediaPlayer = new MediaPlayer();

    mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);


    mediaPlayer.setDataSource(stream);

    mediaPlayer.prepareAsync();

    mediaPlayer.setOnPreparedListener(new OnPreparedListener() {

        @Override

        public void onPrepared(MediaPlayer mp) {

            mp.start();

        }

    });


}


查看完整回答
反對 回復(fù) 2022-06-23
?
一只萌萌小番薯

TA貢獻(xiàn)1795條經(jīng)驗(yàn) 獲得超7個贊

您只需將http://xxx.xx.xxx.x/更改為http://xxx.xx.xxx.x/;stream.mp3可以是任何單詞,重要的是放; 在您的 shoucast url 之后 / 之后,如果您使用 IOS 并且確實(shí)可以檢查您的 Shoucast 版本,則 Ios 只能重現(xiàn) Shoucast v2



查看完整回答
反對 回復(fù) 2022-06-23
  • 2 回答
  • 0 關(guān)注
  • 94 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號