You Are Here:

Community: Developer Discussion Boards

#1 Old Unhappy Please Help Recording mp4 audio..... - 2007-10-08, 16:24

Join Date: Jul 2007
Posts: 3
codsw2
Offline
Registered User
Hi,

I am trying to record audio in mp4 format in N80 phone. When I check the support for mp4 audio encoding, it returns that the support is available in the N80. But when I try to record, the program exists. When I tried on device debugging I found that the program exists when trying to commit the recording. Please help me to sort the problem out, here is the code I used,



import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
import javax.microedition.media.control.RecordControl;

public class CapturePlaybackAudioMIDlet extends MIDlet
implements CommandListener {

// the display items
private Display display = null;
private Alert alert = null;
private Command exitCommand = null;

// players and controls
private Player capturePlayer = null;
private Player playbackPlayer = null;
private RecordControl recordControl = null;

// buffers
private ByteArrayOutputStream bos = new ByteArrayOutputStream();
private ByteArrayInputStream bis = null;

public CapturePlaybackAudioMIDlet() {

// create the display
display = Display.getDisplay(this);
alert = new Alert("Message");
alert.setTimeout(Alert.FOREVER);
alert.setString("Capturing for 10 seconds. Say something intelligent!");
exitCommand = new Command("Exit", Command.EXIT, 1);
alert.addCommand(exitCommand);
alert.setCommandListener(this);

try {
// create the capture player
capturePlayer = Manager.createPlayer("capture://audio?encoding=audio/mp4&rate=16000&bits=16");

if (capturePlayer != null) {

// if created, realize it
capturePlayer.realize();

// and grab the RecordControl
recordControl = (RecordControl)capturePlayer.getControl(
"javax.microedition.media.control.RecordControl");

// set the alert as the current item
display.setCurrent(alert);

// if it is null throw exception
if(recordControl == null)
throw new Exception("No RecordControl available");

// create the buffer in which recording will be done
bos = new ByteArrayOutputStream(1024);

// and set this buffer as the destination for recording
recordControl.setRecordStream(bos);

} else {
throw new Exception("Capture Audio Player is not available");
}

} catch(Exception e) {
error(e);
}
}

public void startApp() {

try {

// first start the corresponding player
capturePlayer.start();

// and then start the RecordControl
recordControl.startRecord();

// now wait 10 seconds
Thread.sleep(10000);

// stop recording after time is up
recordControl.stopRecord();

// commit the recording
recordControl.commit();

// and close the Player instance
capturePlayer.stop();

// finished, set the message
alert.setString("Well done! Now Processing...");

// flush the buffer
bos.flush();

// create an inputstream of this buffer
bis = new ByteArrayInputStream(bos.toByteArray());

// create the playback Player instance with this stream,
// using the specified content type, as given by the RecordControl
playbackPlayer =
Manager.createPlayer(bis, recordControl.getContentType());

// start the playback
playbackPlayer.start();

// and set the message
alert.setString("Playing back ... ");

} catch(Exception e) {
error(e);
} finally {
try {
if(bos != null) bos.close();
if(bis != null) bis.close();
} catch(Exception ex) {
error(ex);
}
}

}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command cmd, Displayable disp) {
if(cmd == exitCommand) {
notifyDestroyed();
}
}

// general purpose error method, displays on screen as well to output
private void error(Exception e) {
alert.setString(e.getMessage());
alert.setTitle("Error");
display.setCurrent(alert);
e.printStackTrace();
}

}
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
Buggy AMR Audio Recording. Please Help!! jhamby General Symbian C++ 8 2009-07-07 11:34
Video with audio recording delay problem on N90 vasya0 Symbian Media (Graphics & Sounds) 2 2007-12-03 17:44
Recording an audio stream using the Series 60 emulator rastapasta Symbian Media (Graphics & Sounds) 4 2007-04-23 12:46
PLz.. plzz.. help me Audio Recording khalandar Mobile Java Tools & SDKs 0 2007-02-19 10:27
Problem when trying to record audio in MP4 format using Python (N80) alb3530 Python 7 2007-02-07 19:12

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