Java 类com.google.android.exoplayer.demo.player.DemoPlayer 实例源码

项目:ExoPlayerController    文件:PlayerActivity.java   
public void showAudioPopup(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    Menu menu = popup.getMenu();
    menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio);
    final MenuItem backgroundAudioItem = menu.findItem(0);
    backgroundAudioItem.setCheckable(true);
    backgroundAudioItem.setChecked(enableBackgroundAudio);
    OnMenuItemClickListener clickListener = new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item == backgroundAudioItem) {
                enableBackgroundAudio = !item.isChecked();
                return true;
            }
            return false;
        }
    };
    configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO);
    popup.show();
}
项目:ExoPlayerController    文件:PlayerActivity.java   
private void configurePopupWithTracks(PopupMenu popup, final OnMenuItemClickListener customActionClickListener,
        final int trackType) {
    if (player == null) {
        return;
    }
    int trackCount = player.getTrackCount(trackType);
    if (trackCount == 0) {
        return;
    }
    popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return (customActionClickListener != null && customActionClickListener.onMenuItemClick(item))
                    || onTrackItemClick(item, trackType);
        }
    });
    Menu menu = popup.getMenu();
    // ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0)
    menu.add(MENU_GROUP_TRACKS, DemoPlayer.TRACK_DISABLED + ID_OFFSET, Menu.NONE, R.string.off);
    for (int i = 0; i < trackCount; i++) {
        menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE, buildTrackName(player.getTrackFormat(trackType, i)));
    }
    menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true);
    menu.findItem(player.getSelectedTrack(trackType) + ID_OFFSET).setChecked(true);
}
项目:ExoPlayer-Demo    文件:PlayerActivity.java   
public void showAudioPopup(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    Menu menu = popup.getMenu();
    menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio);
    final MenuItem backgroundAudioItem = menu.findItem(0);
    backgroundAudioItem.setCheckable(true);
    backgroundAudioItem.setChecked(enableBackgroundAudio);
    OnMenuItemClickListener clickListener = new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item == backgroundAudioItem) {
                enableBackgroundAudio = !item.isChecked();
                return true;
            }
            return false;
        }
    };
    configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO);
    popup.show();
}
项目:Exoplayer_VLC    文件:PlayerActivity.java   
public void showAudioPopup(View v) {
  PopupMenu popup = new PopupMenu(this, v);
  Menu menu = popup.getMenu();
  menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio);
  final MenuItem backgroundAudioItem = menu.findItem(0);
  backgroundAudioItem.setCheckable(true);
  backgroundAudioItem.setChecked(enableBackgroundAudio);
  OnMenuItemClickListener clickListener = new OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
      if (item == backgroundAudioItem) {
        enableBackgroundAudio = !item.isChecked();
        return true;
      }
      return false;
    }
  };
  configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO);
  popup.show();
}
项目:ExoPlayer    文件:PlayerActivity.java   
public void showAudioPopup(View v) {
  PopupMenu popup = new PopupMenu(this, v);
  Menu menu = popup.getMenu();
  menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio);
  final MenuItem backgroundAudioItem = menu.findItem(0);
  backgroundAudioItem.setCheckable(true);
  backgroundAudioItem.setChecked(enableBackgroundAudio);
  OnMenuItemClickListener clickListener = new OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
      if (item == backgroundAudioItem) {
        enableBackgroundAudio = !item.isChecked();
        return true;
      }
      return false;
    }
  };
  configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO);
  popup.show();
}
项目:ExoPlayer-Demo    文件:PlayerActivity.java   
private void configurePopupWithTracks(PopupMenu popup,
                                      final OnMenuItemClickListener customActionClickListener,
                                      final int trackType) {
    if (player == null) {
        return;
    }
    int trackCount = player.getTrackCount(trackType);
    if (trackCount == 0) {
        return;
    }
    popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return (customActionClickListener != null
                    && customActionClickListener.onMenuItemClick(item))
                    || onTrackItemClick(item, trackType);
        }
    });
    Menu menu = popup.getMenu();
    // ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0).
    menu.add(MENU_GROUP_TRACKS, DemoPlayer.TRACK_DISABLED + ID_OFFSET, Menu.NONE, R.string.off);
    for (int i = 0; i < trackCount; i++) {
        menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE,
                buildTrackName(player.getTrackFormat(trackType, i)));
    }
    menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true);
    menu.findItem(player.getSelectedTrack(trackType) + ID_OFFSET).setChecked(true);
}
项目:Exoplayer_VLC    文件:VLCRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player, RendererBuilderCallback callback) {
    TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
    try {
        VLCSampleExtractor extractor = new VLCSampleExtractor(vlc, uri);
        VLCSampleSource vlcsource = new VLCSampleSource(extractor);

        MySurfaceLayoutHandler msh = null;
        System.out.println("VLCRendererBuilder.buildRenderers() props = "+props);
        Object v = props.get(SURFACE_VIEW_RES_ID_PROP);

        if (v instanceof Integer)
            msh = new MySurfaceLayoutHandler(this.context, ((Integer) v).intValue());

        if (msh == null)
            callback.onRenderersError(new ExoPlaybackException("property " + SURFACE_VIEW_RES_ID_PROP + " not set"));


        VLCVideoSurfaceHandler ivdoplayer = new VLCVideoSurfaceHandler( extractor.getLibVLC(),
                player.getMainHandler(), player, msh);

        renderers[DemoPlayer.TYPE_VIDEO] = new VLCVideoTrackRenderer(vlcsource, player.getMainHandler(), player,
                ivdoplayer, extractor.getLibVLC());
        renderers[DemoPlayer.TYPE_AUDIO] = new VLCAudioTrackRenderer(vlcsource, player.getMainHandler(), player,
                extractor.getLibVLC());
    } catch (ExoPlaybackException e) {
        e.printStackTrace();
    }
    callback.onRenderers(null, null, renderers);
}
项目:Exoplayer_VLC    文件:PlayerActivity.java   
private void configurePopupWithTracks(PopupMenu popup,
    final OnMenuItemClickListener customActionClickListener,
    final int trackType) {
  if (player == null) {
    return;
  }
  String[] tracks = player.getTracks(trackType);
  if (tracks == null) {
    return;
  }
  popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
      return (customActionClickListener != null
          && customActionClickListener.onMenuItemClick(item))
          || onTrackItemClick(item, trackType);
    }
  });
  Menu menu = popup.getMenu();
  // ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0)
  menu.add(MENU_GROUP_TRACKS, DemoPlayer.DISABLED_TRACK + ID_OFFSET, Menu.NONE, R.string.off);
  if (tracks.length == 1 && TextUtils.isEmpty(tracks[0])) {
    menu.add(MENU_GROUP_TRACKS, DemoPlayer.PRIMARY_TRACK + ID_OFFSET, Menu.NONE, R.string.on);
  } else {
    for (int i = 0; i < tracks.length; i++) {
      menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE, tracks[i]);
    }
  }
  menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true);
  menu.findItem(player.getSelectedTrackIndex(trackType) + ID_OFFSET).setChecked(true);
}
项目:Exoplayer_VLC    文件:VLCRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player, RendererBuilderCallback callback) {
    TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
    try {
        VLCSampleExtractor extractor = new VLCSampleExtractor(vlc, uri);
        VLCSampleSource vlcsource = new VLCSampleSource(extractor);

        MySurfaceLayoutHandler msh = null;
        System.out.println("VLCRendererBuilder.buildRenderers() props = "+props);
        Object v = props.get(SURFACE_VIEW_RES_ID_PROP);

        if (v instanceof Integer)
            msh = new MySurfaceLayoutHandler(this.context, ((Integer) v).intValue());

        if (msh == null)
            callback.onRenderersError(new ExoPlaybackException("property " + SURFACE_VIEW_RES_ID_PROP + " not set"));


        VLCVideoSurfaceHandler ivdoplayer = new VLCVideoSurfaceHandler( extractor.getLibVLC(),
                player.getMainHandler(), player, msh);

        renderers[DemoPlayer.TYPE_VIDEO] = new VLCVideoTrackRenderer(vlcsource, player.getMainHandler(), player,
                ivdoplayer, extractor.getLibVLC());
        renderers[DemoPlayer.TYPE_AUDIO] = new VLCAudioTrackRenderer(vlcsource, player.getMainHandler(), player,
                extractor.getLibVLC());
    } catch (ExoPlaybackException e) {
        e.printStackTrace();
    }
    callback.onRenderers(null, null, renderers);
}
项目:Exoplayer_VLC    文件:VLCRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player, RendererBuilderCallback callback) {
    TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
    try {
        VLCSampleExtractor extractor = new VLCSampleExtractor(vlc, uri);
        VLCSampleSource vlcsource = new VLCSampleSource(extractor);

        MySurfaceLayoutHandler msh = null;
        System.out.println("VLCRendererBuilder.buildRenderers() props = "+props);
            Object v = props.get(SURFACE_VIEW_RES_ID_PROP);

            if (v instanceof Integer)
                msh = new MySurfaceLayoutHandler(this.context, ((Integer) v).intValue());

        if (msh == null)
            callback.onRenderersError(new ExoPlaybackException("property " + SURFACE_VIEW_RES_ID_PROP + " not set"));


        VLCVideoSurfaceHandler ivdoplayer = new VLCVideoSurfaceHandler( extractor.getLibVLC(),
                player.getMainHandler(), player, msh);

        renderers[DemoPlayer.TYPE_VIDEO] = new VLCVideoTrackRenderer(vlcsource, player.getMainHandler(), player,
                ivdoplayer, extractor.getLibVLC());
        renderers[DemoPlayer.TYPE_AUDIO] = new VLCAudioTrackRenderer(vlcsource, player.getMainHandler(), player,
                extractor.getLibVLC());
    } catch (ExoPlaybackException e) {
        e.printStackTrace();
    }
    callback.onRenderers(null, null, renderers);
}
项目:ExoPlayer    文件:PlayerActivity.java   
private void configurePopupWithTracks(PopupMenu popup,
    final OnMenuItemClickListener customActionClickListener,
    final int trackType) {
  if (player == null) {
    return;
  }
  int trackCount = player.getTrackCount(trackType);
  if (trackCount == 0) {
    return;
  }
  popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
      return (customActionClickListener != null
          && customActionClickListener.onMenuItemClick(item))
          || onTrackItemClick(item, trackType);
    }
  });
  Menu menu = popup.getMenu();
  // ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0)
  menu.add(MENU_GROUP_TRACKS, DemoPlayer.DISABLED_TRACK + ID_OFFSET, Menu.NONE, R.string.off);
  if (trackCount == 1 && TextUtils.isEmpty(player.getTrackName(trackType, 0))) {
    menu.add(MENU_GROUP_TRACKS, DemoPlayer.PRIMARY_TRACK + ID_OFFSET, Menu.NONE, R.string.on);
  } else {
    for (int i = 0; i < trackCount; i++) {
      menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE, player.getTrackName(trackType, i));
    }
  }
  menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true);
  menu.findItem(player.getSelectedTrackIndex(trackType) + ID_OFFSET).setChecked(true);
}
项目:ExoPlayerController    文件:EventLogger.java   
public EventLogger() {
  loadStartTimeMs = new long[DemoPlayer.RENDERER_COUNT];
}
项目:ExoPlayerController    文件:PlayerActivity.java   
private void updateButtonVisibilities() {
    retryButton.setVisibility(playerNeedsPrepare ? View.VISIBLE : View.GONE);
    videoButton.setVisibility(haveTracks(DemoPlayer.TYPE_VIDEO) ? View.VISIBLE : View.GONE);
    audioButton.setVisibility(haveTracks(DemoPlayer.TYPE_AUDIO) ? View.VISIBLE : View.GONE);
    textButton.setVisibility(haveTracks(DemoPlayer.TYPE_TEXT) ? View.VISIBLE : View.GONE);
}
项目:ExoPlayerController    文件:PlayerActivity.java   
public void showVideoPopup(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    configurePopupWithTracks(popup, null, DemoPlayer.TYPE_VIDEO);
    popup.show();
}
项目:ExoPlayerController    文件:PlayerActivity.java   
public void showTextPopup(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    configurePopupWithTracks(popup, null, DemoPlayer.TYPE_TEXT);
    popup.show();
}
项目:ExoPlayer-Demo    文件:EventLogger.java   
public EventLogger() {
  loadStartTimeMs = new long[DemoPlayer.RENDERER_COUNT];
}
项目:ExoPlayer-Demo    文件:PlayerActivity.java   
private void updateButtonVisibilities() {
    retryButton.setVisibility(playerNeedsPrepare ? View.VISIBLE : View.GONE);
    videoButton.setVisibility(haveTracks(DemoPlayer.TYPE_VIDEO) ? View.VISIBLE : View.GONE);
    audioButton.setVisibility(haveTracks(DemoPlayer.TYPE_AUDIO) ? View.VISIBLE : View.GONE);
    textButton.setVisibility(haveTracks(DemoPlayer.TYPE_TEXT) ? View.VISIBLE : View.GONE);
}
项目:ExoPlayer-Demo    文件:PlayerActivity.java   
public void showVideoPopup(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    configurePopupWithTracks(popup, null, DemoPlayer.TYPE_VIDEO);
    popup.show();
}
项目:ExoPlayer-Demo    文件:PlayerActivity.java   
public void showTextPopup(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    configurePopupWithTracks(popup, null, DemoPlayer.TYPE_TEXT);
    popup.show();
}
项目:Exoplayer_VLC    文件:EventLogger.java   
public EventLogger() {
  loadStartTimeMs = new long[DemoPlayer.RENDERER_COUNT];
}
项目:Exoplayer_VLC    文件:PlayerActivity.java   
private void updateButtonVisibilities() {
  retryButton.setVisibility(playerNeedsPrepare ? View.VISIBLE : View.GONE);
  videoButton.setVisibility(haveTracks(DemoPlayer.TYPE_VIDEO) ? View.VISIBLE : View.GONE);
  audioButton.setVisibility(haveTracks(DemoPlayer.TYPE_AUDIO) ? View.VISIBLE : View.GONE);
  textButton.setVisibility(haveTracks(DemoPlayer.TYPE_TEXT) ? View.VISIBLE : View.GONE);
}
项目:Exoplayer_VLC    文件:PlayerActivity.java   
public void showVideoPopup(View v) {
  PopupMenu popup = new PopupMenu(this, v);
  configurePopupWithTracks(popup, null, DemoPlayer.TYPE_VIDEO);
  popup.show();
}
项目:Exoplayer_VLC    文件:PlayerActivity.java   
public void showTextPopup(View v) {
  PopupMenu popup = new PopupMenu(this, v);
  configurePopupWithTracks(popup, null, DemoPlayer.TYPE_TEXT);
  popup.show();
}
项目:ExoPlayer    文件:EventLogger.java   
public EventLogger() {
  loadStartTimeMs = new long[DemoPlayer.RENDERER_COUNT];
}
项目:ExoPlayer    文件:PlayerActivity.java   
private void updateButtonVisibilities() {
  retryButton.setVisibility(playerNeedsPrepare ? View.VISIBLE : View.GONE);
  videoButton.setVisibility(haveTracks(DemoPlayer.TYPE_VIDEO) ? View.VISIBLE : View.GONE);
  audioButton.setVisibility(haveTracks(DemoPlayer.TYPE_AUDIO) ? View.VISIBLE : View.GONE);
  textButton.setVisibility(haveTracks(DemoPlayer.TYPE_TEXT) ? View.VISIBLE : View.GONE);
}
项目:ExoPlayer    文件:PlayerActivity.java   
public void showVideoPopup(View v) {
  PopupMenu popup = new PopupMenu(this, v);
  configurePopupWithTracks(popup, null, DemoPlayer.TYPE_VIDEO);
  popup.show();
}
项目:ExoPlayer    文件:PlayerActivity.java   
public void showTextPopup(View v) {
  PopupMenu popup = new PopupMenu(this, v);
  configurePopupWithTracks(popup, null, DemoPlayer.TYPE_TEXT);
  popup.show();
}