You Are Here:

Community: Developer Discussion Boards

#1 Old Post Capture Audio wont work on N95 8GB - 2008-03-12, 11:44

Join Date: Mar 2008
Posts: 3
GamezMaster
Offline
Registered User
Hi,
The code works fine on the WTK Emulator, but I just can't figure out why it wont work on the N95/Symbian Emulator or phone..
Can anyone please tell me what is wrong?

Thx in advance!

******************App.java******************
package Project;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class App extends MIDlet {

Display display;
Mixer mCanvas;
public App() {
}

protected void startApp() {

mCanvas = new Mixer("DJJLAGT");
display = Display.getDisplay(this);
display.setCurrent(mCanvas);


}

protected void pauseApp() {
System.out.println("pauseApp called...");
}

protected void destroyApp(boolean unconditional) {
mCanvas.stop();
System.out.println("destroyApp called...");
}

}
*********************END**********************

******************Mixer.java******************
package Project;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import javax.microedition.media.protocol.*;
import java.io.*;
import java.util.*;

public class Mixer extends Canvas {

Player Audioplayer, Recordplayer;
VolumeControl vctrl;
RateControl rctrl;
RecordControl record;
public ByteArrayOutputStream OutputStream;
private ByteArrayInputStream InputStream;
private byte [] ByteStream;
int volume = 100;
int rate = 100000;

public Mixer(String title){

System.out.println("Started...");

}
public void paint(Graphics g) {

g.setColor(0x00000000);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0x00ffffff);
g.fillRect(0, 20, volume, 10);



}

public void record() {
try {
Recordplayer = Manager.createPlayer("capture://audio?rate=3000&bits=16");
Recordplayer.realize();
vctrl = (VolumeControl) Recordplayer.getControl("VolumeControl");
vctrl.setLevel(0);
record = (RecordControl) Recordplayer.getControl("RecordControl");
OutputStream = new ByteArrayOutputStream();
record.setRecordStream(OutputStream);

Recordplayer.start();
record.startRecord();


System.out.println("Recording (max 20 sec.)");
Thread.currentThread().sleep(20000);
if(ByteStream==null){
stoprecord();
}
} catch (InterruptedException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
} catch (MediaException ex) {
ex.printStackTrace();
}

}

public void stoprecord() {
try {
record.commit();
Recordplayer.close();
System.out.println("Stopped Recording");
ByteStream = OutputStream.toByteArray();
} catch (IOException ex) {
ex.printStackTrace();
}
}

public void play() {
try {
if(ByteStream!=null){
InputStream = new ByteArrayInputStream(ByteStream);
Audioplayer = Manager.createPlayer(InputStream, "audio/x-wav");
Audioplayer.realize();

vctrl = (VolumeControl) Audioplayer.getControl("VolumeControl");
vctrl.setLevel(volume);

rctrl = (RateControl) Audioplayer.getControl("RateControl");
rctrl.setRate(rate);

Audioplayer.setLoopCount(-1);

Audioplayer.start();
System.out.println("Playing");
}
} catch (Exception e) {
System.out.println(e.toString());
}
}

public void stop() {
try {
Audioplayer.deallocate();
Audioplayer.close();
System.out.println("Stopped");
} catch(Exception e) {}

}

public void keyPressed(int keyCode) {
if(keyCode == KEY_NUM1) {
play();
}

if(keyCode == KEY_NUM2) {
stop();
}

if(keyCode == -4) {
if(volume<100)
{
volume+=10;
System.out.println(""+volume);
vctrl.setLevel(volume);
repaint();
}
}

if(keyCode == -3) {
if(volume>0)
{
volume-=10;
System.out.println(""+volume);
vctrl.setLevel(volume);
repaint();
}
}

if(keyCode == -2) {
if(rate<300000)
{
rate+=10000;
System.out.println(""+rate);
rctrl.setRate(rate);
}
}

if(keyCode == -1) {
if(rate>0)
{
rate-=10000;
System.out.println(""+rate);
rctrl.setRate(rate);
}
}

if(keyCode == KEY_POUND) {
new Thread(new Runnable(){
public void run() {
try{
record();
}catch(Exception e){}
}
}).start();
}

if(keyCode == KEY_STAR) {
new Thread(new Runnable(){
public void run() {
try{
stoprecord();
}catch(Exception e){}
}
}).start();
}

}

}

******************END******************
Reply With Quote

#2 Old Re: Capture Audio wont work on N95 8GB - 2008-03-12, 18:22

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
How does it not work? Do you get an exception or what?

Hartti
Reply With Quote

#3 Old Re: Capture Audio wont work on N95 8GB - 2008-03-12, 18:29

Join Date: Mar 2008
Posts: 3
GamezMaster
Offline
Registered User
No exception,

The program starts, and then does nothing..
nothing at all.. no matter what button I push (#, *, 1 or 2)
It should start recording when I push #, yet, it does nothing..
Reply With Quote

#4 Old Re: Capture Audio wont work on N95 8GB - 2008-03-13, 01:26

Join Date: Aug 2007
Posts: 774
r2j7's Avatar
r2j7
Offline
Forum Nokia Expert
Hello GamezMaster,

Quote:
.. If Canvas is in the full screen mode and it has no CommandListener, the MIDlet triggers low-level key events from the softkeys and is thus in full control of them. ..
Source: http://www.forum.nokia.com/document/...E0E96F2FC.html

How about implementing a CommandListener with the Canvas object just to see if that makes any difference?

Regards,
r2j7
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
N95 8GB Uninstallation problems juliand77 Installation, Certification and Security 2 2007-12-07 11:23
Is the Battery Life on the N95 8GB Better than the N95? brstlrovrs4life General Discussion 1 2007-12-03 01:04
Audio capture and J2ME mike.f.watson Audio 0 2005-08-05 13:42

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: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X 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