This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes Sound Recording and Playing in Mobile Media API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Sound Recording and Playing in Mobile Media API" Watch "Sound Recording and Playing in Mobile Media API" New topic
Author

Sound Recording and Playing in Mobile Media API

Walter Mao
Greenhorn

Joined: Oct 09, 2002
Posts: 2
Hello.
I want to write an application to record and play voice in cellphones using Mobile Media API. My recording function is like this:
try {
// Create a Player that captures live audio.
Player p = Manager.createPlayer("capture://audio");
p.realize();
// Get the RecordControl, set the record stream,
// start the Player and record for 5 seconds.
RecordControl rc = (RecordControl)p.getControl("RecordControl");
ByteArrayOutputStream output = new ByteArrayOutputStream();
rc.setRecordStream(output);
rc.startRecord();
p.start();
Thread.currentThread().sleep(5000);
rc.commit();
p.close();
} catch (IOException ioe) {
} catch (MediaException me) {
} catch (InterruptedException ie) { }
I want to record the voice into a file and store it in cellphone database. How do I do that? Where do I put it in? In this example, I record from web server. That's not what I want. Voice should be an InputStream or DataSource? What is the difference between the two? I want some code examples.
Thank you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Sound Recording and Playing in Mobile Media API
 
Similar Threads
Recording midlet with save function
voice input
OutOfMemory Exception while recording audio
Capture and play audio
Capture audio from Java ME application