log.info("%s - Announcement playing:\n%s",that._name, util.inspect(that.getStatus(),{depth:null})); resumeAfterAnnouncement <- It will be called on every status update
427731
function (status) {
                if  (anouncementIds.length > 0 && anouncementIds.indexOf(that.getCurrentPlaylistId()) < 0)
                {
                  //The item after the announcement has starting buffering -> restore original volume if required
                  if (urlOptions && urlOptions.volume) {
                    that._client.setVolumePromise(currentVolume);
                    urlOptions = undefined; //So we not set it again on every status update
                  }

                  if (that.getStatus().playerState != "BUFFERING") {
                    //The item after the announcement has starting playing -> remove announcement from list
                    log.info ("%s - Resumed after announcement", that._name);
                    that.removeFromPlaylistPromise(anouncementIds);
                    anouncementIds = [];
                    //Anouncement ended
                    return resolve(url);
                  }

                }

                if
                (
                  anouncementIds.length === 0 /*Already completed announcement*/ &&
                  (
                    //Did we insert a chunk?
                    chunkItemIds.length === 0 ||
                    //Next item started playing ?
                    (nextItem && that.getCurrentPlaylistId() == nextItem.itemId && that.getStatus().playerState != "BUFFERING")
                  )
                )
                {
                  //The remaining current item we just inserted has starting playing -> remove
                  log.info ("%s - Back to regular playlist", that._name);
                  if (chunkItemIds.length > 0)
                    that.removeFromPlaylistPromise(chunkItemIds);

                  //We are done
                  that.removeListener(that.EVENT_STATUS, resumeAfterAnnouncement);
                  return;
                }

                //Sanity check - if all items disapear then this means that a new playlist was loaded
                let idsToCheck=anouncementIds.concat(chunkItemIds);
                let allGone = true;

                for (let i in idsToCheck) {
                  if (that._playlist.getItemWithId(idsToCheck[i]) != undefined)
                    allGone = false;
                    break;
                }
                if (allGone) {
                  log.warn("%s - remaining item to play after announcement not found in the playlist -> remove status handled", that._name);
                  that.removeListener(that.EVENT_STATUS, resumeAfterAnnouncement);
                  log.debug("%s - Player status:\n%s",that._name, util.inspect(that._status,{depth:null, colors:true}))
                }

                //Not the status update we are waiting for
              }
282194
@Override
	public void onReceiveNotification(ApptentiveNotification notification) {
		checkConversationQueue();

		if (notification.hasName(NOTIFICATION_ACTIVITY_STARTED) ||
			notification.hasName(NOTIFICATION_ACTIVITY_RESUMED)) {
			final Activity activity = notification.getRequiredUserInfo(NOTIFICATION_KEY_ACTIVITY, Activity.class);
			setCurrentForegroundActivity(activity);
		} else if (notification.hasName(NOTIFICATION_APP_ENTERED_FOREGROUND)) {
			appWentToForeground();
		} else if (notification.hasName(NOTIFICATION_APP_ENTERED_BACKGROUND)) {
			setCurrentForegroundActivity(null);
			appWentToBackground();
		} else if (notification.hasName(NOTIFICATION_PAYLOAD_WILL_START_SEND)) {
			final PayloadData payload = notification.getRequiredUserInfo(NOTIFICATION_KEY_PAYLOAD, PayloadData.class);
			if (payload.getType().equals(PayloadType.message)) {
				resumeSending();
			}
		} else if (notification.hasName(NOTIFICATION_PAYLOAD_DID_FINISH_SEND)) {
			final boolean successful = notification.getRequiredUserInfo(NOTIFICATION_KEY_SUCCESSFUL, Boolean.class);
			final PayloadData payload = notification.getRequiredUserInfo(NOTIFICATION_KEY_PAYLOAD, PayloadData.class);
			final Integer responseCode = notification.getRequiredUserInfo(NOTIFICATION_KEY_RESPONSE_CODE, Integer.class);
			final JSONObject responseData = successful ? notification.getRequiredUserInfo(NOTIFICATION_KEY_RESPONSE_DATA, JSONObject.class) : null;
			if (responseCode == -1) {
				pauseSending(SEND_PAUSE_REASON_NETWORK);
			}

			if (payload.getType().equals(PayloadType.message)) {
				onSentMessage(payload.getNonce(), responseCode, responseData);
			}
		}
	}
