Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Super Contributor
Posts: 308
Registered: ‎05-31-2011
My Device: Blackberry-SDK-9800
My Carrier: SimPakage 6.0.0.337_9800 asia.exe

javax.microedition.media.mediaexception

hi, this is my code to record and pause,resume and play code.but i am getting error as above subject.

    

public

booleanPause()

{

if (_player == null || _player.getState() != Player.STARTED)

{

// Not playing, nothing to do

returnfalse;

}

if (_player != null)

{

try

{

_player.stop();

 

getCurrentPosition= _player.getMediaTime();

System.

out.println("media time recorded:"+getCurrentPosition);

}

catch(Exception e)

{

e.printStackTrace();

}

}

return  true;

}

 

------------------------------------------------------------------------------------------------------

publicvoidResume()

{

try

{

_player = Manager.createPlayer("capture://audio?encoding=pcm");

 

// recordPlayer = Manager.createPlayer("capture://audio?encoding=amr");_player.realize();

 

 

FileConnection fconn = (FileConnection)Connector.open("file:///store/home/user/test_audio2.pcm",Connector.WRITE);

 

//_recordControl.setRecordLocation(file:///store/home/user/test_audio2.pcm);

_player.setMediaTime(getCurrentPosition);

 

//_recordControl.setRecordLocation("file:/SDCard/voicenotes/Myvoice.pcm");//_recordControl.setRecordLocation("file://192.168.0.200/software/yogesh/test_audio2.pcm");_recordControl.startRecord();

 

_player.start();

 

//screen.add("Recording...");

 

 

}

catch(MediaException me)

{

Dialog.alert(me.toString());

}

catch(IOException ioe)

{

Dialog.alert(ioe.toString());

}

}

 ------------------------------------------------------------------------------------------------

publicvoidplay() {

 

try

{

//_player = javax.microedition.media.Manager.createPlayer("file:/SDCard/voicenotes/Myvoice.pcm");_player = javax.microedition.media.Manager.createPlayer("file:///store/home/user/test_audio2.pcm");

 

//Player p = javax.microedition.media.Manager.createPlayer(url);_player.realize();

VolumeControl volume = (VolumeControl)

_player.getControl("VolumeControl");

volume.setLevel(80);

_player.prefetch();

 

_player.start();

}

catch(MediaException me)

{

Dialog.alert(me.toString());

}

catch(IOException ioe)

{

Dialog.alert(ioe.toString());

}

 

}

 

BlackBerry Development Advisor
Posts: 15,303
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: javax.microedition.media.mediaexception

What BlackBerry Smartphone model and BlackBerry device software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.

 

What line of code is triggering the exception?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Super Contributor
Posts: 308
Registered: ‎05-31-2011
My Device: Blackberry-SDK-9800
My Carrier: SimPakage 6.0.0.337_9800 asia.exe

Re: javax.microedition.media.mediaexception

i am using smart phone simulator 6.0.0(9800 torch) blackberry java plugin 1.3.0

 blackberry java SDk 6.0.0.30... i am getting error in resume function.... actually i am not able to attach debbuger

so i am not debugging the code.

Retired
Retired
Posts: 150
Registered: ‎10-19-2010
My Device: Not Specified
My Carrier: Rogers

Re: javax.microedition.media.mediaexception

[ Edited ]

You cannot call setMediaTime on a Player setup to record audio, it is not supported.  It also doesn't make a lot of sense... I assume you are trying to append new recorded data to an existing recording?

 

If do then proper way to do it is to record to a new stream or file and append that stream or file to your existing one, once recording is finished.  Because you are using PCM this should 'just work'.  As an FYI, amr has the ability to pause recording and when resumed the device will continue to append new data to your existing file for you, until commit() is called.  It is the only codec that the device will do this for you.

 

Let me know if that solves your problem!