nokia 6630 audio problem
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   nilesh_gosavi
Posted On:   Friday, June 17, 2005 06:53 AM

I'am developing a J2ME application for Nokia 6630. In which I'm trying to play audio (.mp3 & .amr formats). I use " player.stop(); " to pause audio. But when I try to resume audio, Player strarts audio from beginning. import java.io.*; import javax.microedition.lcdui.*; import javax.microedition.media.*; import javax.microedition.media.control.*; import javax.microedition.media.PlayerListener.*; import java.lang.String.*; import javax.microedition.rms.*; final class PlayerCanvas implements Runnable { private Player player = null; private Thread dThread = null; private InputStream s2 = null; PlayerCanvas(InputStream s1)   More>>

I'am developing a J2ME application for Nokia 6630.
In which I'm trying to play audio (.mp3 & .amr formats).
I use " player.stop(); " to pause audio.
But when I try to resume audio, Player strarts audio from beginning.


import java.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import javax.microedition.media.PlayerListener.*;
import java.lang.String.*;
import javax.microedition.rms.*;

final class PlayerCanvas implements Runnable {
private Player player = null;
private Thread dThread = null;
private InputStream s2 = null;
PlayerCanvas(InputStream s1){
super();
s2=s1;
}
private void createPlayer() {
try {
player = Manager.createPlayer(s2, "audio/mpeg");

}
catch (Exception e) {
}
}
public final void playSound() {
if (dThread == null) {
dThread = new Thread(this);
dThread.start();
} else if (player != null) {
try {
player.start();
} catch (Exception ex){

}
}
}


public final void stopSound() {

try {
dThread = null;

if (player != null) {
player.stop();
player.close();
player = null;
s2.close();
s2=null;
}
} catch (Exception ex) {
System.err.println("Problem closing player");
}
}


final void pauseSound() {//to pause audio
try {
if (player != null)
player.stop();

} catch (Exception ex){
System.err.println("Problem stopping player");
}
}


public final void run()
{
if (player == null)
{
try {

createPlayer();
player.realize();
player.prefetch();
player.start();
}
catch(Exception me1)
{
}
}
}

}

1 ) i use createPlayer() method to create player
2 ) i call playSound() method audio play . then i use
pauseSound() to stop audio,audio stop but when i call once again playSound() method audio start from beginning.

   <<Less
About | Sitemap | Contact