예제 #1
0
 /**
  * Create underlying stream and queue the first play_next_track.
  *
  * @param id Name of the stream.
  * @param pop_url The url to request the next track from.
  */
 Show(IApplication app, String id, String pop_url) {
   stream = Stream.createInstance(app.getVHost(), app.getName(), id);
   stream.setRepeat(false);
   stream.addListener(this);
   this.pop_url = pop_url;
   this.id = id;
   this.app = app;
   schedule_play_next_track();
 }
예제 #2
0
  public void close() {
    closed = true;
    stream.removeListener(this);
    stream.getPublisher().unpublish();
    stream.close();

    stream = null;
    app = null;
  }
예제 #3
0
  /**
   * Request the next track from the trackmanager and play it. When a 404 is returned, delete this
   * show. On any other error: log it and try again in 0.5s.
   */
  private void play_next_track() {
    try {
      last_action = "get next track";
      current_track = new JSONObject(get_url(pop_url));
      WMSLoggerFactory.getLogger(null).info(current_path() + " on " + id);
      boolean success = stream.play("mp3:" + current_path(), 0, -1, true);
      pop_error = false;
      last_action = "play " + current_path();
      if (!success) {
        last_action = "failed play " + current_path();
        schedule_play_next_track();
      }

    } catch (Callback404Exception e) {
      last_action = "remove show";
      Shows.remove_show(app.getName(), id);
      return;
    } catch (IOException e) { // streamer offline?
      WMSLoggerFactory.getLogger(null)
          .error("streamer unreachable (IOException in get_url) in " + id);
      WMSLoggerFactory.getLogger(null).error("asdf", e);
      pop_error = true;
      wait(500);
      schedule_play_next_track();
    } catch (Exception e) {
      WMSLoggerFactory.getLogger(null).error("Unexpected exception in " + id, e);
      pop_error = true;
      wait(500);
      schedule_play_next_track();
    }
  }
예제 #4
0
 private void send_stream_title() {
   AMFDataMixedArray data = new AMFDataMixedArray();
   try {
     String stream_title = current_track.getString("stream_title");
     byte[] title2 = stream_title.getBytes(java.nio.charset.Charset.defaultCharset().name());
     data.put("StreamTitle", new AMFDataItem(new String(title2, "UTF-8")));
     stream.getPublisher().getStream().send("onMetaData", data);
   } catch (java.io.UnsupportedEncodingException e) {
   } catch (JSONException e) {
   }
 }
예제 #5
0
 public void onPlaylistItemStart(Stream stream, PlaylistItem item) {
   WMSLoggerFactory.getLogger(null)
       .info("Item Started: " + item.getName() + "on Stream: " + stream.getName());
   send_stream_title();
 }
예제 #6
0
 public void onPlaylistItemStop(Stream stream, PlaylistItem item) {
   WMSLoggerFactory.getLogger(null)
       .info("Track finished: " + item.getName() + "on Stream: " + stream.getName());
   maybe_delete_current_track();
   play_next_track();
 }