Skip to content

Commit

Permalink
add set/get method
Browse files Browse the repository at this point in the history
  • Loading branch information
chengenzhao committed Nov 2, 2017
1 parent 752134e commit ea4e00f
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/main/java/com/whitewoodcity/core/node/view/MediaView.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,69 +121,99 @@ public void dispose() {
}
}

public void setPaused(Runnable value){
paused(value);
}
public void paused(Runnable value) {
if(body!=null&&body.getMediaPlayer()!=null){
if(Platform.isFxApplicationThread()) body.getMediaPlayer().setOnPaused(value);
else Platform.runLater(() -> body.getMediaPlayer().setOnPaused(value));
}
}

public void setStopped(Runnable value){
stopped(value);
}
public void stopped(Runnable value) {
if(body!=null&&body.getMediaPlayer()!=null){
if(Platform.isFxApplicationThread()) body.getMediaPlayer().setOnStopped(value);
else Platform.runLater(() -> body.getMediaPlayer().setOnStopped(value));
}
}

public void setPlaying(Runnable value){
playing(value);
}
public void playing(Runnable value) {
if(body!=null&&body.getMediaPlayer()!=null){
if(Platform.isFxApplicationThread()) body.getMediaPlayer().setOnPlaying(value);
else Platform.runLater(() -> body.getMediaPlayer().setOnPlaying(value));
}
}

public void setEnd(Runnable value){
end(value);
}
public void end(Runnable value) {
if(body!=null&&body.getMediaPlayer()!=null){
if(Platform.isFxApplicationThread()) body.getMediaPlayer().setOnEndOfMedia(value);
else Platform.runLater(() -> body.getMediaPlayer().setOnEndOfMedia(value));
}
}

public void setError(Runnable value){
error(value);
}
public void error(Runnable value) {
if(body!=null&&body.getMediaPlayer()!=null){
if(Platform.isFxApplicationThread()) body.getMediaPlayer().setOnError(value);
else Platform.runLater(() -> body.getMediaPlayer().setOnError(value));
}
}

public void setHalted(Runnable value){
halted(value);
}
public void halted(Runnable value) {
if(body!=null&&body.getMediaPlayer()!=null){
if(Platform.isFxApplicationThread()) body.getMediaPlayer().setOnHalted(value);
else Platform.runLater(() -> body.getMediaPlayer().setOnHalted(value));
}
}

public void setReady(Runnable value){
ready(value);
}
public void ready(Runnable value) {
if(body!=null&&body.getMediaPlayer()!=null){
if(Platform.isFxApplicationThread()) body.getMediaPlayer().setOnReady(value);
else Platform.runLater(() -> body.getMediaPlayer().setOnReady(value));
}
}

public void setRepeat(Runnable value){
repeat(value);
}
public void repeat(Runnable value) {
if(body!=null&&body.getMediaPlayer()!=null){
if(Platform.isFxApplicationThread()) body.getMediaPlayer().setOnRepeat(value);
else Platform.runLater(() -> body.getMediaPlayer().setOnRepeat(value));
}
}

public void setStalled(Runnable value){
stalled(value);
}
public void stalled(Runnable value) {
if(body!=null&&body.getMediaPlayer()!=null){
if(Platform.isFxApplicationThread()) body.getMediaPlayer().setOnStalled(value);
else Platform.runLater(() -> body.getMediaPlayer().setOnStalled(value));
}
}

public void setSeek(double percentage){
seek(percentage);
}
public void seek(double percentage) {
if(body!=null&&body.getMediaPlayer()!=null){
Duration duration = body.getMediaPlayer().getMedia().getDuration().multiply(percentage);
Expand All @@ -192,6 +222,12 @@ public void seek(double percentage) {
}
}

public void setVolume(double percentage){
volume(percentage);
}
public double getVolume(){
return body.getMediaPlayer().getVolume();
}
public void volume(double volume){
if(body!=null&&body.getMediaPlayer()!=null){
if(Platform.isFxApplicationThread()) body.getMediaPlayer().setVolume(volume);
Expand All @@ -207,13 +243,25 @@ public void mute(){
}
}

public void setMute(boolean mute){
mute(mute);
}
public boolean isMute(){
return body.getMediaPlayer().isMute();
}
public void mute(boolean mute){
if(body!=null&&body.getMediaPlayer()!=null){
if(Platform.isFxApplicationThread()) body.getMediaPlayer().setMute(mute);
else Platform.runLater(() -> body.getMediaPlayer().setMute(mute));
}
}

public void setCycle(int cycle){
cycle(cycle);
}
public int getCycle(){
return body.getMediaPlayer().getCycleCount();
}
public void cycle(int cycle){
if(body!=null&&body.getMediaPlayer()!=null){
if(Platform.isFxApplicationThread()) body.getMediaPlayer().setCycleCount(cycle);
Expand Down

0 comments on commit ea4e00f

Please # to comment.