use of com.google.android.exoplayer2.Player in project instructure-android by instructure.
the class VideoViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_view);
simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.player_view);
simpleExoPlayerView.requestFocus();
mediaDataSourceFactory = buildDataSourceFactory(true);
mainHandler = new Handler();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER);
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl());
simpleExoPlayerView.setPlayer(player);
player.setPlayWhenReady(true);
player.prepare(buildMediaSource(Uri.parse(getIntent().getExtras().getString(Const.URL)), ""));
}
use of com.google.android.exoplayer2.Player in project android-app by LISTEN-moe.
the class StreamPlayer method init.
private void init() {
// In case there's already an instance somehow
releasePlayer();
final DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, userAgent);
final ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
final MediaSource streamSource = new ExtractorMediaSource(Uri.parse(streamUrl), dataSourceFactory, extractorsFactory, null, null);
player = ExoPlayerFactory.newSimpleInstance(context, new DefaultTrackSelector());
player.prepare(streamSource);
player.addListener(eventListener);
player.setVolume(1f);
final AudioAttributes audioAttributes = new AudioAttributes.Builder().setContentType(CONTENT_TYPE_MUSIC).setUsage(USAGE_MEDIA).build();
player.setAudioAttributes(audioAttributes);
}
use of com.google.android.exoplayer2.Player in project RandomWebm by alkocher.
the class RandomFragment method initPlayer.
private void initPlayer(String VIDEO_URL) {
playerView.setPlayer(player);
MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(VIDEO_URL));
player.prepare(mediaSource);
player.setPlayWhenReady(true);
// Progress bar
player.addListener(new Player.EventListener() {
@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
}
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
}
@Override
public void onLoadingChanged(boolean isLoading) {
}
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == Player.STATE_BUFFERING) {
progressBar.setVisibility(View.VISIBLE);
} else {
progressBar.setVisibility(View.GONE);
}
}
@Override
public void onRepeatModeChanged(int repeatMode) {
}
@Override
public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
}
@Override
public void onPlayerError(ExoPlaybackException error) {
}
@Override
public void onPositionDiscontinuity(int reason) {
}
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
}
@Override
public void onSeekProcessed() {
}
});
}
use of com.google.android.exoplayer2.Player in project RandomWebm by alkocher.
the class PlayerActivity method initPlayer.
private void initPlayer(String VIDEO_URL) {
playerView.setPlayer(player);
MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(VIDEO_URL));
player.prepare(mediaSource);
player.setPlayWhenReady(true);
// Loading Bar
player.addListener(new Player.EventListener() {
@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
}
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
}
@Override
public void onLoadingChanged(boolean isLoading) {
}
@Override
public void onRepeatModeChanged(int repeatMode) {
}
@Override
public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
}
@Override
public void onPlayerError(ExoPlaybackException error) {
}
@Override
public void onPositionDiscontinuity(int reason) {
}
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
}
@Override
public void onSeekProcessed() {
}
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == Player.STATE_BUFFERING) {
progressBar.setVisibility(View.VISIBLE);
} else {
progressBar.setVisibility(View.INVISIBLE);
}
}
});
}
use of com.google.android.exoplayer2.Player in project powerbot by powerbot.
the class DrawPlayers method repaint.
public void repaint(final Graphics render) {
if (!ctx.game.loggedIn()) {
return;
}
final FontMetrics metrics = render.getFontMetrics();
for (final Player player : ctx.players.select()) {
final Point location = player.centerPoint();
if (location.x == -1 || location.y == -1) {
continue;
}
render.setColor(Color.RED);
render.fillRect((int) location.getX() - 1, (int) location.getY() - 1, 2, 2);
String s = player.name() + " (" + player.combatLevel() + ")";
render.setColor(player.inCombat() ? Color.RED : player.inMotion() ? Color.GREEN : Color.WHITE);
render.drawString(s, location.x - metrics.stringWidth(s) / 2, location.y - metrics.getHeight() / 2);
final String msg = player.overheadMessage();
boolean raised = false;
if (player.animation() != -1 || player.stance() != -1 || player.npcId() != -1) {
s = "";
s += "(";
if (player.npcId() != -1) {
s += "NPC: " + player.npcId() + " | ";
}
if (player.prayerIcon() != -1) {
s += "P: " + player.prayerIcon() + " | ";
}
if (player.skullIcon() != -1) {
s += "SK: " + player.skullIcon() + " | ";
}
if (player.animation() != -1 || player.stance() > 0) {
s += "A: " + player.animation() + " | ST: " + player.stance() + " | ";
}
s = s.substring(0, s.lastIndexOf(" | "));
s += ")";
render.drawString(s, location.x - metrics.stringWidth(s) / 2, location.y - metrics.getHeight() * 3 / 2);
raised = true;
}
if (msg != null) {
render.setColor(Color.ORANGE);
render.drawString(msg, location.x - metrics.stringWidth(msg) / 2, location.y - metrics.getHeight() * (raised ? 5 : 3) / 2);
}
}
}
Aggregations