/** * Play a specific IPlayItem. The strategy for now is VOD first, Live second. * * @param item Item to play */ protected void play(IPlayItem item) { // dont play unless we are stopped if (state == StreamState.STOPPED) { // assume this is not live stream boolean isLive = false; if (providerService != null) { msgIn = providerService.getVODProviderInput(getScope(), item.getName()); if (msgIn == null) { msgIn = providerService.getLiveProviderInput(getScope(), item.getName(), true); isLive = true; } if (msgIn == null) { log.warn("ABNORMAL Can't get both VOD and Live input from providerService"); return; } } setState(StreamState.PLAYING); currentItem = item; sendResetMessage(); if (msgIn != null) { msgIn.subscribe(this, null); } if (isLive) { if (item.getLength() >= 0) { liveJobName = scheduler.addScheduledOnceJob( item.getLength(), new IScheduledJob() { public void execute(ISchedulingService service) { if (liveJobName == null) { return; } liveJobName = null; onItemEnd(); } }); } } else { long start = item.getStart(); if (start < 0) { start = 0; } sendVODInitCM(msgIn, (int) start); startBroadcastVOD(); } } }