Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Blackberry 黑莓流音频/停止流_Blackberry_Stream - Fatal编程技术网

Blackberry 黑莓流音频/停止流

Blackberry 黑莓流音频/停止流,blackberry,stream,Blackberry,Stream,我是编程新手,有问题 我的代码: choiceFieldANTYFM = new ObjectChoiceField("Wybierz stację(6)", new String[]{"Warszawa [96kb]"}); choiceFieldANTYFM.setChangeListener(this); btnSelectantyfm = new ButtonField("Słuchaj!", FIELD_HCENTER | ButtonField.CONSUME_CLICK

我是编程新手,有问题

我的代码:

  choiceFieldANTYFM = new ObjectChoiceField("Wybierz stację(6)", new String[]{"Warszawa [96kb]"});
  choiceFieldANTYFM.setChangeListener(this);
  btnSelectantyfm = new ButtonField("Słuchaj!", FIELD_HCENTER | ButtonField.CONSUME_CLICK);
  btnSelectantyfm.setChangeListener(this);
  stopplaying = new ButtonField("STOP", FIELD_HCENTER | ButtonField.CONSUME_CLICK);
  stopplaying.setChangeListener(this);

   add(choiceFieldANTYFM);
   add(btnSelectantyfm);
   add(stopplaying);
及其他:

public void fieldChanged(Field field, int context) {
 if (field == btnSelectantyfm)

  {
     System.out.println("Selected item: " + Integer.toString(choiceField.getSelectedIndex()));
  }if (field == btnSelect)
 {

     switch (choiceField.getSelectedIndex())
    {

case 0:

       try {
     String url = "http://94.23.220.75:6000;deviceside=false;ConnectionUID=GPMDSEU01";
      Player player;
      player = javax.microedition.media.Manager.createPlayer(url);
      player.start();
 } 
      catch (Exception e) {
      Dialog.alert(e.toString());
  }


        break;
好的,当我按下“播放”按钮时,它会在应用程序中播放音乐

当再次推它时,它会回圈。这是第二个问题:

我想在按下停止按钮时停止流,即使可以更改音量键+和-:

JDE 5.0:

注意。

而不是做bSelectyFm.setChangeListenerthis;这意味着您的屏幕正在实现FieldChangeListener为每个按钮声明单独的FieldChangeListener对象,如下所示:

btnSelectantyfm.setChangeListener(new FieldChangeListener(){

    public void fieldChanged(Field field, int context){
        //start playing code here
        player.start();
    }
});

stopplaying.setChangeListener(new FieldChangeListener(){

    public void fieldChanged(Field field, int context){
        //stop playing code here
        player.stop();
    }
});
现在需要将Player对象声明为成员变量,以便play和pause FieldChangeListeners可以访问它。要阻止玩家玩,只需执行Player.stop

要在按音量键时更改音量,您需要:

实现KeyListener,以便在按下侧音量键时执行操作 通过执行Player.getControlVolumeControl从播放器获取VolumeControl; 使用新的所需卷更新VolumeControl
非常感谢uour的回复:我有循环问题,按下停止按钮时无法停止这是一个beta OTA应用程序: