Получить разрешение видео в ExoPlayer - PullRequest
0 голосов
/ 08 мая 2018

Как получить разрешение видео из URL-адреса видео в соответствии с чистой скоростью, как в вашей трубе он автоматически получает 128 p, 360 p, используя Exo player.

1 Ответ

0 голосов
/ 08 мая 2018

Я предлагаю вам обратиться сюда, вот код содержания.если это не то, что вы ищете, пожалуйста, проигнорируйте этот ответ.

см. здесь .

Основные моменты, которые вы хотите изучить, касаются выбора дорожек(через TrackSelector), а также TrackSelectionHelper.Ниже я приведу важные примеры кода, которых, надеюсь, будет достаточно для начала работы.Но в конечном итоге, просто следуя чему-то похожему в демонстрационном приложении, вы окажетесь там, где вам нужно.

Вы будете удерживать селектор дорожек, с которым вы запускаете проигрыватель, и использовать его практически для всего.

Ниже приведен блок кода, который идеально подходит для понимания сути того, что вы пытаетесь сделать, поскольку демоверсия, кажется, слишком усложняет ситуацию.Также я не запускал код, но он достаточно близок.

    // These two could be fields OR passed around
    int videoRendererIndex;
    TrackGroupArray trackGroups;

    // This is the body of the logic for see if there are even video tracks
    // It also does some field setting
    MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
    for (int i = 0; i < mappedTrackInfo.length; i++) {
      TrackGroupArray trackGroups = mappedTrackInfo.getTrackGroups(i);
      if (trackGroups.length != 0) {
        switch (player.getRendererType(i)) {
          case C.TRACK_TYPE_VIDEO:
            videoRendererIndex = i;
            return true;
        }
      }
    }

    // This next part is actually about getting the list. It doesn't include
    // some additional logic they put in for adaptive tracks (DASH/HLS/SS),
    // but you can look at the sample for that (TrackSelectionHelper#buildView())
    // Below you'd be building up items in a list. This just does
    // views directly, but you could just have a list of track names (with indexes)
    for (int groupIndex = 0; groupIndex < trackGroups.length; groupIndex++) {
      TrackGroup group = trackGroups.get(groupIndex);
      for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
        if (trackIndex == 0) {
          // Beginning of a new set, the demo app adds a divider
        }
        CheckedTextView trackView = ...; // The TextView to show in the list
        // The below points to a util which extracts the quality from the TrackGroup
        trackView.setText(DemoUtil.buildTrackName(group.getFormat(trackIndex)));
    }

    // Assuming you tagged the view with the groupIndex and trackIndex, you
    // can build your override with that info.
    Pair<Integer, Integer> tag = (Pair<Integer, Integer>) view.getTag();
    int groupIndex = tag.first;
    int trackIndex = tag.second;
    // This is the override you'd use for something that isn't adaptive.
    override = new SelectionOverride(FIXED_FACTORY, groupIndex, trackIndex);
    // Otherwise they call their helper for adaptives, which roughly does:
    int[] tracks = getTracksAdding(override, trackIndex);
    TrackSelection.Factory factory = tracks.length == 1 ? FIXED_FACTORY : adaptiveTrackSelectionFactory;
    override = new SelectionOverride(factory, groupIndex, tracks);

    // Then we actually set our override on the selector to switch the quality/track
    selector.setSelectionOverride(rendererIndex, trackGroups, override);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...