/ / ब्लैकबेरी स्ट्रीम ऑडियो/स्टॉप स्ट्रीम - ब्लैकबेरी, स्ट्रीम

ब्लैकबेरी स्ट्रीम ऑडियो / STOP स्ट्रीम - ब्लैकबेरी, स्ट्रीम

)

मैं प्रोग्रामिंग में नौसिखिया हूं और मुझे समस्या है।

मेरा कोड:

  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;

ठीक है, जब मैं प्ले को पुश करता हूं तो यह एप्लिकेशन में संगीत चला जाता है।

धक्का देने पर इसे फिर से वापस लूप किया। यह दूसरी समस्या है :)

मैं पुश स्टॉप बटन पर स्ट्रीम को रोकना चाहता हूं और भले ही वॉल्यूम कुंजियों को बदलना संभव हो + और - :)

जेडीई 5.0 :)

सादर।

उत्तर:

जवाब के लिए 0 № 1

करने के बजाय btnSelectantyfm.setChangeListener(this); जिसका अर्थ होगा कि आपकी स्क्रीन लागू हो रही है 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 एक सदस्य चर के रूप में ऑब्जेक्ट करें ताकि फील्डचेंज लिस्टर्स प्ले और पॉज़ को एक्सेस कर सकें। प्लेयर को खेलने से रोकने के लिए बस करें player.stop().

वॉल्यूम कुंजियों को दबाए जाने पर वॉल्यूम बदलने के लिए आपको निम्न की आवश्यकता होगी:

  1. एक कार्यान्वित करें KeyListener साइड वॉल्यूम कुंजियों को दबाए जाने पर कार्रवाई करने के लिए
  2. लाओ VolumeControl खिलाड़ी से player.getControl("VolumeControl");
  3. अद्यतन करें VolumeControl नई वांछित मात्रा के साथ