View Full Version : Java project
trublu
29-07-2008, 11:06 PM
I was thinking of making a multimedia player as a part of my Java project.It wud b a basic one,other features wud b added as i learn more.So,the question is,can it b done using Java only? Or do i need to study ne thing else?Pls suggest some useful resources too.
chandru.in
29-07-2008, 11:11 PM
Java alone is more than enough. You need to use JMF (Java Media Framework) for this.
prasath_amd
30-07-2008, 12:31 AM
Or check this out, this is source code for a bare-bone command-line Java mp3 player:-
http://www.javalobby.org/java/forums/t18465.html
I've modified the Command-line player with a JFrame window :-
import java.io.FileInputStream;
import java.io.IOException;
import javax.sound.sampled.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.Thread;
import Limit.*;
public class Jmp3 extends JFrame implements ActionListener
{
JButton open,close;
JFileChooser jfc;
Jmp3()
{
super("Java MP3 Player");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
setSize(400,300);
setVisible(true);
close = new JButton("Close");
open = new JButton("Open");
close.addActionListener(this);
open.addActionListener(this);
this.add(close);
this.add(open);
jfc = new JFileChooser();
jfc.addChoosableFileFilter(new ImageFilter());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand() == "Close")
System.exit(0);
if(ae.getActionCommand() == "Open")
play();
}
public void play()
{
if(jfc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
{
AudioInputStream din = null;
try
{
FileInputStream file = new FileInputStream(jfc.getSelectedFile());
AudioInputStream in = AudioSystem.getAudioInputStream(file);
AudioFormat baseFormat = in.getFormat();
AudioFormat decodedFormat = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
baseFormat.getSampleRate(), 16, baseFormat.getChannels(),
baseFormat.getChannels() * 2, baseFormat.getSampleRate(),
false);
din = AudioSystem.getAudioInputStream(decodedFormat, in);
DataLine.Info info = new DataLine.Info(SourceDataLine.class, decodedFormat);
SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
if(line != null)
{
line.open(decodedFormat);
byte[] data = new byte[4096];
// Start
line.start();
int nBytesRead;
while ((nBytesRead = din.read(data, 0, data.length)) != -1)
{
line.write(data, 0, nBytesRead);
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(din != null)
{
try
{
din.close();
}
catch(IOException e)
{
// Nothing here
}
}
}
}
}
public static void main(String[] args)
{
new Jmp3();
}
}
package Limit;
import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.*;
public class ImageFilter extends FileFilter
{
public boolean accept(File f)
{
String extension = Utils.getExtension(f);
if (extension != null)
{
if (extension.equals(Utils.bpt))
{
return true;
}
else
{
return false;
}
}
return false;
}
public String getDescription()
{
return "MP3 Audio File (.mp3)";
}
}
class Utils
{
public final static String bpt = "mp3";
public static String getExtension(File f)
{
String ext = null;
String s = f.getName();
int i = s.lastIndexOf('.');
if (i > 0 && i < s.length() - 1)
ext = s.substring(i+1).toLowerCase();
return ext;
}
}
trublu
30-07-2008, 10:42 PM
Thankx both of you.
@prasath_amd,thanx for the code.but i prefer to do it myself.
how do i add codec support?
prasath_amd
30-07-2008, 11:29 PM
@prasath_amd,thanx for the code.but i prefer to do it myself.
I gave it only to give u some basic idea tats all.......
how do i add codec support?
don know abt tat.....but i think JMF should do it.......
JMF:-
http://java.sun.com/javase/technologies/desktop/media/jmf/index.jsp
This may be useful for u:-
http://www.javaranch.com/
trublu
31-07-2008, 09:05 AM
I gave it only to give u some basic idea tats all.......
I really appreciate your help.I just said dat i wanna do it myself.
Plasma_Snake
02-08-2008, 09:48 PM
Sorry for budging in but I too have to give a Minor Project after my vacations. I know Core JAVA only and was thinking about making a Torrent Client. Is it possible to make one with my limited knowledge of the subject? Where can i get its exemplary Source Code? :confused:
bukaida
09-08-2008, 09:41 PM
Search here:-
http://java.codeproject.com/
BTW You must know how to write the project report too. It should follow a specified format.
shwetz
09-08-2008, 11:27 PM
i also need to make a java project...i knw basic java programming till applets..i also want to giv it a interface....
QwertyManiac
10-08-2008, 05:45 AM
Learn AWT and then Swing for that.
mahender_joshi
21-09-2008, 11:17 AM
i need hrlp for search engine project on JAVA,,i m begnner for this,,,plzzzzzz
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.