diff --git a/JavaXNA Test/src/Program.java b/JavaXNA Test/src/Program.java index a89a2c5..e1145fb 100644 --- a/JavaXNA Test/src/Program.java +++ b/JavaXNA Test/src/Program.java @@ -6,7 +6,20 @@ public class Program */ public static void main(String[] args) { - Game1 game = new Game1(); - game.Run(); + Game1 game = null; + + try + { + game = new Game1(); + + game.Run(); + } + finally + { + if (game != null) + { + game.Dispose(); + } + } } } diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/MediaPlayer.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/MediaPlayer.java index bdc3146..89e60a7 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/MediaPlayer.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/MediaPlayer.java @@ -9,9 +9,10 @@ import System.*; */ public class MediaPlayer { + private static MediaQueue queue; private static boolean repeat; private static boolean shuffle; - private static MediaQueue queue; + private static MediaState state; /** * Gets the media playback queue, MediaQueue. @@ -26,8 +27,20 @@ public class MediaPlayer */ public MediaState getState() { - // TODO Auto-generated method stub - throw new NotImplementedException(); + return state; + } + + private static void setState(MediaState value) + { + if (state != value) + { + state = value; + + if (MediaStateChanged.hasHandlers()) + { + MediaStateChanged.raise(null, EventArgs.Empty); + } + } } /** @@ -51,48 +64,51 @@ public class MediaPlayer { } + private static void NextSong(int direction) + { + // TODO: implement + + if (ActiveSongChanged.hasHandlers()) + { + ActiveSongChanged.raise(null, EventArgs.Empty); + } + } + /** - * + * Moves to the next song in the queue of playing songs. */ public static void MoveNext() { - if (!ActiveSongChanged.hasHandlers()) - { - ActiveSongChanged.raise(null, EventArgs.Empty); - } - - // TODO: implement + NextSong(1); } /** - * + * Moves to the previous song in the queue of playing songs. */ public static void MovePrevious() { - if (!ActiveSongChanged.hasHandlers()) - { - ActiveSongChanged.raise(null, EventArgs.Empty); - } - - // TODO: implement + NextSong(-1); } /** - * + * Pauses the currently playing song. */ public static void Pause() { - if (!MediaStateChanged.hasHandlers()) + if (state != MediaState.Playing || queue.getActiveSong() == null) { - MediaStateChanged.raise(null, EventArgs.Empty); + return; } // TODO: implement + throw new NotImplementedException(); } /** + * Plays a Song. * * @param song + * Song to play. */ public static void Play(Song song) { @@ -101,8 +117,10 @@ public class MediaPlayer } /** + * Plays a SongCollection. * * @param songs + * SongCollection to play. */ public static void Play(SongCollection songs) { @@ -111,9 +129,13 @@ public class MediaPlayer } /** + * Plays a SongCollection, starting with the Song at the specified index. * * @param songs + * SongCollection to play. + * * @param index + * Index of the song in the collection at which playback should begin. */ public static void Play(SongCollection songs, int index) { @@ -122,20 +144,21 @@ public class MediaPlayer } /** - * + * Resumes a paused song. */ public static void Resume() { - if (!MediaStateChanged.hasHandlers()) + if (state != MediaState.Paused) { - MediaStateChanged.raise(null, EventArgs.Empty); + return; } // TODO: implement + throw new NotImplementedException(); } /** - * + * Stops playing a song. */ public static void Stop() { @@ -145,5 +168,6 @@ public class MediaPlayer } // TODO: implement + throw new NotImplementedException(); } } diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/MediaQueue.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/MediaQueue.java index 604a861..7ec7eb3 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/MediaQueue.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/MediaQueue.java @@ -1,5 +1,7 @@ package Microsoft.Xna.Framework.Media; +import java.util.Random; + import System.*; /** @@ -9,16 +11,47 @@ import System.*; */ public final class MediaQueue { + private int activeSongIndex = -1; + private Random random = new Random(); + + /** + * Gets the current Song in the queue of playing songs. + * + * @return + * The current Song in the queue of playing songs. + */ public Song getActiveSong() { throw new NotImplementedException(); } + /** + * Gets the index of the current (active) song in the queue of playing songs. + * + * @return + * The index of the current (active) song in the queue of playing songs. + */ public int getActiveSongIndex() + { + return activeSongIndex; + } + + /** + * Sets the index of the current (active) song in the queue of playing songs. + * + * @param value + */ + public void setActiveSongIndex(int value) { throw new NotImplementedException(); } + /** + * Gets the amount of songs in the MediaQueue. + * + * @return + * The amount of songs in the MediaQueue. + */ public int getCount() { throw new NotImplementedException(); @@ -28,6 +61,13 @@ public final class MediaQueue { } + /** + * Gets the Song at the specified index in the MediaQueue. + * + * @param index + * + * @return + */ public Song get(int index) { throw new NotImplementedException();