Updated Program and MediaPlayer implementations
Added documentation
This commit is contained in:
parent
675695c5c0
commit
b9ce68510d
@ -6,7 +6,20 @@ public class Program
|
|||||||
*/
|
*/
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
Game1 game = new Game1();
|
Game1 game = null;
|
||||||
game.Run();
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
game = new Game1();
|
||||||
|
|
||||||
|
game.Run();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (game != null)
|
||||||
|
{
|
||||||
|
game.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,10 @@ import System.*;
|
|||||||
*/
|
*/
|
||||||
public class MediaPlayer
|
public class MediaPlayer
|
||||||
{
|
{
|
||||||
|
private static MediaQueue queue;
|
||||||
private static boolean repeat;
|
private static boolean repeat;
|
||||||
private static boolean shuffle;
|
private static boolean shuffle;
|
||||||
private static MediaQueue queue;
|
private static MediaState state;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the media playback queue, MediaQueue.
|
* Gets the media playback queue, MediaQueue.
|
||||||
@ -26,8 +27,20 @@ public class MediaPlayer
|
|||||||
*/
|
*/
|
||||||
public MediaState getState()
|
public MediaState getState()
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
return state;
|
||||||
throw new NotImplementedException();
|
}
|
||||||
|
|
||||||
|
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()
|
public static void MoveNext()
|
||||||
{
|
{
|
||||||
if (!ActiveSongChanged.hasHandlers())
|
NextSong(1);
|
||||||
{
|
|
||||||
ActiveSongChanged.raise(null, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: implement
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Moves to the previous song in the queue of playing songs.
|
||||||
*/
|
*/
|
||||||
public static void MovePrevious()
|
public static void MovePrevious()
|
||||||
{
|
{
|
||||||
if (!ActiveSongChanged.hasHandlers())
|
NextSong(-1);
|
||||||
{
|
|
||||||
ActiveSongChanged.raise(null, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: implement
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Pauses the currently playing song.
|
||||||
*/
|
*/
|
||||||
public static void Pause()
|
public static void Pause()
|
||||||
{
|
{
|
||||||
if (!MediaStateChanged.hasHandlers())
|
if (state != MediaState.Playing || queue.getActiveSong() == null)
|
||||||
{
|
{
|
||||||
MediaStateChanged.raise(null, EventArgs.Empty);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Plays a Song.
|
||||||
*
|
*
|
||||||
* @param song
|
* @param song
|
||||||
|
* Song to play.
|
||||||
*/
|
*/
|
||||||
public static void Play(Song song)
|
public static void Play(Song song)
|
||||||
{
|
{
|
||||||
@ -101,8 +117,10 @@ public class MediaPlayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Plays a SongCollection.
|
||||||
*
|
*
|
||||||
* @param songs
|
* @param songs
|
||||||
|
* SongCollection to play.
|
||||||
*/
|
*/
|
||||||
public static void Play(SongCollection songs)
|
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
|
* @param songs
|
||||||
|
* SongCollection to play.
|
||||||
|
*
|
||||||
* @param index
|
* @param index
|
||||||
|
* Index of the song in the collection at which playback should begin.
|
||||||
*/
|
*/
|
||||||
public static void Play(SongCollection songs, int index)
|
public static void Play(SongCollection songs, int index)
|
||||||
{
|
{
|
||||||
@ -122,20 +144,21 @@ public class MediaPlayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Resumes a paused song.
|
||||||
*/
|
*/
|
||||||
public static void Resume()
|
public static void Resume()
|
||||||
{
|
{
|
||||||
if (!MediaStateChanged.hasHandlers())
|
if (state != MediaState.Paused)
|
||||||
{
|
{
|
||||||
MediaStateChanged.raise(null, EventArgs.Empty);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Stops playing a song.
|
||||||
*/
|
*/
|
||||||
public static void Stop()
|
public static void Stop()
|
||||||
{
|
{
|
||||||
@ -145,5 +168,6 @@ public class MediaPlayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package Microsoft.Xna.Framework.Media;
|
package Microsoft.Xna.Framework.Media;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import System.*;
|
import System.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -9,16 +11,47 @@ import System.*;
|
|||||||
*/
|
*/
|
||||||
public final class MediaQueue
|
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()
|
public Song getActiveSong()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
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()
|
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();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of songs in the MediaQueue.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The amount of songs in the MediaQueue.
|
||||||
|
*/
|
||||||
public int getCount()
|
public int getCount()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
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)
|
public Song get(int index)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user