845337
void enterInterruptImpl(Dim.StackFrame lastFrame,
                            String threadTitle, String alertMessage) {
        statusBar.setText("Thread: " + threadTitle);

        showStopLine(lastFrame);

        if (alertMessage != null) {
            MessageDialogWrapper.showMessageDialog(this,
                                                   alertMessage,
                                                   "Exception in Script",
                                                   JOptionPane.ERROR_MESSAGE);
        }

        updateEnabled(true);

        Dim.ContextData contextData = lastFrame.contextData();

        JComboBox<String> ctx = context.context;
        List<String> toolTips = context.toolTips;
        context.disableUpdate();
        int frameCount = contextData.frameCount();
        ctx.removeAllItems();
        // workaround for JDK 1.4 bug that caches selected value even after
        // removeAllItems() is called
        ctx.setSelectedItem(null);
        toolTips.clear();
        for (int i = 0; i < frameCount; i++) {
            Dim.StackFrame frame = contextData.getFrame(i);
            String url = frame.getUrl();
            int lineNumber = frame.getLineNumber();
            String shortName = url;
            if (url.length() > 20) {
                shortName = "..." + url.substring(url.length() - 17);
            }
            String location = "\"" + shortName + "\", line " + lineNumber;
            ctx.insertItemAt(location, i);
            location = "\"" + url + "\", line " + lineNumber;
            toolTips.add(location);
        }
        context.enableUpdate();
        ctx.setSelectedIndex(0);
        ctx.setMinimumSize(new Dimension(50, ctx.getMinimumSize().height));
    }
1363573
@Override
    public void onOnline(Computer c, TaskListener listener) throws IOException, InterruptedException {
        synchronized(this) {
            future.cancel(false);
            future = Timer.get().schedule(MONITOR_UPDATER, 5, TimeUnit.SECONDS);
        }
    }
99531
@Override
    public void notifyStandBy() {
        synchronized (qSync) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "notifyStandBy called with qStatus: " + qStatus);
            }
            if (qStatus == Q_STATUS.BYPASSED) {
                // no other writes waiting, so no queue thread in flight.  Set the state for more caller thread processing
                qStatus = Q_STATUS.NOT_IN_USE;
            } else if (qStatus == Q_STATUS.STAND_BY) {
                // Requests have been put on the Queue while we were writing, The Queue thread waiting to service them can start now
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "notifyStandBy doing notify");
                }
                qSync.notify();
            }
        }
    }
519101
protected void _notifyActionComponentsNow()
  {
    for( Iterator iter = _mapItems.keySet().iterator(); iter.hasNext(); )
    {
      JComponent item = (JComponent)iter.next();
//      if( !item.isShowing() )
//      {
//        continue;
//      }

      Action action = (Action)item.getClientProperty( GenericAction.ACTION_PROPERTY );
      if( action == null )
      {
        if( item instanceof AbstractButton )
        {
          action = ((AbstractButton)item).getAction();
        }

        if( action == null )
        {
          continue;
        }
      }

      boolean bEnabled = action.isEnabled();

//      long lTime = System.currentTime();
//      boolean bEnabled = action.isEnabled();
//      long diff = System.currentTime() - lTime;
//      if( diff > 50 )
//      {
//        //!! Uncomment following line and set a break point there to debug poor performing isEnabled() impl.
//        //action.isEnabled();
//
//        ConditionalActionHandler cah = null;
//        if( action instanceof GenericAction )
//        {
//          cah = ((GenericAction)action).getConditionalActionHandler();
//        }
//        System.out.println( "!!!!!!!!!!!!!!!!!!!!!!!\n" +
//                            "An action.isEnabled() impl needs to be optimized.\nIt took " + diff + "ms to complete.\n" +
//                            (cah == null ? "" : "ConditionalActionHandler: " + cah.getClass().getName() + "\n") +
//                            "Debug UpdateNotifier.notifyActionComponentsNow() to find the naughty code." +
//                            "\n!!!!!!!!!!!!!!!!!!!!!!!" );
//      }

      if( item.isEnabled() != bEnabled )
      {
        item.setEnabled( bEnabled );
      }


      // Also handle "selected" state for togglable :) items

      if( action instanceof GenericAction )
      {
        boolean bSelected = ((GenericAction)action).isSelected();
        if( item instanceof JToggleButton )
        {
          JToggleButton tb = (JToggleButton)item;
          if( tb.isSelected() != bSelected )
          {
            tb.setSelected( bSelected );
          }
        }
        else if( item instanceof JCheckBoxMenuItem )
        {
          JCheckBoxMenuItem tb = (JCheckBoxMenuItem)item;
          if( tb.getState() != bSelected )
          {
            tb.setState( bSelected );
          }
        }
      }
    }
  }
1024255
public void onMemberInfoUpdated(AVIMClient client, AVIMConversation conversation,
                                  AVIMConversationMemberInfo memberInfo, List<String> updatedProperties, String operator) {
    LOGGER.d("Notification --- " + operator + " updated memberInfo: " + memberInfo.toString());
  }
748551
@Override
  public void onEvent(Context context, Event event, Bundle extras) {
    LOGGER.d("received Notify Event. Event=" + event);
    if (Event.NOTIFICATION_CLICK_BTN.equals(event) || Event.NOTIFICATION_OPENED.equals(event)) {
      int notifyId = extras.getInt(BOUND_KEY.pushNotifyId, 0);
      LOGGER.d("received Push Event. notifyId:" + notifyId);
      if (0 != notifyId) {
        NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        manager.cancel(notifyId);
      }
    } else {
      LOGGER.d("unknow event.");
    }
    super.onEvent(context, event, extras);
  }
638268
def check_for_playback_status
      timers << every(1) do
        case true
        when info.stopped? && playing?  then @machine.trigger(:stopped)
        when info.played?  && playing?  then @machine.trigger(:played)
        when info.playing? && !playing? then @machine.trigger(:playing)
        when info.paused?  && playing?  then @machine.trigger(:paused)
        end
      end
    end
140164
private void updateStateAndNotifyListener(UploadState uploadState) throws IOException {
    this.uploadState = uploadState;
    if (progressListener != null) {
      progressListener.progressChanged(this);
    }
  }
964927
public boolean resumeWaiting(InternalEvent eventMessageDoc) throws ActivityException {
        EventWaitInstance received = registerWaitEvents(true, true);
        if (received!=null) {
            setReturnCodeAndExitStatus(received.getCompletionCode());
            processMessage(getExternalEventInstanceDetails(received.getMessageDocumentId()));
            return handleCompletionCode();
        } else return false;
    }
318604
@Override
    public void indicateProgress() {
        verifySystemOut();
        progressIndicatorActive = true;
        if (isAnsiEnabled()) {
            if (lastMessage != null && lastMessage.length() > 0) {
                if (!lastMessage.contains(maxIndicatorString)) {
                    updateStatus(lastMessage + indicator);
                }
            }
        } else {
            out.print(indicator);
        }
    }
1127753
function () {
    if (player.playing) player.pause()
    else player.play()
    if (player.playing) {
      clickToPlay.style.display = 'none'
    } else {
      clickToPlay.textContent = 'Paused'
      clickToPlay.style.display = 'block'
    }
  }
80804
function() {
      if (node.debug) {
        node.log('STARTING event listener');
      }

      var net = require('net');
      var dgram = require('dgram');
      node.inputSocket = dgram.createSocket({type:'udp4', reuseAddr: true});

      node.inputSocket.on('notify', function (event) {
        if (node.debug) {
          node.log('Got a notification.', event)
        }
      });

      node.inputSocket.on('message', function (msg, rinfo) {
        //node.log("[" + rinfo.address + "] --> " + msg.toString());

        if (rinfo.address == node.address) {
          if (node.debug) {
            node.log("UPnP Event from [" + rinfo.address + "] --> " );//+ msg.toString());
          }

          // Split to header and body
          msg = msg.toString().split('\r\n\r\n');
          var header = msg[0];
          var body = msg[1];

          // Ignore UPNP search requests
          var method = header.split('\r\n').shift().split(' ').shift().trim();
          if (method == 'M-SEARCH'){
            return;
          }

          // Parse rest of header
          var arr = header.match(/[^\r\n]+/g);
          var headerInfo = {};
          for (var i = 1; i < arr.length; ++i){
            var tem = arr[i].split(/:(.+)?/);
            if (typeof(tem[1]) == 'string'){ tem[1] = tem[1].trim(); }
            headerInfo[tem[0].toLowerCase()] = tem[1];
          };
          //node.log("METHOD: " + method);
          //node.log("BODY: " + body);
          //node.log("NTS: " + headerInfo['nts']);

          // NOTIFY messages tell us about the properties that changed
          if (method == 'NOTIFY' && headerInfo['nts'] == 'yamaha:propchange') {

            var parseString = require('xml2js').parseString;
            parseString(body, function (err, result) {
              if (err) {
                node.error('Failed to parse the event with error: ' + err);
                return;
              }

              // Check the received object
              var zoneName = undefined;
              if (result.hasOwnProperty('YAMAHA_AV')) {
                if (result.YAMAHA_AV.hasOwnProperty('Main_Zone')) {
                  zoneName = 'Main_Zone';
                } else if (result.YAMAHA_AV.hasOwnProperty('Zone_2')) {
                  zoneName = 'Zone_2';
                } else if (result.YAMAHA_AV.hasOwnProperty('Zone_3')) {
                  zoneName = 'Zone_3';
                } else if (result.YAMAHA_AV.hasOwnProperty('Zone_4')) {
                  zoneName = 'Zone_4';
                }
              }
              if (zoneName === undefined
                || result.YAMAHA_AV[zoneName] === undefined
                || result.YAMAHA_AV[zoneName][0] === undefined) {
                if (node.debug) {
                  node.warn('Unknown event message format: ' + JSON.stringify(result));
                }
                return;
              }

              for (var i in result.YAMAHA_AV[zoneName][0].Property) {
                var prop = result.YAMAHA_AV[zoneName][0].Property[i];
                if (node.debug) {
                  node.log('Property-Change: ' + prop);
                }

                // Event Notification only notifies that there is a change in each item.
                // It is necessary to issue the GET command to obtain the content of the item with the change.
                if (prop == 'Power') {

                  // Get current power state and publish to all subscriber.
                  node.sendGetCommand(zoneName + '.Power_Control.Power').then(function(value) {
                    for (var s in node.subscriptions) {
                      node.subscriptions[s].handler(zoneName + '.Power_Control.Power', value);
                    }
                  }).catch(function(error) {
                    node.error('Failed to request data from AVR with error: ' + error);
                  });

                } else if (prop == 'Input') {

                  // Get current input selection and publish to all subscriber.
                  node.sendGetCommand(zoneName + '.Input.Input_Sel').then(function(value) {
                    for (var s in node.subscriptions) {
                      node.subscriptions[s].handler(zoneName + '.Input.Input_Sel', value);
                    }
                  }).catch(function(error) {
                    node.error('Failed to request data from AVR with error: ' + error);
                  });

                } else if (prop == 'Volume') {

                  // We don't know from the event itself if volume changed or mute/unmute was pressed.
                  // Therefore we read both states.
                  node.sendGetCommand(zoneName + '.Volume.Lvl').then(function(value) {
                    for (var s in node.subscriptions) {
                      node.subscriptions[s].handler(zoneName + '.Volume.Lvl', value);
                    }
                  }).catch(function(error) {
                    node.error('Failed to request data from AVR with error: ' + error);
                  });
                  node.sendGetCommand(zoneName + '.Volume.Mute').then(function(value) {
                    for (var s in node.subscriptions) {
                      node.subscriptions[s].handler(zoneName + '.Volume.Mute', value);
                    }
                  }).catch(function(error) {
                    node.error('Failed to request data from AVR with error: ' + error);
                  });

                } else if (prop == 'Play_Info') {

                  // When getting the Play_Info event we need to check the current input mode and then read
                  // the corresponding item that holds info about current mode.
                  node.sendGetCommand(zoneName + '.Input.Input_Sel').then(function(value) {

                    var validInputs = {
                      'TUNER': 'Tuner', 'Napster': 'Napster', 'Spotify': 'Spotify', 'JUKE': 'JUKE', 'SERVER': 'SERVER',
                      'NET RADIO': 'NET_RADIO', 'USB': 'USB', 'iPod_USB': 'iPod_USB', 'AirPlay': 'AirPlay'
                    };

                    if (validInputs.hasOwnProperty(value)) {
                      node.sendGetCommand(validInputs[value] + '.Play_Info').then(function(value2) {
                        for (var s in node.subscriptions) {
                          node.subscriptions[s].handler(value + '.Play_Info', value2);
                        }
                      }).catch(function(error) {
                        node.error('Received event Play_Info but failed to read play info of current input selection: ' + error);
                      });
                    } else {
                      if (node.debug) {
                        node.log('Received event Play_Info but do not know or support current input selection ' + value);
                      }
                    }
                  }).catch(function(error) {
                    node.error('Received event Play_Info but failed to read current input selection: ' + error);
                  });

                } else if (prop == 'List_Info') {

                  // When getting the List_info event we need to check the current input mode and then read
                  // the corresponding item that holds info about current mode.
                  node.sendGetCommand(zoneName + '.Input.Input_Sel').then(function(value) {

                    var validInputs = {
                      'Napster': 'Napster', 'JUKE': 'JUKE', 'SERVER': 'SERVER',
                      'NET RADIO': 'NET_RADIO', 'USB': 'USB', 'iPod_USB': 'iPod_USB'
                    };

                    if (validInputs.hasOwnProperty(value)) {
                      node.sendGetCommand(validInputs[value] + '.List_Info').then(function(value2) {
                        for (var s in node.subscriptions) {
                          node.subscriptions[s].handler(value + '.List_Info', value2);
                        }
                      }).catch(function(error) {
                        node.error('Received event List_Info but failed to read play info of current input selection: ' + error);
                      });
                    } else {
                      if (node.debug) {
                        node.log('Received event List_Info but do not know or support current input selection ' + value);
                      }
                    }
                  }).catch(function(error) {
                    node.error('Received event List_Info but failed to read current input selection: ' + error);
                  });

                } else {

                  // The event is not known. Maybe the AVR is too new.
                  if (node.debug) {
                    node.log('Received unsupported Property-Change via multicast: ' + prop);
                  }
                  return;

                }
              }
            });
          }
        }
      });

      node.inputSocket.on('listening', function () {
        try {
          var address = node.inputSocket.address();
          node.log('UDP client listening on ' + address.address + ":" + address.port);
          node.inputSocket.setBroadcast(true)
          node.inputSocket.setMulticastTTL(5);
          node.inputSocket.addMembership('239.255.255.250');
          //node.inputSocket.addMembership('239.255.255.250', '192.168.0.101');
          //node.inputSocket.addMembership('239.255.255.250', '127.0.0.1');

          /*
          var message = new Buffer(
            "M-SEARCH * HTTP/1.1\r\n" +
            "HOST: 239.255.255.250:1900\r\n" +
            "MAN: \"ssdp:discover\"\r\n" +
            "ST: ssdp:all\r\n" + // Essential, used by the client to specify what they want to discover, eg 'ST:ge:fridge'
            "MX: 3\r\n" + // 1 second to respond (but they all respond immediately?)
            "\r\n");
          */

            //node.inputSocket.send(message, 0, message.length, 1900, "239.255.255.250");
          } catch (err) {
            node.warn('Cannot bind address for UPNP event listener. Port probably already in use. Error: ' + err);
          }
        });

      try {
        node.inputSocket.bind(1900);
      }
      catch (err) {
        node.warn('Cannot bind address for UPNP event listener. Port probably already in use. Error: ' + err);
      }
    }
713387
@Override
  public void play(SpeechAnnouncement speechAnnouncement) {
    boolean isValidAnnouncement = speechAnnouncement != null
      && !TextUtils.isEmpty(speechAnnouncement.announcement());
    boolean canPlay = isValidAnnouncement && languageSupported && !isMuted;
    if (!canPlay) {
      return;
    }

    fireInstructionListenerIfApi14();

    HashMap<String, String> params = new HashMap<>(1);
    params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, DEFAULT_UTTERANCE_ID);
    textToSpeech.speak(speechAnnouncement.announcement(), TextToSpeech.QUEUE_ADD, params);
  }
1047207
public void resume() {
        this.paused = false;
        ServerActivityCallback listener = listenerUpdater.get(this);
        if (listener != null) {
            listenerUpdater.compareAndSet(this, listener, null);
        }
    }
507448
function () {

	LOG.warn('appinfo sent to lobby:');
	LOG.warn(l_appinfo);
	
    // notify AppManager we're ready
    l_notifyLobby('SR_APP_READY', l_appinfo, 'SR_APP_READY_RES',
        function (event) {

            if (event.data.op === true)
                LOG.sys('SR_APP_READY returns ok', 'l_HandlerPool');
            else
                LOG.error('SR_APP_READY returns fail', 'l_HandlerPool');

			// call onDone if exists (but just once)
            if (l_onDone) {
				UTIL.safeCall(l_onDone);
				l_onDone = undefined;
			}			
        }
    );
}