You Are Here:

Community: Developer Discussion Boards

#1 Old sound bug on 6610/6310i involving TextBox class. - 2004-02-01, 05:19

Join Date: Aug 2003
Posts: 232
Location: uk
Send a message via ICQ to alex_crowther
alex_crowther's Avatar
alex_crowther
Offline
Regular Contributor
This may apply to other phones, but thats all I have
to test it on at the moment.

This bug does not occure in any emulator, only on a
real phone.

Basically, it appears that while the display is set
to an instance of "TextBox" sound will not play.
More so, any sound currently playing is cut off
the moment the display is set.

I have included part of my code below:

-------------------------------------------------------------------------
static final int SOUND_VOLUME = 1;
static Sound sound;

// sound function
public static void playSound(byte bytes[])
{
try
{
if (sound == null)
sound = new Sound(bytes, Sound.FORMAT_TONE);

if (sound.getState() == Sound.SOUND_PLAYING)
sound.stop();

sound.init(bytes, Sound.FORMAT_TONE);
sound.setGain(SOUND_VOLUME);
sound.play(1);
}
catch(Exception e)
{
showError(e.toString());
}
}


// a test function to show the problem
// (My real code uses a TextBox to get the players
// name for a highscore table, which is where my
// real problem is).

public void menuInfo()
{
sCurrentMenu = sInfo;

/*
// sound will work using this section
Form_Info = new Form("Info");
Form_Info.addCommand(Command_back);
Form_Info.addCommand(Command_ok);
Form_Info.setCommandListener(this);
Form_Info.append("some info");
display.setCurrent(Form_Info);
*/

// but not using this section
TextBox foo = new TextBox("Info", "some info!", 10, 0);
foo.addCommand(Command_ok);
foo.addCommand(Command_back);
foo.setCommandListener(this);
display.setCurrent(foo);

// load and play a sound (makes no difference
// if sound is preloaded, or loaded on the fly)
playSound(loadBinaryFile("/testsound.ott"));
}


// callback for Back and OK commands.
// back goes back to menu, ok just tries
// to play the sound again.
public void commandAction(Command c, Displayable d)
{
String sLabel = c.getLabel();

try
{
// -- SNIP --
if (sCurrentMenu.equals(sInfo))
{
if (sLabel.equals(sOK))
{
// play sound on OK, this is only to test if it will play
playSound(MyUtils.loadBinaryFile("/testsound.ott"));
}
else // ie == sBack
{
Form_Info = null;
menuMain();
}
}
// -- SNIP --
}
catch (Exception e)
{
ShowError(e.toString());
}
}
-------------------------------------------------------

As noted in the above code, if method, menuInfo()
uses an instance of class Form, the sound plays
on calling of the menuInfo() method, and plays
again if the OK callback event is sent.

However if you use a TextBox, the sound plays
for about 1/4 of a second and is then cut off,
when the method is called. The OK callback
produces no sound at all.

Anyone have any ideas ???

Alex
Last edited by alex_crowther : 2004-02-01 at 23:08.
Reply With Quote

#2 Old update - 2004-02-01, 23:07

Join Date: Aug 2003
Posts: 232
Location: uk
Send a message via ICQ to alex_crowther
alex_crowther's Avatar
alex_crowther
Offline
Regular Contributor
Further testing has reveiled it also affects the 6310i.
Again only happens on a real phone and not an emulator.

Anyone else experiencing this ?

Alex
Reply With Quote

#3 Old Update - 2004-02-05, 12:44

Join Date: Aug 2003
Posts: 232
Location: uk
Send a message via ICQ to alex_crowther
alex_crowther's Avatar
alex_crowther
Offline
Regular Contributor
Incase anyone is interest, but too lazy to write their own code,
I am written a demo project to demonstrate this undocumented
'feature' :P

Also, I have noticed that 2 of the emulators (5100 and 3300),
do actually accurately model real phone behaviour, i.e. won't
produce sound when screen is set to a TextBox.

--- CUT ---
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import com.nokia.mid.sound.*;

/*
Emulator : TextBox Produced Sound
3410 - YES
6310i - YES
3510i - YES
7210 - YES
6230 - YES
5100 - No
3300 - No

5100 and 3300 emulators seem to accurately model the real phones.
*/

