|
 |
|
01-25-2008, 05:53 PM
|
#1
|
|
FLAC
Join Date: May 2006
Location: Calgary, Alberta
Posts: 936
|
Building A Completely Java Based Front End
Not sure what I'll call it yet but it'll be completely Java based and the front end will be separate from the back end so you'll be able to build your own GUI and run it on your machine if you're so inclined. But here's what I have after just a few days....more questions than anything really....
Here's a hacked up version of the skin I'm using now with a few new features added:
The top bar will display the current song and to the right of it is a digital clock. The bottom left is a slider style control for the volume and above that is a box containing the heading and next to that is the temperature in the car with up/down arrows for controlling it. Functionality not important for now.
So here are the containers I was going to build to hold all this stuff:
In this image I've got the JFrame which will be 800x600 and three containers inside the JFrame labeled 1, 2 and 3.
Each container will hold more containers:
Each of those containers holds more contianers:
And each of those containers will contain a bunch of JPanels which will eventually each contain a button or label:
Now I have a few questions:
1. Am I doing this totally wrong? I know it will work but what's better for laying it out?
2. Do I have to add containers to the JFrame and then JPanels to the container and then labels tot he JPanels and then buttons to the labels? Can I just add buttons to the Frame, or JPanels straight to the JFrame or any other weird combination?
3, Any other ideas?
__________________
Ampie Case
2.5" Hard Drive 80GB Toshiba 5400rpm
Kingston 512 MB DDR RAM PC3200
Xenarc 700TSV - VGA Monitor
VIA EPIA M10000 Mini-ITX Mainboard
M1-ATX 90 Watt - Smart Power Supply
2005 Honda Civic
|
|
|
|
|
|
Advertisement
|
Sponsored links
|
01-26-2008, 11:35 AM
|
#2
|
|
Variable Bitrate
Join Date: Aug 2006
Location: Clearfield Utah USA
Posts: 396
|
having panels/containters isn't a "bad" idea it just seems rather limiting.
I am also just wondering, why java?
keep up the good work
__________________
OpenICE - "The Car Entertainment Platform"
http://openice.org
LinuxICE IRC chatroom: #linuxice irc.freenode.com
|
|
|
01-26-2008, 01:35 PM
|
#3
|
|
FLAC
Join Date: May 2006
Location: Calgary, Alberta
Posts: 936
|
It's the only language I know. Why does everyone ask that? Who cares.
__________________
Ampie Case
2.5" Hard Drive 80GB Toshiba 5400rpm
Kingston 512 MB DDR RAM PC3200
Xenarc 700TSV - VGA Monitor
VIA EPIA M10000 Mini-ITX Mainboard
M1-ATX 90 Watt - Smart Power Supply
2005 Honda Civic
|
|
|
01-26-2008, 01:40 PM
|
#4
|
|
Fusion Brain Creator
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 7,439
|
Quote: Originally Posted by kev000 
having panels/containters isn't a "bad" idea it just seems rather limiting.
I am also just wondering, why java?
Quote: Originally Posted by Maheriano 
It's the only language I know. Why does everyone ask that? Who cares.
We ask because Java is very limiting, bloated, and slow. It is cross platform though so you may get that first all OS support that no-body has. But you do know that java is one of the slowest languages, so smoothness will be hard to achieve with big graphics and low-end media.
But I dont think this has been done before, so keep at it!
As for how to do it, I am pretty sure the best way to do it, would be to just put everything in 1 panel. Define where by point locations and size. This way you are not limited by the number of panels. Then when a click happens, iterate through every thing in that 1 panel, until the mouse intersects that area.
|
|
|
01-26-2008, 03:25 PM
|
#5
|
|
FLAC
Join Date: May 2006
Location: Calgary, Alberta
Posts: 936
|
Been working on it yesterday and today.
__________________
Ampie Case
2.5" Hard Drive 80GB Toshiba 5400rpm
Kingston 512 MB DDR RAM PC3200
Xenarc 700TSV - VGA Monitor
VIA EPIA M10000 Mini-ITX Mainboard
M1-ATX 90 Watt - Smart Power Supply
2005 Honda Civic
|
|
|
01-26-2008, 11:17 PM
|
#6
|
|
FLAC
Join Date: May 2006
Location: Calgary, Alberta
Posts: 936
|
Been coding all day, even took it to the restaurant while waiting for food.
Clock - dynamically pulls current time from computer clock
Songs - dynamically pulls current files located in predetermined songs directory. Doesn't yet pull level 0 files, just top level.
Album Cover - doesn't yet pull dynamically
Buttons - not yet mapped to anything
__________________
Ampie Case
2.5" Hard Drive 80GB Toshiba 5400rpm
Kingston 512 MB DDR RAM PC3200
Xenarc 700TSV - VGA Monitor
VIA EPIA M10000 Mini-ITX Mainboard
M1-ATX 90 Watt - Smart Power Supply
2005 Honda Civic
|
|
|
02-12-2008, 08:20 PM
|
#7
|
|
FLAC
Join Date: May 2006
Location: Calgary, Alberta
Posts: 936
|
updates:
- song list recursively populated from a specified directory
- double tap a song in the list and it plays
- double tap a new song in the list and the first one stops, the new one plays
- new buttons
__________________
Ampie Case
2.5" Hard Drive 80GB Toshiba 5400rpm
Kingston 512 MB DDR RAM PC3200
Xenarc 700TSV - VGA Monitor
VIA EPIA M10000 Mini-ITX Mainboard
M1-ATX 90 Watt - Smart Power Supply
2005 Honda Civic
|
|
|
02-16-2008, 05:18 PM
|
#8
|
|
FLAC
Join Date: May 2006
Location: Calgary, Alberta
Posts: 936
|
Is anyone even following this thread?
Had some more time yesterday. I'm not doing much at work right now so I got a lot of time to browse the Swing forums over at Sun.
- to play a song you can double click the song name or single click it and hit play
- song list is just song names now, not the full path
- when you play a song it loads the song name up top
- buttons fit to window
- volume bar which moves from green to red to control volume
- border removed around song list
- album cover loads when song is played
__________________
Ampie Case
2.5" Hard Drive 80GB Toshiba 5400rpm
Kingston 512 MB DDR RAM PC3200
Xenarc 700TSV - VGA Monitor
VIA EPIA M10000 Mini-ITX Mainboard
M1-ATX 90 Watt - Smart Power Supply
2005 Honda Civic
|
|
|
02-16-2008, 05:22 PM
|
#9
|
|
Fusion Brain Creator
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 7,439
|
I check in every now and then to see what you've got.
|
|
|
02-16-2008, 06:11 PM
|
#10
|
|
FLAC
Join Date: May 2006
Location: Calgary, Alberta
Posts: 936
|
That makes me feel better!
__________________
Ampie Case
2.5" Hard Drive 80GB Toshiba 5400rpm
Kingston 512 MB DDR RAM PC3200
Xenarc 700TSV - VGA Monitor
VIA EPIA M10000 Mini-ITX Mainboard
M1-ATX 90 Watt - Smart Power Supply
2005 Honda Civic
|
|
|
02-20-2008, 08:11 PM
|
#11
|
|
It ain't easy being a green moderator
Join Date: Aug 2002
Location: Steps out the front of Henson's workshop or Sydney
Posts: 2,257
|
I always keep an eye on frontends. It is always good to see what is being developed.
__________________
Never let the truth get in the way of a good story
Chat on the mp3car channel on IRC
Server: efnet Channel: #mp3car
No irc client installed? Go to http://chat.efnet.org/. In the channel drop down box select "other" and type in #mp3car.
|
|
|
02-22-2008, 10:38 AM
|
#12
|
|
Low Bitrate
Join Date: Jan 2006
Location: Duluth, GA
Posts: 110
|
Challenges
How much time have you spent researching the challenges involved in making a truly great Java front-end? By 'great', I mean that people would prefer your app over what is currently on the market, regardless of price.
I've been building simple test cases for a while now, and I have yet to find a cost effective solution to the following...
1. DRM infected music. There are a lot of people with subscriptions to music services. These people will naturally expect their music to play on their carpc. How would you play subscription-downloaded music in a cross platform manner? Sure, you could always write a wrapper around WMP (or buy one), but then you kill the cross platform compatability.
2. Navigation. You can use Java to access the GPS receiver, but then you have the challenge of how to display it. You could use one of the online map providers, but that would require users to be always connected to the internet. Again, you could write a wrapper around mappoint or some other sdk, but you kill the cross platform part. I've searched and searched for a Java solution, but came up empty every time.
These are the hard challenges. If you can think of a way around them, I'd be happy to help you out.
@The Java-haters above: java itself is not slow, the recent jres (1.5+) have great performance. Cold startup time is admittedly an issue. However, once the jre starts, you would be hard pressed to see the performance difference.
|
|
|
02-27-2008, 12:06 PM
|
#13
|
|
FLAC
Join Date: May 2006
Location: Calgary, Alberta
Posts: 936
|
1. WTF is DRM?
2. For navigation I would just embed iGuidance again, I'm not looking for something cross platform, this is simply a front end for me specifically. And if anyone else likes it then they can use it too!
But I'm kind of stuck right now as to how I skip to a specified portion of the audio file after moving the slider. I can't figure that out. I don't see any methods that take a byte/frame position in the file as a parameter to use as a starting point.
__________________
Ampie Case
2.5" Hard Drive 80GB Toshiba 5400rpm
Kingston 512 MB DDR RAM PC3200
Xenarc 700TSV - VGA Monitor
VIA EPIA M10000 Mini-ITX Mainboard
M1-ATX 90 Watt - Smart Power Supply
2005 Honda Civic
|
|
|
02-27-2008, 12:21 PM
|
#14
|
|
Low Bitrate
Join Date: Jan 2006
Location: Duluth, GA
Posts: 110
|
1. DRM = Digital Rights Management, aka restricted files. This is put on files that you download from music subscription services (Napster, iTunes, etc...)
2. It seems odd to use Java to write a platform specific application. If I was going to write for windows only, I'd just use C# or VB, which allow much tighter integration into the underlying platform. I know you only know Java right now, but this may be a good excuse for you to learn C# (very Java-like). It looks good on a resume to know more than one language anyhow.
3. If you were able to pull off a great, fully cross platform frontend in Java, you'd be a star at the next JavaOne.
4. What method are you using to play music files? Maybe I can help you on the seek functionality.
|
|
|
02-27-2008, 01:36 PM
|
#15
|
|
FLAC
Join Date: May 2006
Location: Calgary, Alberta
Posts: 936
|
Quote: Originally Posted by coffeejolts 
1. DRM = Digital Rights Management, aka restricted files. This is put on files that you download from music subscription services (Napster, iTunes, etc...)
2. It seems odd to use Java to write a platform specific application. If I was going to write for windows only, I'd just use C# or VB, which allow much tighter integration into the underlying platform. I know you only know Java right now, but this may be a good excuse for you to learn C# (very Java-like). It looks good on a resume to know more than one language anyhow.
3. If you were able to pull off a great, fully cross platform frontend in Java, you'd be a star at the next JavaOne.
4. What method are you using to play music files? Maybe I can help you on the seek functionality.
DRM......right, but I don't understand what the issue is. Just put it in your car and play it........it doesn't work? Why would anyone buy a song you can't port?
I'm using the Java Media Framework (JMF) to play the songs right now, I wrote my own player for it by creating an AudioInputStream and reading from the file, then writing to the stream. I've posted it a few times on the Java forums at Sun but no luck, not even any replies. Here's the Player class I wrote:
Quote:
import java.io.File;
import java.io.IOException;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.BooleanControl;
import javax.sound.sampled.Control;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.FloatControl.Type;
import javax.swing.SwingUtilities;
public class Player
{
public Player()
{
}
public void playSong(String song)
{
final String songLocation = song;
{
try
{
File file = new File(songLocation);
fileSize = file.length();
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);
line = (SourceDataLine) AudioSystem.getLine(info);
if (line != null)
{
line.open(decodedFormat);
data = new byte[4096];
// Start
line.start();
long percentageOfFileRead;
long numberOfBytesRead;
while ((nBytesRead = din.read(data, 0, data.length)) != -1)
{
line.write(data, 0, nBytesRead);
System.out.println("Frame length = " + din.getFrameLength());
numberOfBytesRead = fileSize - in.available();
percentageOfFileRead = (numberOfBytesRead * 100) / fileSize;
MusicGUI.songSlider.setValue((int)percentageOfFile Read);
}
// Stop
/* line.drain();
line.stop();
line.close();
din.close();*/
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(din != null)
{
try
{
din.close();
}
catch(IOException e)
{
System.out.println("Error: " + e);
}
}
}
}
try
{
Thread.sleep(800);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
public void stopSong()
{
if(din != null)
{
try
{
line.stop();
line.close();
din.close();
}
catch(IOException e)
{
System.out.println("Error: " + e);
}
}
}
public void muteLine()
{
/* control = (BooleanControl)line.getControl(BooleanControl.Typ e.MUTE);
if (control.getValue() == true)
{
control.setValue(false);
}
else
{
control.setValue(true);
}
*/
volumeControl = (FloatControl)line.getControl(FloatControl.Type.MA STER_GAIN);
if (volumeControl.getValue() == -80)
{
volumeControl.shift(-80, 6, 400000000);
}
else
{
volumeControl.setValue(-80);
}
}
public int getElapsedTime()
{
return nBytesRead;
}
public void setElapsedTime(int newPosition)
{
if(newPosition > 0)
{
temp = (int)fileSize * newPosition / 100;
System.out.println("File Size = " + fileSize);
System.out.println("Slider Position = " + newPosition);
System.out.println("Number of bytes to skip to = " + temp);
try
{
din.skip(500);
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
public String getVolume()
{
volumeControl = (FloatControl)line.getControl(FloatControl.Type.MA STER_GAIN);
return volumeControl.toString();
}
public void setVolume(int volume)
{
volumeControl = (FloatControl)line.getControl(FloatControl.Type.MA STER_GAIN);
volumeControl.setValue(volumeControl.getValue() + (float).1);
}
private long i = 0;
private int temp;
private long fileSize;
private byte[] data;
private int nBytesRead;
private SourceDataLine line = null;
private FloatControl volumeControl = null;
BooleanControl control = null;
AudioInputStream in = null;
AudioInputStream din = null;
}
Forget the getter / setter methods at the bottom, the place it's playing the song is this line:
Quote:
while ((nBytesRead = din.read(data, 0, data.length)) != -1)
{
line.write(data, 0, nBytesRead);
}
It's buffering 4096 bytes, writing (playing) it, then getting the next 4096 bytes and it does that for the whole song. It works perfect and the slider follows along with it but when I move the slider I can't get the song to jump, I'm lost at how to do this. Let me know if you want any more code. Thanks!
__________________
Ampie Case
2.5" Hard Drive 80GB Toshiba 5400rpm
Kingston 512 MB DDR RAM PC3200
Xenarc 700TSV - VGA Monitor
VIA EPIA M10000 Mini-ITX Mainboard
M1-ATX 90 Watt - Smart Power Supply
2005 Honda Civic
|
|
|
|
Sponsored links
|
|
Advertisement
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 07:05 AM.
| |