File tree Expand file tree Collapse file tree 4 files changed +45
-0
lines changed
Expand file tree Collapse file tree 4 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1717import com .redomar .game .gfx .Screen ;
1818import com .redomar .game .gfx .SpriteSheet ;
1919import com .redomar .game .level .LevelHandler ;
20+ import com .redomar .game .lib .Music ;
2021import com .redomar .game .net .GameClient ;
2122import com .redomar .game .net .GameServer ;
2223import com .redomar .game .net .packets .Packet00Login ;
@@ -108,6 +109,9 @@ public synchronized void start() {
108109 running = true ;
109110 new Thread (this ).start ();
110111
112+ Music music = new Music ();
113+ new Thread (music ).start ();
114+
111115 if (Jdata_Host == 0 ) {
112116 socketServer = new GameServer (this );
113117 socketServer .start ();
Original file line number Diff line number Diff line change 1+ package com .redomar .game .lib ;
2+
3+ import java .io .BufferedInputStream ;
4+ import java .io .FileInputStream ;
5+ import java .net .URL ;
6+
7+ import com .redomar .game .Game ;
8+
9+ import javazoom .jl .player .Player ;
10+
11+ public class Music implements Runnable {
12+
13+ private String file ;
14+ private Player musicPlayer ;
15+
16+ public Music (URL url ){
17+ this .file = url .toString ().substring (6 );
18+ }
19+
20+ public Music () {
21+
22+ }
23+
24+ public void Play (){
25+ try {
26+ FileInputStream inputFile = new FileInputStream (file );
27+ BufferedInputStream buffered = new BufferedInputStream (inputFile );
28+ musicPlayer = new Player (buffered );
29+ musicPlayer .play ();
30+ } catch (Exception e ) {
31+ System .out .println ("Problem playing file " + file );
32+ System .out .println (e );
33+ }
34+ }
35+
36+ @ Override
37+ public void run () {
38+ Music music = new Music (Game .class .getResource ("/music/yoshi.mp3" ));
39+ music .Play ();
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments