Search in sources :

Example 11 with Player

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)), ""));
}
Also used : Handler(android.os.Handler) DefaultHttpDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) ExoPlayerFactory(com.google.android.exoplayer2.ExoPlayerFactory) DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) DefaultTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector) TrackSelection(com.google.android.exoplayer2.trackselection.TrackSelection) AdaptiveVideoTrackSelection(com.google.android.exoplayer2.trackselection.AdaptiveVideoTrackSelection) DefaultLoadControl(com.google.android.exoplayer2.DefaultLoadControl)

Example 12 with Player

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);
}
Also used : DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) ExtractorsFactory(com.google.android.exoplayer2.extractor.ExtractorsFactory) DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) DefaultTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) AudioAttributes(com.google.android.exoplayer2.audio.AudioAttributes) DataSource(com.google.android.exoplayer2.upstream.DataSource)

Example 13 with Player

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() {
        }
    });
}
Also used : Player(com.google.android.exoplayer2.Player) SimpleExoPlayer(com.google.android.exoplayer2.SimpleExoPlayer) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) ExoPlaybackException(com.google.android.exoplayer2.ExoPlaybackException) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) TrackSelectionArray(com.google.android.exoplayer2.trackselection.TrackSelectionArray) Timeline(com.google.android.exoplayer2.Timeline) MediaSource(com.google.android.exoplayer2.source.MediaSource) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) PlaybackParameters(com.google.android.exoplayer2.PlaybackParameters)

Example 14 with Player

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);
            }
        }
    });
}
Also used : Player(com.google.android.exoplayer2.Player) SimpleExoPlayer(com.google.android.exoplayer2.SimpleExoPlayer) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) ExoPlaybackException(com.google.android.exoplayer2.ExoPlaybackException) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) TrackSelectionArray(com.google.android.exoplayer2.trackselection.TrackSelectionArray) Timeline(com.google.android.exoplayer2.Timeline) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) PlaybackParameters(com.google.android.exoplayer2.PlaybackParameters)

Example 15 with Player

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);
        }
    }
}
Also used : Player(org.powerbot.script.rt6.Player) FontMetrics(java.awt.FontMetrics) Point(java.awt.Point)

Aggregations

Test (org.junit.Test)250 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)185 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)174 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)127 PlayerRunnable (com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable)107 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)91 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)89 NoUidTimeline (com.google.android.exoplayer2.testutil.NoUidTimeline)89 Listener (com.google.android.exoplayer2.Player.Listener)85 TimelineWindowDefinition (com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition)72 MediaSource (com.google.android.exoplayer2.source.MediaSource)68 ExoPlayerTestRunner (com.google.android.exoplayer2.testutil.ExoPlayerTestRunner)67 ConcatenatingMediaSource (com.google.android.exoplayer2.source.ConcatenatingMediaSource)66 Nullable (androidx.annotation.Nullable)56 ClippingMediaSource (com.google.android.exoplayer2.source.ClippingMediaSource)49 CompositeMediaSource (com.google.android.exoplayer2.source.CompositeMediaSource)49 MaskingMediaSource (com.google.android.exoplayer2.source.MaskingMediaSource)49 ServerSideAdInsertionMediaSource (com.google.android.exoplayer2.source.ads.ServerSideAdInsertionMediaSource)49 FakeAdaptiveMediaSource (com.google.android.exoplayer2.testutil.FakeAdaptiveMediaSource)49 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)47