Help Me to make playlist song

how to add the new song from jfilechooser but the older playlist is saved in table or another.
so how to add many song in playlist, i want to make a media player with javaFX.
thanks i need help for my study

Hi,
I did it in my app: adding songs to a table. The first thing to do is to create a JavaBean that contains the information you want inside your table. When doing this you have to respect the conventions defined by JFX for properties (you can find them here: http://docs.oracle.com/javafx/2/binding/jfxpub-binding.htm)
For example I created a Song class:
public class Song implements Serializable {
    private ReadOnlyObjectProperty<Media> media;
    private ReadOnlyStringProperty artist;
    private ReadOnlyStringProperty album;
    private ReadOnlyStringProperty title;
    private ReadOnlyStringProperty duration;
    public Song(URI uri) {
        if (uri == null) {
            throw new NullPointerException("Can not create the song with a null URI");
        this.media = new SimpleObjectProperty<>(new Media(uri.toString()));
        this.artist = new SimpleStringProperty("Unknown");
        this.album = new SimpleStringProperty("Unknown");
        this.title = new SimpleStringProperty("Unknow");
        this.duration = new SimpleStringProperty("--:--:--");
        this.media.get().getMetadata().addListener(new MapChangeListener<String, Object>() {
            @Override
            public void onChanged(Change<? extends String, ? extends Object> change) {
                if (change.getKey().equals("title")) {
                    if (change.wasAdded()) {
                        ((SimpleStringProperty) Song.this.titleProperty()).set(change.getValueAdded().toString());
                    } else {
                        ((SimpleStringProperty) Song.this.titleProperty()).set("Unknown");
                } else if (change.getKey().equals("artist")) {
                    if (change.wasAdded()) {
                        ((SimpleStringProperty) Song.this.artistProperty()).set(change.getValueAdded().toString());
                    } else {
                        ((SimpleStringProperty) Song.this.artistProperty()).set("Unknown");
                } else if (change.getKey().equals("album")) {
                    if (change.wasAdded()) {
                        ((SimpleStringProperty) Song.this.albumProperty()).set(change.getValueAdded().toString());
                    } else {
                        ((SimpleStringProperty) Song.this.albumProperty()).set("Unknown");
        this.media.get().durationProperty().addListener(new InvalidationListener() {
            @Override
            public void invalidated(Observable o) {
                if(media.get().durationProperty().get() == Duration.UNKNOWN) {
                    ((SimpleStringProperty) duration).set("--:--:--");
                } else {
                    double initialTime = media.get().durationProperty().get().toSeconds();
                    int numberOfHour = (int) initialTime / 3600;
                    int numberOfMinutes;
                    int numberOfSeconds;
                    double remainingTime = initialTime % 3600;
                    if (remainingTime == 0) {
                        numberOfMinutes = 0;
                        numberOfSeconds = 0;
                    } else {
                        numberOfMinutes = (int) remainingTime / 60;
                        numberOfSeconds = (int) remainingTime % 60;
                    ((SimpleStringProperty) duration).set(String.format("%1$02d:%2$02d:%3$02d", numberOfHour, numberOfMinutes, numberOfSeconds));
    public final String getArtist() {
        return this.artistProperty().get();
    public ReadOnlyStringProperty artistProperty() {
        return this.artist;
    public final String getAlbum() {
        return this.albumProperty().get();
    public ReadOnlyStringProperty albumProperty() {
        return this.album;
    public final String getTitle() {
        return this.titleProperty().get();
    public ReadOnlyStringProperty titleProperty() {
        return this.title;
    public final String getDuration() {
        return this.durationProperty().get();
    public ReadOnlyStringProperty durationProperty() {
        return this.duration;
    public final Media getMedia() {
        return this.mediaProperty().get();
    public ReadOnlyObjectProperty<Media> mediaProperty() {
        return this.media;
}And then, when you have your TableView, you can do something like this:
public class MusicController implements Initializable {
    TableView<Song> songsTableView;
    @FXML
    private TableColumn<Song, String> titleColumn;
    @FXML
    private TableColumn<Song, String> albumColumn;
    @FXML
    private TableColumn<Song, String> artistColumn;
    @FXML
    private TableColumn<Song, Duration> durationColumn;
    @Override
    public void initialize(URL arg0, ResourceBundle arg1) {
        this.artistColumn.setCellValueFactory(new PropertyValueFactory<Song, String>("artist"));
        this.albumColumn.setCellValueFactory(new PropertyValueFactory<Song, String>("album"));
        this.titleColumn.setCellValueFactory(new PropertyValueFactory<Song, String>("title"));
        this.durationColumn.setCellValueFactory(new PropertyValueFactory<Song, Duration>("duration"));
}And to add a song to the table, you just need to do something like this:
this.songsTableView.getItems().add(new Song(file.toURI()));And the rest is done for you :)
I didn't implement a double-click event yet.

Similar Messages

  • HELP!  I subscribed to imatch on my mac so that I could access the songs anywhere with my iphone.  However since I live in a rural community I would like to make playlists that always stay on my phone in case I don't have service.  Not sure how.

    HELP!  I subscribed to imatch on my mac so that I could access the songs anywhere with my iphone.  However since I live in a rural community I would like to make playlists that always stay on my phone in case I don't have service.  Not sure how.

    I have the same issue.  While I am sure your solution would work, my playlist has over 6,000 songs and hiting every song to download it is not very practical.  Is there another way?
    I am looking to have a subset of my music physically on my phone so that I can play it without internet access, but have access to the entire library when I do have internet access. 

  • My Itunes is no longer allowing me to manage my music on my phone i can no longer select on my iphone to make playlists and delete music. Please help fix my problem.

    My Itunes is no longer allowing me to manage my music on my phone i can no longer select on my iphone to make playlists and delete music. Please help fix my problem. Iphone4s, 32gigs, IOS 7.1.2
    I don't know why it stopped working but it happened a month or two ago but the option on this phone that's usually all the way to the left when you select your device but now its not and I don't know what caused it. ive already tried troubleshooting my problem but have found no help.

    Hello Salmomma,
    Thank you for the details of the issue you are experiencing when trying to connect your iPhone to your Mac.  I recommend following the steps in the tutorial below for an issue like this:
    iPhone not appearing in iTunes
    http://www.apple.com/support/iphone/assistant/itunes/
    Additionally, you can delete music directly from the iPhone by swiping the song:
    Delete a song from iPhone: In Songs, swipe the song, then tap Delete.
    iPhone User Guide
    http://manuals.info.apple.com/MANUALS/1000/MA1658/en_US/iphone_ios6_user_guide.p df
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • When I went to bed I had 3,000  song and multiple playlists.  This morning I have ~30 songs and no playlists.  What could have happened to my songs playlists?  I run iTunes on a Windows 7 64-bit machine.  HELP! (oh, and the Songs are not in recycle bin)

    When I went to bed I had 3,000  song and multiple playlists.  This morning I have ~30 songs and no playlists.  What could have happened to my songs playlists?  I run iTunes on a Windows 7 64-bit machine.  HELP! (oh, and the Songs are not in recycle bin)
    My wife's ipod nano was plugged into the machine overnight.
    When she went running with it, there were no songs on it.  She checked the computer and was horrified to see that the playlists had disappeared and most of the songs had disappeared.
    QUESTIONS:
    1. What could it be?
    2. How can I fix it?

    Hi, there alot of us suffering from this phernomonon but there is a forum topic about is already.
    https://discussions.apple.com/message/16767377#16767377
    Come check it out.
    Hope this works out for all of us.

  • I bought a new laptop and can access my itunes library but when i try to add purchased playlist songs to my ipod message appears asking if I'm ok with erasing all other songs on the ipod. Help needed.

    I bought a new laptop and can access my itunes library but when i try to add purchased playlist songs to my ipod message appears asking if I'm ok with erasing all other songs on the ipod. How do I add purchased playlist to ipod without erasing existing ipod playlists?

    cujoftw wrote:
    wow ... I get a headache just trying to read what you just said. I went and read how to migrate my library and found that you can only migrate purchased media.
    No, you can easily migrate your entire library from one working compter to another.
    If you fail to backup or migrate your library and find yourself with nothing but a new empty computer and a device full of content iTunes is designed to only recover the iTunes purchased content, however third party tools can help recover everything if needed.
    tt2

  • How to make playlist of the video songs I have installed from computer

    How to make playlist of video songs I have installed from computer

    What on earth do you mean by "video songs"?

  • How to make playlist in Nokia 6300

    Hi,
    I bought nokia 6300 without knowing that it won't allow to make playlist
    Can anyone help me or is there any way to make playlist of your own choice I guess it should allow to make playlist its very basic thing which is supposed to be in mp3 supported mobiles
    Thanks,
    Message Edited by shameers on 19-Aug-2008 08:57 AM
    Solved!
    Go to Solution.

    You can create a playlist using Nokia Music Manager (PC Suite application). Then, transfer the playlist to your phone.
    Select songs you want and then choose File > Create new playlist.
    Should be draggable/copy-able just like music files after it's created.
    "Try not. Do or do not, there is no try."
    If you found someone's comments helpful or like what that person has to say, please give some Kudos to the post!

  • New computer can't make playlists

    I purchased a new computer because my otherone was dying.  I have transfered all of my itunes songs to the new computer and deauthorized the old computer but now cannot make playlists.  Can anyone help me?

    Ok, i'm progressing - I think.  I have my library - have found the left column where the playlists are located - but the playlists on my phone aren't appearing in my library.  The phone appears to sync - goes through steps 1, 2 and 3 but nothing happens.  There is no indication on my phone that it is connected to itunes. ???

  • How to make Playlist for Nokia N79 on PC?

    Hello
    I have Nokia N79.
    I want to make playlist for it on PC.
    I tried using Ovi Player software but was not able to create playlist with it.
    Please help me out.
     Tell me easiet way to create and manage playlist for Nokia N79.
    Thanks.

    You can create a playlist on the phone in music player, or create one in Windows Media Player ans sync with phone. Or just select all songs and play random.
    Good Luck
    If I have helped at all, a click on the White Star is always appreciated :
    you can also help others by marking 'accept as solution' 

  • How can I make playlists and update ipod from music stored on a NAS?

    I recently bought a new computer and before doing so, I transferred all my mp3/music files onto my NAS device.  I am able to share that music and play it from my Itunes, but I cannot make playlists from it or update my ipod.  I tried searching and following what some people have said with no luck.  Please help, as I'd like to keep all my music files on the NAS and not have them taking up space on my local computer hard drive.

    Read my blog :
    [Create and add a TABLE in iWeb|http://www.wyodor.net/blog/archives/2010/01/entry_297.html]
    [More about a TABLE in iWeb|http://www.wyodor.net/blog/archives/2010/01/entry_298.html]

  • How do I get iTunes to show up so I can make playlists and burn CD's as I was able to do in MAC OS X Snow Leopard?  I upgraded to MAVERICKS so that I could have iCloud capabilities.

    How do I get iTunes to show up so I can make playlists and burn CD's as I was able to do in MAC OS X Snow Leopard?  I upgraded to MAVERICKS so that I could have iCloud capabilities.

    Hi ...
    Help here >  iTunes 11 for Mac: Create a playlist

  • Change Playlist song order

    How can I make the songs on a playlist play in numerical order in my iPod shuffle?  They are playing in alphabetical order by song title.

    The 4th (and 3rd gen) shuffle can hold multiple playlists like the other "big" iPods.  If you are looking at the main music list for the shuffle in iTunes, that is not a "playlist" (it is the shuffle's music library).  That list cannot be re-ordered like a playlist, just as you cannot re-order songs in your main iTunes music library.
    If you load the shuffle manually, buy dragging songs to the shuffle, this is what you need to do.  Select the shuffle in the iTunes sidebar, under DEVICES.  NOTE:  If the iTunes sidebar (along left side of window) is not visible, from the menu bar, under View, select Show Sidebar.
    Click the small triangle to the left of the shuffle name in the sidebar, to show its content list (indented below the shuffle).  Playlists on the shuffle appear there, on the content list.  If there are no playlists shown there, with the shuffle's name selected, click the plus sign at the bottom of the sidebar to create a new playlist.  A playlist appears on the shuffle's content list, where you can name it.
    When loading the shuffle by dragging songs to it, drag the songs to this playlist.  That adds the song to the shuffle and to that particular playlist.  Since this is a playlist, you can select it and re-order the songs as desired.  When you play the shuffle, use VoiceOver to select that playlist (instead of playing from the All Songs list).  The songs will play in playlist order, if the shuffle's power switch is on the play-in-order (middle) position.

  • Can't make playlists from selections in iTunes 8

    Can't click on the selections I want to make into playlists and either choose that option from the pull down menu or use the key command. As others are saying, iTunes 8 is quite buggy.

    I am choosing a song or songs from the library and then trying to use the key command (shift command N) to make a playlist from them. However, although I've been doing this for years, I can't do it in iTunes 8. Neither can I choose the song or songs and then make a playlist out of them using the pull down File menu item "Make Playlist from Selection." That menu item is darkened, not available.
    Yes, I can still make a new folder, manually name it, then drag and drop the songs into it.

  • How do i make a song on my iphone a ringtone for a contact

    how do i make a song on my iphone a ringtone for a contact

    Songs and ringtones are not interchangeable.  A song needs to be converted to a ringtone.
    If you have a Mac, you can do that conversion using GarageBand.  See GarageBand's help for details.  If you have a Windows computer, there are third party apps that do the conversion, but I don't know any details.

  • How do I make playlists again

    How do I make playlist with my songs.  I don't like the playlist not being on the left side.

    By enabling the side bar and selecting the "Songs" button, iTunes 11 feels alot more like iTunes 10,
    http://www.ilounge.com/index.php/tips/comments/re-enabling-the-sidebar-in-itunes -11/
    After that it is easy.

Maybe you are looking for