MediaBot.java
Go to the documentation of this file.
00001 
00009 package script.media;
00010 
00011 import org.rosbuilding.common.ISystem;
00012 import org.rosbuilding.common.media.CommandUtil;
00013 import org.rosbuilding.common.media.IPlayer;
00014 import org.rosbuilding.common.media.ISpeaker;
00015 
00016 import com.google.common.base.Strings;
00017 import com.rosalfred.core.ia.CommandPublisher;
00018 import com.rosalfred.core.ia.rivescript.RiveScript;
00019 
00020 import smarthome_media_msgs.MediaAction;
00021 
00028 public class MediaBot extends CommandPublisher {
00029 
00030     public MediaBot(RiveScript rivescript) {
00031         super(rivescript);
00032     }
00033 
00034     public void selectSource(String source, String channel) {
00035         if (Strings.isNullOrEmpty(channel))
00036             channel = source;
00037 
00038         MediaAction media = this.node.getTopicMessageFactory().newFromType(MediaAction._TYPE);
00039         media.setMethod("channel");
00040         media.setUri("channel://" + channel);
00041         media.setType("");
00042 
00043         this.publish(CommandUtil.toCommand(node, media));
00044     }
00045 
00046     // SYSTEM
00047     public void start() {
00048         this.publish(ISystem.OP_POWER);
00049     }
00050 
00051     public void shutdown() {
00052         this.publish(ISystem.OP_SHUTDOWN);
00053     }
00054 
00055     // SPEAKER
00056     public void mute() {
00057         this.publish(ISpeaker.OP_MUTE);
00058     }
00059 
00060     // PLAYER
00061     public void play() {
00062         this.publish(IPlayer.OP_PLAY);
00063     }
00064 
00065     public void pause() {
00066         this.publish(IPlayer.OP_PAUSE);
00067     }
00068 
00069     public void stop() {
00070         this.publish(IPlayer.OP_STOP);
00071     }
00072 
00073     public void forward() {
00074         this.publish(IPlayer.OP_RIGHT);
00075     }
00076 
00077     public void backward() {
00078         this.publish(IPlayer.OP_LEFT);
00079     }
00080 
00081     public void up() {
00082         this.publish(IPlayer.OP_UP);
00083     }
00084 
00085     public void down() {
00086         this.publish(IPlayer.OP_DOWN);
00087     }
00088 
00089     public void select() {
00090         this.publish(IPlayer.OP_SELECT);
00091     }
00092 }


alfred_bot
Author(s): Mickael Gaillard , Erwan Le Huitouze
autogenerated on Tue Jun 14 2016 01:34:50