You Are Here:

Community: Developer Discussion Boards

#1 Old Runtime Error when Paly .wav File. - 2006-12-25, 12:59

Join Date: Nov 2006
Posts: 422
Location: Rajkot
Send a message via Skype™ to Tanya
Tanya's Avatar
Tanya
Offline
Regular Contributor
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
Reply With Quote

#2 Old Re: Runtime Error when Paly .wav File. - 2006-12-25, 15:25

Join Date: Nov 2003
Posts: 3,641
Location: Bangalore , India
Send a message via Yahoo to balagopalks
balagopalks's Avatar
balagopalks
Offline
Forum Nokia Expert
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.
Reply With Quote

#3 Old Re: Runtime Error when Paly .wav File. - 2006-12-26, 07:13

Join Date: Nov 2006
Posts: 422
Location: Rajkot
Send a message via Skype™ to Tanya
Tanya's Avatar
Tanya
Offline
Regular Contributor
Hi

ya i tried with real device also but it's do nothing.

Tanya
Reply With Quote

#4 Old Re: Runtime Error when Paly .wav File. - 2006-12-26, 07:35

Join Date: Dec 2006
Posts: 5
vivek_k95
Offline
Registered User
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
Reply With Quote

#5 Old Re: Runtime Error when Paly .wav File. - 2006-12-26, 09:17

Join Date: Nov 2006
Posts: 422
Location: Rajkot
Send a message via Skype™ to Tanya
Tanya's Avatar
Tanya
Offline
Regular Contributor
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.
Reply With Quote

#6 Old Re: Runtime Error when Paly .wav File. - 2007-01-03, 10:42

Join Date: Aug 2006
Posts: 307
axs
Offline
Regular Contributor
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 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
Similar Threads
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

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