public abstract class Player<T> extends OutputPlugin<T> implements MusicProvider, ResourceBuilderModel, MusicHelper, EventListenerModel
How to use it:
Usage is pretty straightforward. Extend this class an override the abstract methods.
- To register further commands, use the getCommandHandler() method in the constructor.
- To start playing, use the PlayerController.startPlaying() methods, never call the play() method directly!
Also, don't call the stopSound() method directly, use stopMusicPlayback().
All basic methods are implemented in this class,but to code special behaviour fell free to explore the other
classes and interfaces.
Note: the playback automatically stops when the user left.
Constructor and Description |
---|
Player(Context context,
String id,
boolean runsInPlay,
boolean playRequestTrackInfo,
boolean providesTrackInfo,
boolean playbackShuffle,
boolean playbackRepeat,
boolean playbackRepeatSong,
boolean isUsingJava)
creates a new output-plugin with a new id
|
Player(Context context,
String id,
boolean runsInPlay,
Identifiable activator,
boolean providesTrackInfo,
boolean playbackShuffle,
boolean playbackRepeat,
boolean playbackRepeatSong,
boolean isUsingJava)
creates a new output-plugin with a new id
|
Player(Context context,
String id,
boolean runsInPlay,
List<Identifiable> activators,
boolean providesTrackInfo,
boolean playbackShuffle,
boolean playbackRepeat,
boolean playbackRepeatSong,
boolean isUsingJava)
creates a new output-plugin with a new id
|
Modifier and Type | Method and Description |
---|---|
List<? extends EventModel<?>> |
announceEvents()
this method is called to register for what Events it wants to provide Resources.
|
List<? extends ResourceModel> |
announceResources()
This method is called to register what resources the object provides.
just pass a List of Resources without Data in it. |
protected CommandHandler |
createCommandHandler()
override this method if you want to change the command handler
|
void |
eventFired(EventModel eventModel) |
protected void |
fireStartMusicRequest(EventModel eventModel)
this method will be called to create and fire the StartMusicRequest
|
Capabilities |
getCapabilities()
gets the Capabilities of the Player
|
CommandHandler |
getCommandHandler()
returns the CommandHandler
|
Playlist |
getCurrentPlaylist()
gets the current Playlist
|
Progress |
getCurrentProgress()
gets the Progress
|
PlaybackState |
getPlaybackState()
gets the PlaybackState of the Player
|
Volume |
getVolume()
gets the Volume
|
boolean |
isOutputRunning()
true if playing and false if not
|
boolean |
isPlaying()
true if playing and false if not
|
boolean |
isUsingJava()
true if using java, false if not (and for example a C-library)
|
abstract void |
mute()
this method call must mute the plugin.
|
void |
pausePlaying()
signals that the playing paused
|
abstract void |
play(EventModel eventModel)
this method will be called if a request was cached which was eligible to start the music.
please check the events resources for parameters (if expected). |
List<ResourceModel> |
provideResource(List<? extends ResourceModel> resources,
Optional<EventModel> event)
This method is called when an object wants to get a Resource.
|
void |
renderFinalOutput(List<T> data,
EventModel eventModel)
method that uses the data from the OutputExtensions to generate a final output that will then be rendered.
|
void |
resumePlaying()
signals that the playing resumed
|
void |
rollBackToDefault()
sets every information into its default state (playlist, volume, etc...)
|
void |
stop() |
void |
stopMusicPlayback()
stops the playing/indicates that the playing stopped.
|
abstract void |
stopSound()
this method call must stop the sound.
NEVER CALL THIS METHOD DIRECTLY, USE stopMusicPlayback() . |
void |
trackInfoUpdate(Playlist playlist,
TrackInfo info)
call this method if the trackInfo object in the playlist was updated.
|
abstract void |
unMute()
this method call must un-mute the plugin.
|
void |
updateCurrentTrackInfo(TrackInfo trackInfo)
checks if the trackInfo is an update and fires the appropriate Event.
|
void |
updatePlayInfo(Playlist playlist)
fires an update event which notifies that parameters have changed
|
void |
updatePlayInfo(Playlist playlist,
Progress progress,
TrackInfo trackInfo,
Volume volume)
fires an update event which notifies that parameters have changed
|
void |
updatePlayInfo(Playlist playlist,
Progress progress,
Volume volume)
updates the Info about the current song
|
void |
updatePlayInfo(Progress progress)
fires an update event which notifies that parameters have changed
|
void |
updatePlayInfo(Volume volume)
fires an update event which notifies that parameters have changed
|
getArgument, getArgumentType
addToEventList, blockingQueueHandling, getEventBlockingQueue, getOutputExtensionList, getReceivingType, getTimeoutLimit, handleFutures, isDone, isRunning, outputExtensionAdded, outputExtensionRemoved, run, terminate
getContext, getID
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
playerError, playerError, startedSound, startedSound, updatePlayInfo, updateStateInfo
endedSound
fire, fire, fire, fire, fire
debug, debug, error, error, getContext
getID, isOwner
submit, submit, submit, submitRun, timeOut, timeOut
debug, debug, error, error, fatal, fatal, warn, warn
exceptionThrown
public Player(Context context, String id, boolean runsInPlay, List<Identifiable> activators, boolean providesTrackInfo, boolean playbackShuffle, boolean playbackRepeat, boolean playbackRepeatSong, boolean isUsingJava)
context
- contextid
- the id of the new output-plugin. The ID of the InformationProvider is also based on this id
(id + ".InformationProvider")runsInPlay
- whether the termination of the play method should be treated as the termination the
music (STOP not PAUSE)activators
- the activators which are able to start the Player if the Player is not able to start from
request from other addonsprovidesTrackInfo
- whether the Player provides TrackInfoplaybackShuffle
- whether the player is able to provide the info that the playback is shufflingplaybackRepeat
- whether the player is able to provide the info that the playback is repeatingplaybackRepeatSong
- whether the player is able to provide the info that the playback is repeating the songisUsingJava
- true if using java, false if not (and for example a C-library)public Player(Context context, String id, boolean runsInPlay, Identifiable activator, boolean providesTrackInfo, boolean playbackShuffle, boolean playbackRepeat, boolean playbackRepeatSong, boolean isUsingJava)
context
- contextid
- the id of the new output-plugin. The ID of the InformationProvider is also based on this id
(id + ".InformationProvider")runsInPlay
- whether the termination of the play method should be treated as the termination the
music (STOP not PAUSE)activator
- the activator which is able to start the Player if the Player is not able to start from
request from other addonsprovidesTrackInfo
- whether the Player provides TrackInfoplaybackShuffle
- whether the player is able to provide the info that the playback is shufflingplaybackRepeat
- whether the player is able to provide the info that the playback is repeatingplaybackRepeatSong
- whether the player is able to provide the info that the playback is repeating the songisUsingJava
- true if using java, false if not (and for example a C-library)public Player(Context context, String id, boolean runsInPlay, boolean playRequestTrackInfo, boolean providesTrackInfo, boolean playbackShuffle, boolean playbackRepeat, boolean playbackRepeatSong, boolean isUsingJava)
context
- contextid
- the id of the new output-pluginrunsInPlay
- whether the termination of the play method should be treated as the termination of playing the
musicplayRequestTrackInfo
- whether the player is able to process PlayRequests with TrackInfoprovidesTrackInfo
- whether the Player provides TrackInfoplaybackShuffle
- whether the player is able to provide the info that the playback is shufflingplaybackRepeat
- whether the player is able to provide the info that the playback is repeatingplaybackRepeatSong
- whether the player is able to provide the info that the playback is repeating the songisUsingJava
- true if using java, false if not (and for example a C-library)public CommandHandler getCommandHandler()
public boolean isOutputRunning()
isOutputRunning
in interface MusicProvider
isOutputRunning
in interface PermanentSoundUsed
public boolean isPlaying()
isPlaying
in interface MusicProvider
public boolean isUsingJava()
isUsingJava
in interface MusicProvider
isUsingJava
in interface PermanentSoundUsed
public void stopMusicPlayback()
this method has no effect if runsInPlay is enabled in the constructor.
public Playlist getCurrentPlaylist()
getCurrentPlaylist
in interface MusicProvider
public void updatePlayInfo(Playlist playlist)
updatePlayInfo
in interface MusicHelper
playlist
- the optional playlistpublic void updateCurrentTrackInfo(TrackInfo trackInfo)
public void trackInfoUpdate(Playlist playlist, TrackInfo info)
playlist
- the playlistinfo
- the new trackInfo objectpublic Volume getVolume()
getVolume
in interface MusicProvider
public void updatePlayInfo(Volume volume)
updatePlayInfo
in interface MusicHelper
volume
- the optional volumepublic Progress getCurrentProgress()
getCurrentProgress
in interface MusicProvider
public void updatePlayInfo(Progress progress)
updatePlayInfo
in interface MusicHelper
progress
- the optional progresspublic PlaybackState getPlaybackState()
getPlaybackState
in interface MusicProvider
public void pausePlaying()
public void resumePlaying()
public void updatePlayInfo(Playlist playlist, Progress progress, Volume volume)
playlist
- the playlist, or nullprogress
- the progress, or nullvolume
- the volume, or nullpublic void updatePlayInfo(Playlist playlist, Progress progress, TrackInfo trackInfo, Volume volume)
updatePlayInfo
in interface MusicHelper
playlist
- the optional playlistprogress
- the optional progresstrackInfo
- the optional trackInfovolume
- the optional volumepublic Capabilities getCapabilities()
getCapabilities
in interface MusicProvider
public List<? extends ResourceModel> announceResources()
announceResources
in interface ResourceBuilderModel
public List<? extends EventModel<?>> announceEvents()
The Event has to be in the following format: It should contain only one Descriptor and and one Resource with the ID "description", which contains an description of the Event.
announceEvents
in interface ResourceBuilderModel
public List<ResourceModel> provideResource(List<? extends ResourceModel> resources, Optional<EventModel> event)
Don't use the Resources provided as arguments, they are just the requests. There is a timeout after 1 second.
provideResource
in interface ResourceBuilderModel
resources
- a list of resources without dataevent
- if an event caused the action, it gets passed. It can also be null.public void renderFinalOutput(List<T> data, EventModel eventModel)
renderFinalOutput
in class OutputPlugin<T>
data
- the data generatedeventModel
- the Event which caused the whole thingprotected CommandHandler createCommandHandler()
protected void fireStartMusicRequest(EventModel eventModel)
eventModel
- the causepublic void stop()
stop
in interface OutputPluginModel<Object,T>
stop
in class OutputPluginArgument<Object,T>
public void eventFired(EventModel eventModel)
eventFired
in interface EventListenerModel
public void rollBackToDefault()
public abstract void mute()
public abstract void unMute()
public abstract void stopSound()
stopMusicPlayback()
.public abstract void play(EventModel eventModel)
eventModel
- the causeCopyright © 2016. All rights reserved.