public class TextBoxSoundTest extends MIDlet implements CommandListener
{
Display display;

List theMenu;
TextBox textbox;
Form form;

Command Command_menu = new Command("Menu", Command.BACK, 1);
Command Command_select = new Command("Select", Command.BACK, 0);
Command Command_tone = new Command("Tone", Command.BACK, 2);
Command Command_tune = new Command("Tune", Command.BACK, 2);

Sound sound;

// an error buffer
String sBuf = "";

byte tune[] =
{(byte)0x02, (byte)0x4A, (byte)0x3A, (byte)0x80, (byte)0x40,
(byte)0x09, (byte)0xD1, (byte)0x66, (byte)0xA0, (byte)0x5A,
(byte)0x06, (byte)0x20, (byte)0x6A, (byte)0x0A, (byte)0x23,
(byte)0x04, (byte)0x9B, (byte)0x81, (byte)0xB8, (byte)0x28,
(byte)0x9C, (byte)0x08, (byte)0xC0, (byte)0x8C, (byte)0x0B,
(byte)0x40, (byte)0xAC, (byte)0x0B, (byte)0x40, (byte)0x8C,
(byte)0x12, (byte)0x6A, (byte)0x05, (byte)0xA0, (byte)0x62,
(byte)0x06, (byte)0xA0, (byte)0x6E, (byte)0x0A, (byte)0x23,
(byte)0x02, (byte)0x70, (byte)0x23, (byte)0x04, (byte)0x9B,
(byte)0x81, (byte)0xA8, (byte)0x18, (byte)0x81, (byte)0xA8,
(byte)0x16, (byte)0x81, (byte)0x58, (byte)0x16, (byte)0x81,
(byte)0x88, (byte)0x11, (byte)0x81, (byte)0x58, (byte)0x18,
(byte)0x81, (byte)0xB8, (byte)0x1A, (byte)0x81, (byte)0x88,
(byte)0x1A, (byte)0x81, (byte)0x68, (byte)0x18, (byte)0x81,
(byte)0xA8, (byte)0x28, (byte)0x8C, (byte)0x12, (byte)0x6E,
(byte)0x06, (byte)0xE0, (byte)0xA2, (byte)0x70, (byte)0x23,
(byte)0x02, (byte)0x30, (byte)0x2D, (byte)0x02, (byte)0xB0,
(byte)0x2D, (byte)0x02, (byte)0x30, (byte)0x49, (byte)0xA8,
(byte)0x16, (byte)0x81, (byte)0x88, (byte)0x1A, (byte)0x81,
(byte)0x38, (byte)0x28, (byte)0x8C, (byte)0x12, (byte)0x6E,
(byte)0x06, (byte)0xA0, (byte)0x62, (byte)0x05, (byte)0xA0,
(byte)0x46, (byte)0x05, (byte)0xA0, (byte)0x56, (byte)0x05,
(byte)0x90, (byte)0x41, (byte)0x00, (byte)0x00};


// --------------------------------------------------------------------- //
public TextBoxSoundTest()
{
}
// --------------------------------------------------------------------- //



// --------------------------------------------------------------------- //
public void startApp()
{
if (display == null)
display = Display.getDisplay(this);

theMenu = new List("Menu", Choice.IMPLICIT);

theMenu.append("TextBox", null);
theMenu.append("Form", null);

theMenu.addCommand(Command_select);

theMenu.addCommand(Command_tone);
theMenu.addCommand(Command_tune);


theMenu.setCommandListener(this);

display.setCurrent(theMenu);
}
// --------------------------------------------------------------------- //



// --------------------------------------------------------------------- //
public void commandAction(Command c, Displayable s)
{
if (c == Command_menu)
{
// if errors have been recorded, put them in a ticker
// on the main menu, no idea if this works, seemed
// like a good way to see errors when testing on
// a real phone though.
if (sBuf.length() > 0)
{
theMenu.setTicker(new Ticker("[" + sBuf + "]"));
sBuf = "";
} else {
theMenu.setTicker(null);
}

display.setCurrent(theMenu);
}
else
if (c == Command_tone)
{
playSound(1500, 500);
}
else
if (c == Command_tune)
{
playSound(tune);
}
else
{
switch(theMenu.getSelectedIndex())
{
case 0:
{
textbox = new TextBox("TextBox:", "Sound Probably Won't Work",100, 0);

textbox.addCommand(Command_menu);
textbox.addCommand(Command_tone);
textbox.addCommand(Command_tune);
textbox.setCommandListener(this);

display.setCurrent(textbox);
}
break;

case 1:
{
form = new Form("Form:");
form.append("Sound Will Work");

form.addCommand(Command_menu);
form.addCommand(Command_tone);
form.addCommand(Command_tune);
form.setCommandListener(this);

display.setCurrent(form);
}

break;
}
}



}
// --------------------------------------------------------------------- //



// --------------------------------------------------------------------- //
public void playSound(byte bytes[])
{
try
{
if (sound == null)
sound = new Sound(bytes, Sound.FORMAT_TONE);

if (sound.getState() == Sound.SOUND_PLAYING)
sound.stop();

sound.init(bytes, Sound.FORMAT_TONE);
sound.setGain(255);
sound.play(1);
}
catch(Exception e)
{
sBuf = sBuf + e.toString();
}
}
// --------------------------------------------------------------------- //



// --------------------------------------------------------------------- //
public void playSound(int freq, int dur)
{
try
{
if (sound == null)
sound = new Sound(freq, dur);

if (sound.getState() == Sound.SOUND_PLAYING)
sound.stop();

sound.init(freq, dur);
sound.setGain(255);
sound.play(1);
}
catch(Exception e)
{
sBuf = sBuf + e.toString();
}
}
// --------------------------------------------------------------------- //



// --------------------------------------------------------------------- //
public void pauseApp()
{
}
// --------------------------------------------------------------------- //



// --------------------------------------------------------------------- //
public void destroyApp(boolean unconditional)
{
}
// --------------------------------------------------------------------- //
}
--- CUT ---
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