當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleExoPlayer.addListener方法代碼示例

本文整理匯總了Java中com.google.android.exoplayer2.SimpleExoPlayer.addListener方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleExoPlayer.addListener方法的具體用法?Java SimpleExoPlayer.addListener怎麽用?Java SimpleExoPlayer.addListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.exoplayer2.SimpleExoPlayer的用法示例。


在下文中一共展示了SimpleExoPlayer.addListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
 * Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
 * {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
 * assignments are overridden.
 *
 * @param player The {@link SimpleExoPlayer} to use.
 */
public void setPlayer(SimpleExoPlayer player) {
    if (this.player == player) {
        return;
    }
    if (this.player != null) {
        this.player.setTextOutput(null);
        this.player.setVideoListener(null);
        this.player.removeListener(componentListener);
        this.player.setVideoSurface(null);
    }
    this.player = player;
    shutterView.setVisibility(VISIBLE);
    if (player != null) {
        if (surfaceView instanceof TextureView) {
            player.setVideoTextureView((TextureView) surfaceView);
        } else if (surfaceView instanceof SurfaceView) {
            player.setVideoSurfaceView((SurfaceView) surfaceView);
        }
        player.setVideoListener(componentListener);
        player.addListener(componentListener);
        player.setTextOutput(componentListener);
    }
}
 
開發者ID:12d,項目名稱:react-native-videoplayer,代碼行數:31,代碼來源:ExoPlayerView.java

示例2: setPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
public void setPlayer(SimpleExoPlayer player) {
    if (this.player == player) {
        return;
    }
    if (this.player != null) {
        this.player.removeListener(this);
    }
    this.player = player;
    if (player != null) {
        player.addListener(this);

        boolean playing = player.getPlayWhenReady();
        setIsPlaying(playing);
    }

    updateAll();
}
 
開發者ID:Tubitv,項目名稱:TubiPlayer,代碼行數:18,代碼來源:TubiObservable.java

示例3: doActionAndScheduleNextImpl

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
@Override
protected void doActionAndScheduleNextImpl(final SimpleExoPlayer player,
    final MappingTrackSelector trackSelector, final Surface surface, final Handler handler,
    final ActionNode nextAction) {
  if (nextAction == null) {
    return;
  }
  Player.EventListener listener = new Player.DefaultEventListener() {
    @Override
    public void onTimelineChanged(Timeline timeline, Object manifest) {
      if (timeline.equals(expectedTimeline)) {
        player.removeListener(this);
        nextAction.schedule(player, trackSelector, surface, handler);
      }
    }
  };
  player.addListener(listener);
  if (player.getCurrentTimeline().equals(expectedTimeline)) {
    player.removeListener(listener);
    nextAction.schedule(player, trackSelector, surface, handler);
  }
}
 
開發者ID:y20k,項目名稱:transistor,代碼行數:23,代碼來源:Action.java

示例4: setPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
 * Set the {@link SimpleExoPlayer} to use.
 * <p>
 * To transition a {@link SimpleExoPlayer} from targeting one view to another, it's recommended to
 * use {@link #switchTargetView(SimpleExoPlayer, SimpleExoPlayerView, SimpleExoPlayerView)} rather
 * than this method. If you do wish to use this method directly, be sure to attach the player to
 * the new view <em>before</em> calling {@code setPlayer(null)} to detach it from the old one.
 * This ordering is significantly more efficient and may allow for more seamless transitions.
 *
 * @param player The {@link SimpleExoPlayer} to use.
 */
public void setPlayer(SimpleExoPlayer player) {
    if (this.player == player) {
        return;
    }
    if (this.player != null) {
        this.player.removeListener(componentListener);
        this.player.removeTextOutput(componentListener);
        this.player.removeVideoListener(componentListener);
        if (surfaceView instanceof TextureView) {
            this.player.clearVideoTextureView((TextureView) surfaceView);
        } else if (surfaceView instanceof SurfaceView) {
            this.player.clearVideoSurfaceView((SurfaceView) surfaceView);
        }
    }
    this.player = player;
    if (useController) {
        controller.setPlayer(player);
    }
    if (shutterView != null) {
        shutterView.setVisibility(VISIBLE);
    }
    if (player != null) {
        if (surfaceView instanceof TextureView) {
            player.setVideoTextureView((TextureView) surfaceView);
        } else if (surfaceView instanceof SurfaceView) {
            player.setVideoSurfaceView((SurfaceView) surfaceView);
        }
        player.addVideoListener(componentListener);
        player.addTextOutput(componentListener);
        player.addListener(componentListener);
        maybeShowController(false);
        updateForCurrentTrackSelections();
    } else {
        hideController();
        hideArtwork();
    }
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:49,代碼來源:SimpleExoPlayerView.java

示例5: setPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
     * Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
     * {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
     * assignments are overridden.
     * <p>
     * @param player The {@link SimpleExoPlayer} to use.
     */
    public void setPlayer(SimpleExoPlayer player, @NonNull TubiPlaybackInterface playbackInterface) {
        setPlaybackInterface(playbackInterface);
        if (this.player == player) {
            return;
        }
        if (this.player != null) {
            this.player.removeListener(componentListener);
            this.player.clearTextOutput(componentListener);
            this.player.clearVideoListener(componentListener);
            if (surfaceView instanceof TextureView) {
                this.player.clearVideoTextureView((TextureView) surfaceView);
            } else if (surfaceView instanceof SurfaceView) {
                this.player.clearVideoSurfaceView((SurfaceView) surfaceView);
            }
        }
        this.player = player;
        if (useController) {
            controller.setPlayer(player,this, playbackInterface);
        }
        if (shutterView != null) {
            shutterView.setVisibility(VISIBLE);
        }
        if (player != null) {
            if (surfaceView instanceof TextureView) {
                player.setVideoTextureView((TextureView) surfaceView);
            } else if (surfaceView instanceof SurfaceView) {
                player.setVideoSurfaceView((SurfaceView) surfaceView);
            }
            player.setVideoListener(componentListener);
            player.setTextOutput(componentListener);
            player.addListener(componentListener);
//            maybeShowController(false);
            updateForCurrentTrackSelections();
        } else {
            hideController();
            hideArtwork();
        }
    }
 
開發者ID:Tubitv,項目名稱:TubiPlayer,代碼行數:46,代碼來源:TubiExoPlayerView.java

示例6: createFullPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
private SimpleExoPlayer createFullPlayer() {
    TrackSelection.Factory videoTrackSelectionFactory
            = new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
    TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
    LoadControl loadControl = new DefaultLoadControl();
    SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(
            new DefaultRenderersFactory(playerView.getContext()),
            trackSelector, loadControl);
    player.setPlayWhenReady(true);
    player.prepare(mediaSourceBuilder.getMediaSource(false));
    player.addListener(eventListener);
    return player;
}
 
開發者ID:rubensousa,項目名稱:PreviewSeekBar,代碼行數:14,代碼來源:ExoPlayerManager.java

示例7: createFullPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
private SimpleExoPlayer createFullPlayer() {
    TrackSelection.Factory videoTrackSelectionFactory
            = new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
    TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
    LoadControl loadControl = new DefaultLoadControl();
    SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(
            new DefaultRenderersFactory(playerView.getContext()),
            trackSelector, loadControl);
    player.setPlayWhenReady(true);
    player.prepare(mediaSourceBuilder.getMediaSource(false));
    player.addListener(this);
    return player;
}
 
開發者ID:hongcwamazing,項目名稱:PreviewSeekBar-master,代碼行數:14,代碼來源:ExoPlayerManager.java

示例8: setPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
private void setPlayer(SimpleExoPlayer player, boolean isFromSelf) {
    if (this.player == player && !isFromSelf) {
        return;
    }
    if (this.player != null) {
        this.player.removeListener(componentListener);
        this.player.setVideoSurface(null);
    }

    this.player = player;
    if (useController) {
        controller.setPlayer(player);
    }
    if (player != null) {
        if (surfaceView instanceof TextureView) {
            player.setVideoTextureView((TextureView) surfaceView);
        } else if (surfaceView instanceof SurfaceView) {
            player.setVideoSurfaceView((SurfaceView) surfaceView);
        }
        player.setVideoListener(componentListener);
        player.addListener(componentListener);
        player.setTextOutput(componentListener);
        maybeShowController(false);
    } else {
        shutterView.setVisibility(VISIBLE);
        controller.hide();
    }
}
 
開發者ID:JarvanMo,項目名稱:ExoPlayerVideoView,代碼行數:29,代碼來源:ExoVideoView.java

示例9: setPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
 * Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
 * {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
 * assignments are overridden.
 *
 * @param player The {@link SimpleExoPlayer} to use.
 */
public void setPlayer(SimpleExoPlayer player) {
  if (this.player == player) {
    return;
  }
  if (this.player != null) {
    this.player.setTextOutput(null);
    this.player.setVideoListener(null);
    this.player.removeListener(componentListener);
    this.player.setVideoSurface(null);
  }
  this.player = player;
  if (useController) {
    controller.setPlayer(player);
  }
  if (shutterView != null) {
    shutterView.setVisibility(VISIBLE);
  }
  if (player != null) {
    if (surfaceView instanceof TextureView) {
      player.setVideoTextureView((TextureView) surfaceView);
    } else if (surfaceView instanceof SurfaceView) {
      player.setVideoSurfaceView((SurfaceView) surfaceView);
    }
    player.setVideoListener(componentListener);
    player.addListener(componentListener);
    player.setTextOutput(componentListener);
    maybeShowController(false);
    updateForCurrentTrackSelections();
  } else {
    hideController();
    hideArtwork();
  }
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:41,代碼來源:SimpleExoPlayerView.java

示例10: setPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
 * Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
 * {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
 * assignments are overridden.
 *
 * @param player The {@link SimpleExoPlayer} to use.
 */
public void setPlayer(SimpleExoPlayer player) {
  if (this.player == player) {
    return;
  }
  if (this.player != null) {
    this.player.setTextOutput(null);
    this.player.setVideoListener(null);
    this.player.removeListener(componentListener);
    this.player.setVideoSurface(null);
  }
  this.player = player;
  if (useController) {
    controller.setPlayer(player);
  }
  if (player != null) {
    if (surfaceView instanceof TextureView) {
      player.setVideoTextureView((TextureView) surfaceView);
    } else if (surfaceView instanceof SurfaceView) {
      player.setVideoSurfaceView((SurfaceView) surfaceView);
    }
    player.setVideoListener(componentListener);
    player.addListener(componentListener);
    player.setTextOutput(componentListener);
    maybeShowController(false);
  } else {
    shutterView.setVisibility(VISIBLE);
    controller.hide();
  }
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:37,代碼來源:SimpleExoPlayerView.java

示例11: ExoPlayerGlue

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
public ExoPlayerGlue(SimpleExoPlayer player, MappingTrackSelector trackSelector, Context context) {
    super(context, new int[] {PLAYBACK_SPEED_FAST_L0, PLAYBACK_SPEED_FAST_L1, PLAYBACK_SPEED_FAST_L2, PLAYBACK_SPEED_FAST_L3, PLAYBACK_SPEED_FAST_L4});
    handler = new Handler();

    this.player = player;
    this.trackSelector = trackSelector;
    player.addListener(this);
    trackSelector.addListener(this);

    playbackSpeed = new PlaybackSpeedTask();
}
 
開發者ID:irtimmer,項目名稱:itplayer,代碼行數:12,代碼來源:ExoPlayerGlue.java

示例12: setPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
 * Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
 * {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
 * assignments are overridden.
 * <p>
 * To transition a {@link SimpleExoPlayer} from targeting one view to another, it's recommended to
 * use {@link #switchTargetView(SimpleExoPlayer, SimpleExoPlayerView, SimpleExoPlayerView)} rather
 * than this method. If you do wish to use this method directly, be sure to attach the player to
 * the new view <em>before</em> calling {@code setPlayer(null)} to detach it from the old one.
 * This ordering is significantly more efficient and may allow for more seamless transitions.
 *
 * @param player The {@link SimpleExoPlayer} to use.
 */
public void setPlayer(SimpleExoPlayer player) {
    if (this.player == player) {
        return;
    }
    if (this.player != null) {
        this.player.removeListener(componentListener);
        this.player.clearTextOutput(componentListener);
        this.player.clearVideoListener(componentListener);
        if (surfaceView instanceof TextureView) {
            this.player.clearVideoTextureView((TextureView) surfaceView);
        } else if (surfaceView instanceof SurfaceView) {
            this.player.clearVideoSurfaceView((SurfaceView) surfaceView);
        }
    }
    this.player = player;
    if (useController) {
        controller.setPlayer(player);
    }
    if (shutterView != null) {
        shutterView.setVisibility(VISIBLE);
    }
    if (player != null) {
        if (surfaceView instanceof TextureView) {
            player.setVideoTextureView((TextureView) surfaceView);
        } else if (surfaceView instanceof SurfaceView) {
            player.setVideoSurfaceView((SurfaceView) surfaceView);
        }
        player.setVideoListener(componentListener);
        player.setTextOutput(componentListener);
        player.addListener(componentListener);
        maybeShowController(false);
        updateForCurrentTrackSelections();
    } else {
        hideController();
        hideArtwork();
    }
}
 
開發者ID:StepicOrg,項目名稱:stepik-android,代碼行數:51,代碼來源:SimpleExoPlayerView.java

示例13: playingAdAndPauseMovie

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
private void playingAdAndPauseMovie(PlayerUIController controller, AdMediaModel adMediaModel, PlayerComponentController componentController, FsmPlayer fsmPlayer) {

        SimpleExoPlayer adPlayer = controller.getAdPlayer();
        SimpleExoPlayer moviePlayer = controller.getContentPlayer();

        // then setup the player for ad to playe
        MediaModel adMedia = adMediaModel.nextAD();

        //TODO: Handle situation when ad medaia is empty, or invalid urls.
        if (adMedia != null) {

            if (adMedia.isVpaid()) {
                fsmPlayer.transit(Input.VPAID_MANIFEST);
                return;
            }

            hideVpaidNShowPlayer(controller);

            moviePlayer.setPlayWhenReady(false);

            //prepare the moviePlayer with data source and set it play

            boolean haveResumePosition = controller.getAdResumePosition() != C.TIME_UNSET;

            //prepare the mediaSource to AdPlayer
            adPlayer.prepare(adMedia.getMediaSource() , !haveResumePosition, true);

            if (haveResumePosition) {
                adPlayer.seekTo(adPlayer.getCurrentWindowIndex(), controller.getAdResumePosition());
            }

            //update the ExoPlayerView with AdPlayer and AdMedia
            TubiExoPlayerView tubiExoPlayerView = (TubiExoPlayerView) controller.getExoPlayerView();
            tubiExoPlayerView.setPlayer(adPlayer, componentController.getTubiPlaybackInterface());
            tubiExoPlayerView.setMediaModel(adMedia, false);
            //update the numbers of ad left to give user indicator
            tubiExoPlayerView.setAvailableAdLeft(adMediaModel.nubmerOfAd());

            //Player the Ad.
            adPlayer.setPlayWhenReady(true);
            adPlayer.addListener(componentController.getAdPlayingMonitor());
            adPlayer.setAudioDebugListener(componentController.getAdPlayingMonitor());
            adPlayer.setVideoDebugListener(componentController.getAdPlayingMonitor());
            adPlayer.setMetadataOutput(componentController.getAdPlayingMonitor());
        }
    }
 
開發者ID:Tubitv,項目名稱:TubiPlayer,代碼行數:47,代碼來源:AdPlayingState.java

示例14: ExoPlayerPlaybackHandler

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
public ExoPlayerPlaybackHandler(SimpleExoPlayer exoPlayer) {
	this.exoPlayer = exoPlayer;
	exoPlayer.addListener(this);

	this.playbackHandlerPromise = new Promise<>((MessengerOperator<PlayableFile>) this);
}
 
開發者ID:danrien,項目名稱:projectBlue,代碼行數:7,代碼來源:ExoPlayerPlaybackHandler.java

示例15: setPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
 * Set the {@link SimpleExoPlayer} to use.
 * <p>
 * To transition a {@link SimpleExoPlayer} from targeting one view to another, it's recommended to
 * use {@link #switchTargetView(SimpleExoPlayer, SimpleExoPlayerView, SimpleExoPlayerView)} rather
 * than this method. If you do wish to use this method directly, be sure to attach the player to
 * the new view <em>before</em> calling {@code setPlayer(null)} to detach it from the old one.
 * This ordering is significantly more efficient and may allow for more seamless transitions.
 *
 * @param player The {@link SimpleExoPlayer} to use.
 */
public void setPlayer(SimpleExoPlayer player) {
  if (this.player == player) {
    return;
  }
  if (this.player != null) {
    this.player.removeListener(componentListener);
    this.player.removeTextOutput(componentListener);
    this.player.removeVideoListener(componentListener);
    if (surfaceView instanceof TextureView) {
      this.player.clearVideoTextureView((TextureView) surfaceView);
    } else if (surfaceView instanceof SurfaceView) {
      this.player.clearVideoSurfaceView((SurfaceView) surfaceView);
    }
  }
  this.player = player;
  if (useController) {
    controller.setPlayer(player);
  }
  if (shutterView != null) {
    shutterView.setVisibility(VISIBLE);
  }
  if (subtitleView != null) {
    subtitleView.setCues(null);
  }
  if (player != null) {
    if (surfaceView instanceof TextureView) {
      player.setVideoTextureView((TextureView) surfaceView);
    } else if (surfaceView instanceof SurfaceView) {
      player.setVideoSurfaceView((SurfaceView) surfaceView);
    }
    player.addVideoListener(componentListener);
    player.addTextOutput(componentListener);
    player.addListener(componentListener);
    maybeShowController(false);
    updateForCurrentTrackSelections();
  } else {
    hideController();
    hideArtwork();
  }
}
 
開發者ID:y20k,項目名稱:transistor,代碼行數:52,代碼來源:SimpleExoPlayerView.java


注:本文中的com.google.android.exoplayer2.SimpleExoPlayer.addListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。