Examples of SqueezePlayer


Examples of org.openhab.io.squeezeserver.SqueezePlayer

  @ActionDoc(text = "Turn one of your Squeezebox devices on/off", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
  public static boolean squeezeboxPower(
      @ParamDoc(name = "playerId", text = "The Squeezebox to turn on/off") String playerId,
      @ParamDoc(name = "power", text = "True to turn on, False to turn off") boolean power) {   
    SqueezePlayer player = getPlayer(playerId);
    if (player == null) return false;
   
    if (power) {
      squeezeServer.powerOn(playerId);
    } else {
View Full Code Here

Examples of org.openhab.io.squeezeserver.SqueezePlayer

 
  @ActionDoc(text = "Mute/unmute one of your Squeezebox devices", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
  public static boolean squeezeboxMute(
      @ParamDoc(name = "playerId", text = "The Squeezebox to turn on/off") String playerId,
      @ParamDoc(name = "mute", text = "True to mute, False to un-mute") boolean mute) {   
    SqueezePlayer player = getPlayer(playerId);
    if (player == null) return false;

    if (mute) {
      squeezeServer.mute(playerId);
    } else {
View Full Code Here

Examples of org.openhab.io.squeezeserver.SqueezePlayer

 
  @ActionDoc(text = "Set the volume on one of your Squeezebox devices", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
  public static boolean squeezeboxVolume(
      @ParamDoc(name = "playerId", text = "The Squeezebox to turn on/off") String playerId,
      @ParamDoc(name = "volume", text = "The volume between 0-100") int volume) {   
    SqueezePlayer player = getPlayer(playerId);
    if (player == null) return false;

    squeezeServer.setVolume(playerId, volume);
    return true;
  }
View Full Code Here

Examples of org.openhab.io.squeezeserver.SqueezePlayer

  }
 
  @ActionDoc(text = "Send the 'play' command to one of your Squeezebox devices", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
  public static boolean squeezeboxPlay(
      @ParamDoc(name = "playerId", text = "The Squeezebox to send the command to") String playerId) {
    SqueezePlayer player = getPlayer(playerId);
    if (player == null) return false;
   
    squeezeServer.play(playerId);
    return true;
  }
View Full Code Here

Examples of org.openhab.io.squeezeserver.SqueezePlayer

  }
 
  @ActionDoc(text = "Send the 'pause' command to one of your Squeezebox devices", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
  public static boolean squeezeboxPause(
      @ParamDoc(name = "playerId", text = "The Squeezebox to send the command to") String playerId) {
    SqueezePlayer player = getPlayer(playerId);
    if (player == null) return false;

    squeezeServer.pause(playerId);
    return true;
  }
View Full Code Here

Examples of org.openhab.io.squeezeserver.SqueezePlayer

  }
 
  @ActionDoc(text = "Send the 'stop' command to one of your Squeezebox devices", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
  public static boolean squeezeboxStop(
      @ParamDoc(name = "playerId", text = "The Squeezebox to send the command to") String playerId) {
    SqueezePlayer player = getPlayer(playerId);
    if (player == null) return false;

    squeezeServer.stop(playerId);
    return true;
  }
View Full Code Here

Examples of org.openhab.io.squeezeserver.SqueezePlayer

  }
 
  @ActionDoc(text = "Send the 'next' command to one of your Squeezebox devices", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
  public static boolean squeezeboxNext(
      @ParamDoc(name = "playerId", text = "The Squeezebox to send the command to") String playerId) {
    SqueezePlayer player = getPlayer(playerId);
    if (player == null) return false;

    squeezeServer.next(playerId);
    return true;
  }
View Full Code Here

Examples of org.openhab.io.squeezeserver.SqueezePlayer

  }
 
  @ActionDoc(text = "Send the 'prev' command to one of your Squeezebox devices", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
  public static boolean squeezeboxPrev(
      @ParamDoc(name = "playerId", text = "The Squeezebox to send the command to") String playerId) {
    SqueezePlayer player = getPlayer(playerId);
    if (player == null) return false;

    squeezeServer.prev(playerId);
    return true;
  }
View Full Code Here

Examples of org.openhab.io.squeezeserver.SqueezePlayer

  @ActionDoc(text = "Play a URL on one of your Squeezebox devices using the specified volume", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
  public static boolean squeezeboxPlayUrl(
      @ParamDoc(name = "playerId", text = "The Squeezebox to send the URL to") String playerId,
      @ParamDoc(name = "url", text = "The URL to play (if empty will clear the playlist)") String url,
      @ParamDoc(name = "volume", text = "The volume to set the device when playing this URL (between 1-100)") int volume) {
    SqueezePlayer player = getPlayer(playerId);
    if (player == null) return false;

    // set the player ready to play this URL
       if (volume != -1) {
      logger.trace("Setting player state: volume {}", volume);
View Full Code Here

Examples of org.openhab.io.squeezeserver.SqueezePlayer

  public static boolean squeezeboxSpeak(
      @ParamDoc(name = "playerId", text = "The Squeezebox to send the message to") String playerId,
      @ParamDoc(name = "message", text = "The message to say") String message,
      @ParamDoc(name = "volume", text = "The volume to set the device when speaking this message (between 1-100)") int volume,
      @ParamDoc(name = "resumePlayback", text = "Continue playback after speech") Boolean resumePlayback ){
    SqueezePlayer player = getPlayer(playerId);
    if (player == null) return false;
    logger.trace("***START SPEECH**** Player: '{}'", playerId);
    // get the current player state
    int playerVolume = player.getUnmuteVolume();
    boolean playerPowered = player.isPowered();
    boolean playerMuted = player.isMuted();
    Mode playerMode = player.getMode();
    int currNumTracks = player.getNumberPlaylistTracks();
    int currPlayingTime = player.getCurrentPlayingTime();
    int currPlaylistIndex = player.getCurrentPlaylistIndex();
    int currPlaylistShuffle = player.getCurrentPlaylistShuffle();
    int currPlaylistRepeat = player.getCurrentPlaylistRepeat();
    int newNumTracks = 0;
    logger.trace("Current Playing Mode '{}'", playerMode.toString());
    logger.trace("Current Volume '{}'", playerVolume);
    logger.trace("Current Num Playlist Tracks '{}'", currNumTracks);
    logger.trace("Current Playing Playlist Index '{}'", currPlaylistIndex);
    logger.trace("Current Playing Time '{}'", currPlayingTime);
    logger.trace("Current Shuffle Mode '{}'", currPlaylistShuffle);
    logger.trace("Current Repeat Mode '{}'", currPlaylistRepeat);
   
    // If Playing Pause player before adjusting volume!
    if (playerMode == Mode.play)
      squeezeServer.pause(playerId);
   
    // set the player ready to play this announcement
    if (playerMuted) {
      logger.trace("Setting player state: unmuted");
      squeezeServer.unMute(playerId);
    }
    if (volume != -1) {
      logger.trace("Setting player state: volume {}", volume);
      squeezeServer.setVolume(playerId, volume);
    }
   
    if (currPlaylistRepeat != 0)
      squeezeServer.setRepeatMode(playerId, 0);
    if (currPlaylistShuffle != 0) {
      squeezeServer.setShuffleMode(playerId, 0);
      currPlaylistIndex = 0;
      logger.trace("Shuffle Changed! Set Current Playing Index to 0");
    }
   
   
    // can only 'say' 100 chars at a time
    List<String> sentences = getSentences(message, MAX_SENTENCE_LENGTH);

    // send each sentence in turn
    for (String sentence : sentences) {
      logger.trace("Sending sentence to " + playerId + " (" + sentence + ")");
     
      String encodedSentence;
      try {
        encodedSentence = URLEncoder.encode(sentence, "UTF-8");
      } catch (UnsupportedEncodingException e) {
        logger.warn("Failed to encode sentence '" + sentence + "'. Skipping sentence.", e);
        continue;
      }
      encodedSentence = encodedSentence.replace("+", "%20");
      logger.trace("Encoded sentence " + encodedSentence);
     
      // build the URL to send to the Squeezebox to play
      String url = String.format(GOOGLE_TRANSLATE_URL,squeezeServer.language()) + encodedSentence;
     
      // create an instance of our special listener so we can detect when the sentence is complete
      SqueezeboxSentenceListener listener = new SqueezeboxSentenceListener(playerId);
      squeezeServer.addPlayerEventListener(listener);
     
      // send the URL (this will power up the player and un-mute if necessary)
      logger.trace("Adding URL to current playlist '{}' to play", url);
      squeezeServer.addPlaylistItem(playerId, url);
      logger.trace("Sleeping for 1s for updated playlist to refresh", url);
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        continue;
      }
      newNumTracks = player.getNumberPlaylistTracks();
      logger.trace("New Playlist Track Number: '{}'", newNumTracks);
     
      squeezeServer.playPlaylistItem(playerId, newNumTracks-1);
     
      squeezeServer.play(playerId);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.