Problem with forward button
hi,
I am doing a media player with java.
I am using a table for displaying the audio files to be played and I have created the code for playing the audio files. It is as follows :
try{
if (p != null) {
p.stop();
p.deallocate();
}
URL mediaURL = new URL("file:" + (String)jTable1.getValueAt(jTable1.getSelectedRow(), 1));
System.out.println(mediaURL);
try {
p = Manager.createPlayer(mediaURL);
p.addControllerListener(this);
p.start();
} catch (NoPlayerException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
} catch(MalformedURLException e) {
System.out.println(e);
}
Now, the problem is that,, Since I am using a table, if
I write the code to forward button as getSelectedRows()+1
it forwards from any song that is selected in the table but not playing.,,.
Wanted urgent help..
Message was edited by:
Spanian
[1014 byte] By [
Spaniana] at [2007-11-26 20:42:25]

# 1
> hi,
>
> I am doing a media player with java.
> I am using a table for displaying the audio files to
> be played and I have created the code for playing the
> audio files. It is as follows :
> if
> I write the code to forward button as
> getSelectedRows()+1
> it forwards from any song that is selected in the
> table but not playing.,,.
>
> Wanted urgent help..
>
> Message was edited by:
> Spanian
Did you remember to use p.start() in the same void as getSelectedRows()+1?
# 2
> hi,
>
> I am doing a media player with java.
> I am using a table for displaying the audio files to
> be played and I have created the code for playing the
> audio files. It is as follows :
>
> try{
> if (p != null) {
> p.stop();
> p.deallocate();
>
> URL mediaURL = new URL("file:" +
> (String)jTable1.getValueAt(jTable1.getSelectedRow(),
> 1));
>System.out.println(mediaURL);
> try {
>p = Manager.createPlayer(mediaURL);
> p.addControllerListener(this);
>p.start();
> atch (NoPlayerException ex) {
>ex.printStackTrace();
> tch (IOException ex) {
>ex.printStackTrace();
>} catch(MalformedURLException e) {
>System.out.println(e);
>}
> ow, the problem is that,, Since I am using a table,
> if
> I write the code to forward button as
> getSelectedRows()+1
> it forwards from any song that is selected in the
> table but not playing.,,.
>
> Wanted urgent help..
>
> Message was edited by:
> Spanian
Use an extra field called int currentindex
which points at the song in the jtable which is currently being played. When you want to play the next song you would have to just set it to currentindex + 1 to get the next song from the JTable
# 3
hi,that problem is not still over., but I can do it.,.,.Now I am moving with next problem.,.How to save a playlist, using a jtable.Thats eating my head.,.,.
# 5
The class that you are having the JTable can be serailized. Implement serializable interface.Does that help?
# 6
I dont think so serialization will help, It will make me more complex..,What about using XML only for playlist
# 7
> I dont think so serialization will help,
Why do you think it won't help. I would prefer it any day. Imeplement the code for a JTable in a separate file which implements serializable. When you start your application just load the serialized class from a file
>It will make
> me more complex..,
No it won't
# 8
I dont think so it will be proper to dump entire GUI (Since using NetBeans) into a file and then once again loading it back..,Do you think it will be proper
# 9
> I dont think so it will be proper to dump entire GUI
> (Since using NetBeans) into a file and then once
> again loading it back..,
> Do you think it will be proper
You don't have to dump entire GUI. Extend JTable and implement serializable. That would just make you serialize on small class and not the entire GUI
class MyJTable extends JTable implements Serializable
{
// blahblah
}
clas GUI
{
MyJTable myjtable;
GUI
{
nyjtable = new MyJTable();
}
if ( application closing )
{
//serialize myjtable instance;
}
}
Message was edited by:
qUesT_foR_knOwLeDge