| Reply | « Previous Thread | Next Thread » |
|
Hi
My Code: import java.util.*; import java.io.*; import javax.microedition.lcdui.*; import javax.microedition.midlet.*; import javax.microedition.media.*; /** * An example MIDlet with simple "Hello" text and an Exit command. * Refer to the startApp, pauseApp, and destroyApp * methods so see how each handles the requested transition. * * @author desk-21 * @version */ public class HelloMIDlet extends MIDlet implements CommandListener,PlayerListener { private Display display; private List itemList; private Form form; private Command cmdStop,cmdStart,cmdPause,cmdExit; private Hashtable items,itemsInfo; private Player player; public HelloMIDlet() { try { display = Display.getDisplay(this); itemList = new List("Select any item to play",List.IMPLICIT); cmdStop = new Command("Stop",Command.SCREEN,1); cmdStart = new Command("Start",Command.SCREEN,1); cmdPause = new Command("Pause",Command.SCREEN,1); cmdExit = new Command("Exit",Command.SCREEN,1); form = new Form("Palying Mmedia"); form.addCommand(cmdStop); form.addCommand(cmdPause); form.addCommand(cmdExit); items = new Hashtable(); itemsInfo = new Hashtable(); items.put("bark","file://bark.wav"); itemsInfo.put("bark","audio/x-wav"); } catch(Exception e) { System.out.println(e.getMessage()); } } public void startApp() { for(Enumeration en=items.keys();en.hasMoreElements();) { itemList.append((String)en.nextElement(),null); } itemList.setCommandListener(this); display.setCurrent(itemList); } public void pauseApp() { try { if(player != null) player.stop(); } catch(Exception e) {} } public void destroyApp(boolean unconditional) { if(player != null) player.close(); // close the player } public void commandAction(Command command, Displayable disp) { if(command == cmdExit) { destroyApp(false); notifyDestroyed(); } if(disp==itemList) { List list = ((List)disp); String key = list.getString(list.getSelectedIndex()); try { playMedia((String)items.get(key), key); } catch (Exception e) { System.err.println("Unable to play: " + e); e.printStackTrace(); } } if(command == cmdStop) { try { player.close(); // close the player display.setCurrent(itemList); // redisplay the list of media form.removeCommand(cmdStart); // remove the start command form.addCommand(cmdPause); // add the pause command } catch(Exception e) { System.err.println("cmdStop : " + e); } } if(command == cmdPause) { try { player.stop(); // pauses the media, note that it is called stop form.removeCommand(cmdPause); // remove the pause command form.addCommand(cmdStart); // add the start (restart) command } catch(Exception e) { System.err.println("cmdStop : " + e); } } if(command ==cmdStart) { try { player.start(); // starts from where the last pause was called form.removeCommand(cmdStart); form.addCommand(cmdPause); } catch(Exception e) { System.err.println("cmdStop : " + e); } } } private void playMedia(String locator, String key) throws Exception { try { String file = locator.substring(locator.indexOf("file://") + 7, locator.length()); player = Manager.createPlayer(getClass().getResourceAsStream(file), (String)itemsInfo.get(key)); player.addPlayerListener(this); player.setLoopCount(-1); // play indefinitely player.prefetch(); // prefetch player.realize(); // realize player.start(); // and start } catch(Exception e) { System.out.println(e.getMessage() + " " + e.toString()); } } /* Handle player events */ public void playerUpdate(Player player, String event, Object eventData) { if(event.equals(PlayerListener.STARTED) && new Long(0L).equals((Long)eventData)) { display.setCurrent(form); } else if(event.equals(PlayerListener.CLOSED)) { form.deleteAll(); // clears the form of any previous controls } } } Error: java.lang.OutOfMemoryError at javax.microedition.lcdui.List.callKeyPressed(+91) at javax.microedition.lcdui.Display$DisplayAccessor.keyEvent(+198) at javax.microedition.lcdui.Display$DisplayManagerImpl.keyEvent(+11) at com.sun.midp.lcdui.DefaultEventHandler.keyEvent(+121) at com.sun.midp.lcdui.AutomatedEventHandler.keyEvent(+210) at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+178) and when i can give smallsize file's path than give Error: null if any idea/suggestion than please give me. Regards, Tanya |
|
In which emulator have you tried ? Have you tried in a real device?
Regards Gopal __________________ MobiQuil.com An initiative by Developers for Developers. http://www.mobiquil.com - Alpha - Launched. |
|
Hi
ya i tried with real device also but it's do nothing. Tanya |
|
hi,
i found ur working over wav (audio codec) ,pls help me ..i want to know few basic things ,how speech recognition works,if for matching two amr files have to compare,so what should be the criteria,please tell me some links over it my email id is vivkhr@gmail.com thank u vivek khera |
|
Sorry vivek
i don't know more about audio because i fresher in this developer's field. so i really very sorry. but search in google site you definetly find the solution. Tanya. |
|
I guess your wav file is bigger than your emulator's or real phone's heap-memory size (a long-time "feature" on Nokia phones). Try a wav file less than 1 Mb in size, and if it will not working, check out the file path. If you'll get the same errors, try to find a simple player code from the net.
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| could not find thread.mbg and thread.rsg | deercrane | General Symbian C++ | 3 | 2006-04-18 10:44 |
| Tips on using NDS 1.1 | mitts | Symbian Tools & SDKs | 7 | 2006-01-18 17:07 |
| What is the error in my code here? Unable to Save document to file | yuva69 | General Symbian C++ | 1 | 2005-05-26 15:22 |
| Creation of .wav file. | gauravgandhi80 | General Symbian C++ | 3 | 2004-12-24 04:01 |
| Looking for help from member......pl...help me in my source code. | yuva69 | General Symbian C++ | 0 | 2002-06-10 13:24 |