Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-18-2006, 11:26 AM   #1
Registered: Sep 2004
Distribution: debian sarge 64bit (AMD)
Posts: 709

Rep: Reputation: 30
playing a midi file in java

I want to be able to play stop and loop a midi file. However the code i have accepts a url object but I cant find a way to get that to point to the file on my hdd. it's a java program and not an applet

Last edited by linuxmandrake; 03-18-2006 at 11:30 AM.
Old 03-18-2006, 02:22 PM   #2
Mega Man X
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 64
Since you did not post any code and I don't feel like writing a midi player (you need threads, sequencers, etc), I will give you the basic idea. If you are going for a command line player (For example, to start your application like this: midiplayer <song.mid>), then do something like this:

public class Main {

    public static void main(String[] args) {
        if (args.length != 1) {
            System.out.println("Usage: java midiplayer <filename>");
        } else {
            MidiPlayer midiPlayer = new MidiPlayer(args[0]);
MidiPlayer is the code you have. Make two separated classes: One for the player one for the Mainclass. On the Player's constructor, you will pass the song name (a String).

If you post some code I could give you a hand

Last edited by Mega Man X; 03-18-2006 at 02:30 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
playing midi files? slinky2004 Linux - General 3 01-04-2006 04:08 PM
What package for playing CD and midi file satimis Linux From Scratch 25 09-30-2005 10:57 PM
Playing MIDI files under Mandrake KhmerDucky Linux - Software 1 06-09-2005 10:13 PM
Playing Midi in SuSE 9.2 Mic Q SUSE / openSUSE 5 01-12-2005 06:47 PM
Playing MIDI files rajan_kanwar Linux - Software 1 02-05-2004 05:46 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:38 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration