Java 类com.google.android.exoplayer2.ExoPlayer.ExoPlayerMessage 实例源码

项目:Exoplayer2Radio    文件:ExoPlayerImplInternal.java   
private void sendMessagesInternal(ExoPlayerMessage[] messages) throws ExoPlaybackException {
  try {
    for (ExoPlayerMessage message : messages) {
      message.target.handleMessage(message.messageType, message.message);
    }
    if (mediaSource != null) {
      // The message may have caused something to change that now requires us to do work.
      handler.sendEmptyMessage(MSG_DO_SOME_WORK);
    }
  } finally {
    synchronized (this) {
      customMessagesProcessed++;
      notifyAll();
    }
  }
}
项目:K-Sonic    文件:ExoPlayerImplInternal.java   
private void sendMessagesInternal(ExoPlayerMessage[] messages) throws ExoPlaybackException {
  try {
    for (ExoPlayerMessage message : messages) {
      message.target.handleMessage(message.messageType, message.message);
    }
    if (mediaSource != null) {
      // The message may have caused something to change that now requires us to do work.
      handler.sendEmptyMessage(MSG_DO_SOME_WORK);
    }
  } finally {
    synchronized (this) {
      customMessagesProcessed++;
      notifyAll();
    }
  }
}
项目:videoPickPlayer    文件:ExoPlayerImplInternal.java   
private void sendMessagesInternal(ExoPlayerMessage[] messages) throws ExoPlaybackException {
  try {
    for (ExoPlayerMessage message : messages) {
      message.target.handleMessage(message.messageType, message.message);
    }
    if (mediaSource != null) {
      // The message may have caused something to change that now requires us to do work.
      handler.sendEmptyMessage(MSG_DO_SOME_WORK);
    }
  } finally {
    synchronized (this) {
      customMessagesProcessed++;
      notifyAll();
    }
  }
}
项目:transistor    文件:ExoPlayerImplInternal.java   
public synchronized void blockingSendMessages(ExoPlayerMessage... messages) {
  if (released) {
    Log.w(TAG, "Ignoring messages sent after release.");
    return;
  }
  int messageNumber = customMessagesSent++;
  handler.obtainMessage(MSG_CUSTOM, messages).sendToTarget();
  boolean wasInterrupted = false;
  while (customMessagesProcessed <= messageNumber) {
    try {
      wait();
    } catch (InterruptedException e) {
      wasInterrupted = true;
    }
  }
  if (wasInterrupted) {
    // Restore the interrupted status.
    Thread.currentThread().interrupt();
  }
}
项目:transistor    文件:ExoPlayerImplInternal.java   
private void sendMessagesInternal(ExoPlayerMessage[] messages) throws ExoPlaybackException {
  try {
    for (ExoPlayerMessage message : messages) {
      message.target.handleMessage(message.messageType, message.message);
    }
    if (state == Player.STATE_READY || state == Player.STATE_BUFFERING) {
      // The message may have caused something to change that now requires us to do work.
      handler.sendEmptyMessage(MSG_DO_SOME_WORK);
    }
  } finally {
    synchronized (this) {
      customMessagesProcessed++;
      notifyAll();
    }
  }
}
项目:Exoplayer2Radio    文件:ExoPlayerImplInternal.java   
public void sendMessages(ExoPlayerMessage... messages) {
  if (released) {
    Log.w(TAG, "Ignoring messages sent after release.");
    return;
  }
  customMessagesSent++;
  handler.obtainMessage(MSG_CUSTOM, messages).sendToTarget();
}
项目:Exoplayer2Radio    文件:ExoPlayerImplInternal.java   
public synchronized void blockingSendMessages(ExoPlayerMessage... messages) {
  if (released) {
    Log.w(TAG, "Ignoring messages sent after release.");
    return;
  }
  int messageNumber = customMessagesSent++;
  handler.obtainMessage(MSG_CUSTOM, messages).sendToTarget();
  while (customMessagesProcessed <= messageNumber) {
    try {
      wait();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
}
项目:K-Sonic    文件:ExoPlayerImplInternal.java   
public void sendMessages(ExoPlayerMessage... messages) {
  if (released) {
    Log.w(TAG, "Ignoring messages sent after release.");
    return;
  }
  customMessagesSent++;
  handler.obtainMessage(MSG_CUSTOM, messages).sendToTarget();
}
项目:K-Sonic    文件:ExoPlayerImplInternal.java   
public synchronized void blockingSendMessages(ExoPlayerMessage... messages) {
  if (released) {
    Log.w(TAG, "Ignoring messages sent after release.");
    return;
  }
  int messageNumber = customMessagesSent++;
  handler.obtainMessage(MSG_CUSTOM, messages).sendToTarget();
  while (customMessagesProcessed <= messageNumber) {
    try {
      wait();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
}
项目:videoPickPlayer    文件:ExoPlayerImplInternal.java   
public void sendMessages(ExoPlayerMessage... messages) {
  if (released) {
    Log.w(TAG, "Ignoring messages sent after release.");
    return;
  }
  customMessagesSent++;
  handler.obtainMessage(MSG_CUSTOM, messages).sendToTarget();
}
项目:videoPickPlayer    文件:ExoPlayerImplInternal.java   
public synchronized void blockingSendMessages(ExoPlayerMessage... messages) {
  if (released) {
    Log.w(TAG, "Ignoring messages sent after release.");
    return;
  }
  int messageNumber = customMessagesSent++;
  handler.obtainMessage(MSG_CUSTOM, messages).sendToTarget();
  while (customMessagesProcessed <= messageNumber) {
    try {
      wait();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
}
项目:transistor    文件:ExoPlayerImplInternal.java   
public void sendMessages(ExoPlayerMessage... messages) {
  if (released) {
    Log.w(TAG, "Ignoring messages sent after release.");
    return;
  }
  customMessagesSent++;
  handler.obtainMessage(MSG_CUSTOM, messages).sendToTarget();
}
项目:transistor    文件:DynamicConcatenatingMediaSource.java   
/**
 * Adds a {@link MediaSource} to the playlist and executes a custom action on completion.
 * <p>
 * Note: {@link MediaSource} instances are not designed to be re-used. If you want to add the same
 * piece of media multiple times, use a new instance each time.
 *
 * @param index The index at which the new {@link MediaSource} will be inserted. This index must
 *     be in the range of 0 &lt;= index &lt;= {@link #getSize()}.
 * @param mediaSource The {@link MediaSource} to be added to the list.
 * @param actionOnCompletion A {@link Runnable} which is executed immediately after the media
 *     source has been added to the playlist.
 */
public synchronized void addMediaSource(int index, MediaSource mediaSource,
    @Nullable Runnable actionOnCompletion) {
  Assertions.checkNotNull(mediaSource);
  Assertions.checkArgument(!mediaSourcesPublic.contains(mediaSource));
  mediaSourcesPublic.add(index, mediaSource);
  if (player != null) {
    player.sendMessages(new ExoPlayerMessage(this, MSG_ADD,
        new MessageData<>(index, mediaSource, actionOnCompletion)));
  } else if (actionOnCompletion != null) {
    actionOnCompletion.run();
  }
}
项目:transistor    文件:DynamicConcatenatingMediaSource.java   
/**
 * Adds multiple {@link MediaSource}s to the playlist and executes a custom action on completion.
 * <p>
 * Note: {@link MediaSource} instances are not designed to be re-used. If you want to add the same
 * piece of media multiple times, use a new instance each time.
 *
 * @param index The index at which the new {@link MediaSource}s will be inserted. This index must
 *     be in the range of 0 &lt;= index &lt;= {@link #getSize()}.
 * @param mediaSources A collection of {@link MediaSource}s to be added to the list. The media
 *     sources are added in the order in which they appear in this collection.
 * @param actionOnCompletion A {@link Runnable} which is executed immediately after the media
 *     sources have been added to the playlist.
 */
public synchronized void addMediaSources(int index, Collection<MediaSource> mediaSources,
    @Nullable Runnable actionOnCompletion) {
  for (MediaSource mediaSource : mediaSources) {
    Assertions.checkNotNull(mediaSource);
    Assertions.checkArgument(!mediaSourcesPublic.contains(mediaSource));
  }
  mediaSourcesPublic.addAll(index, mediaSources);
  if (player != null && !mediaSources.isEmpty()) {
    player.sendMessages(new ExoPlayerMessage(this, MSG_ADD_MULTIPLE,
        new MessageData<>(index, mediaSources, actionOnCompletion)));
  } else if (actionOnCompletion != null){
    actionOnCompletion.run();
  }
}
项目:transistor    文件:DynamicConcatenatingMediaSource.java   
/**
 * Moves an existing {@link MediaSource} within the playlist and executes a custom action on
 * completion.
 *
 * @param currentIndex The current index of the media source in the playlist. This index must be
 *     in the range of 0 &lt;= index &lt; {@link #getSize()}.
 * @param newIndex The target index of the media source in the playlist. This index must be in the
 *     range of 0 &lt;= index &lt; {@link #getSize()}.
 * @param actionOnCompletion A {@link Runnable} which is executed immediately after the media
 *     source has been moved.
 */
public synchronized void moveMediaSource(int currentIndex, int newIndex,
    @Nullable Runnable actionOnCompletion) {
  if (currentIndex == newIndex) {
    return;
  }
  mediaSourcesPublic.add(newIndex, mediaSourcesPublic.remove(currentIndex));
  if (player != null) {
    player.sendMessages(new ExoPlayerMessage(this, MSG_MOVE,
        new MessageData<>(currentIndex, newIndex, actionOnCompletion)));
  } else if (actionOnCompletion != null) {
    actionOnCompletion.run();
  }
}
项目:transistor    文件:DynamicConcatenatingMediaSource.java   
private void maybeNotifyListener(@Nullable EventDispatcher actionOnCompletion) {
  if (!preventListenerNotification) {
    listener.onSourceInfoRefreshed(this,
        new ConcatenatedTimeline(mediaSourceHolders, windowCount, periodCount, shuffleOrder),
        null);
    if (actionOnCompletion != null) {
      player.sendMessages(
          new ExoPlayerMessage(this, MSG_ON_COMPLETION, actionOnCompletion));
    }
  }
}
项目:transistor    文件:DynamicConcatenatingMediaSource.java   
/**
 * Removes a {@link MediaSource} from the playlist and executes a custom action on completion.
 * <p>
 * Note: {@link MediaSource} instances are not designed to be re-used, and so the instance being
 * removed should not be re-added. If you want to move the instance use
 * {@link #moveMediaSource(int, int)} instead.
 *
 * @param index The index at which the media source will be removed. This index must be in the
 *     range of 0 &lt;= index &lt; {@link #getSize()}.
 * @param actionOnCompletion A {@link Runnable} which is executed immediately after the media
 *     source has been removed from the playlist.
 */
public synchronized void removeMediaSource(int index, @Nullable Runnable actionOnCompletion) {
  mediaSourcesPublic.remove(index);
  if (player != null) {
    player.sendMessages(new ExoPlayerMessage(this, MSG_REMOVE,
        new MessageData<>(index, null, actionOnCompletion)));
  } else if (actionOnCompletion != null) {
    actionOnCompletion.run();
  }
}