当前位置: 首页>>代码示例>>Java>>正文


Java SimpleExoPlayer.setPlayWhenReady方法代码示例

本文整理汇总了Java中com.google.android.exoplayer2.SimpleExoPlayer.setPlayWhenReady方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleExoPlayer.setPlayWhenReady方法的具体用法?Java SimpleExoPlayer.setPlayWhenReady怎么用?Java SimpleExoPlayer.setPlayWhenReady使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.exoplayer2.SimpleExoPlayer的用法示例。


在下文中一共展示了SimpleExoPlayer.setPlayWhenReady方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: seekOrSkip

import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private void seekOrSkip() {
    if (fsmPlayer == null) {
        return;
    }

    if (fsmPlayer instanceof FsmPlayer) {

        if (((FsmPlayer) fsmPlayer).getController() != null) {
            SimpleExoPlayer adPlayer = ((FsmPlayer) fsmPlayer).getController().getAdPlayer();

            if (adPlayer != null && adPlayer.getPlaybackState() == ExoPlayer.STATE_BUFFERING) {

                long position = adPlayer.getCurrentPosition() + 1000 < adPlayer.getDuration() ? adPlayer.getCurrentPosition() + 1000 : adPlayer.getDuration();
                adPlayer.seekTo(position);
                adPlayer.setPlayWhenReady(true);
                return;
            }
        }
    }
}
 
开发者ID:Tubitv,项目名称:TubiPlayer,代码行数:21,代码来源:AdPlayingMonitor.java

示例2: prepareExoPlayerForUri

import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
public SimpleExoPlayer prepareExoPlayerForUri(
        int playerKey,
        @NonNull Context context,
        @NonNull Uri uri,
        @NonNull SimpleExoPlayerView simpleExoPlayerView,
        int currentWindow,
        boolean playWhenReady,
        long playbackPosition) {

    SimpleExoPlayer simpleExoPlayer = playersInUse.get(playerKey);

    if (simpleExoPlayer == null) {
        simpleExoPlayer = setUpMediaPlayer(context);
        simpleExoPlayerView.setPlayer(simpleExoPlayer);
        simpleExoPlayer.setPlayWhenReady(playWhenReady);
        simpleExoPlayer.seekTo(currentWindow, playbackPosition);
        MediaSource mediaSource = setUpMediaSource(context, uri);
        simpleExoPlayer.prepare(mediaSource, true, false);
        playersInUse.put(playerKey, simpleExoPlayer);
    } else {
        simpleExoPlayer.seekTo(currentWindow, playbackPosition);
        simpleExoPlayer.setPlayWhenReady(playWhenReady);
    }

    return simpleExoPlayer;
}
 
开发者ID:ecarrara-araujo,项目名称:yabaking,代码行数:27,代码来源:ExoPlayerManager.java

示例3: stopAdandPlayerMovie

import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private void stopAdandPlayerMovie(PlayerUIController controller, PlayerComponentController componentController, MediaModel movieMedia) {

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

        //first remove the AdPlayer's listener and pause the player
        adPlayer.removeListener(componentController.getAdPlayingMonitor());
        adPlayer.setPlayWhenReady(false);

        //then update the playerView with SimpleExoPlayer and Movie MediaModel
        TubiExoPlayerView tubiExoPlayerView = (TubiExoPlayerView) controller.getExoPlayerView();
        tubiExoPlayerView.setPlayer(moviePlayer, componentController.getTubiPlaybackInterface());
        tubiExoPlayerView.setMediaModel(movieMedia, false);

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

        boolean haveResumePosition = controller.getMovieResumePosition() != C.TIME_UNSET;
        if (moviePlayer.getPlaybackState() == ExoPlayer.STATE_IDLE) {
            moviePlayer.prepare(movieMedia.getMediaSource(), !haveResumePosition, false);
        }

        updatePlayerPosition(moviePlayer, controller);

        moviePlayer.setPlayWhenReady(true);

        hideVpaidNShowPlayer(controller);
    }
 
开发者ID:Tubitv,项目名称:TubiPlayer,代码行数:28,代码来源:MoviePlayingState.java

示例4: onCreate

import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (!isPlaying) {
        Handler mainHandler = new Handler();
        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelection.Factory videoTrackSelectionFactory =
                new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector =
                new DefaultTrackSelector(videoTrackSelectionFactory);

        LoadControl loadControl = new DefaultLoadControl();

        SimpleExoPlayer player =
                ExoPlayerFactory.newSimpleInstance(MainActivity.this, trackSelector, loadControl);
        SimpleExoPlayerView playerView = (SimpleExoPlayerView) findViewById(R.id.videoView);
        playerView.setPlayer(player);
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(MainActivity.this,
                Util.getUserAgent(MainActivity.this, "yourApplicationName"));
        MediaSource mediaSource = new ExtractorMediaSource(Uri.parse("https://r7---sn-3c27ln7k.googlevideo.com/videoplayback?id=6fb497d0971b8cdf&itag=22&source=picasa&begin=0&requiressl=yes&mm=30&mn=sn-3c27ln7k&ms=nxu&mv=m&nh=IgphcjAzLmticDAxKgkxMjcuMC4wLjE&pl=22&sc=yes&mime=video/mp4&lmt=1486083166327499&mt=1486135406&ip=134.249.158.189&ipbits=8&expire=1486164239&sparams=ip,ipbits,expire,id,itag,source,requiressl,mm,mn,ms,mv,nh,pl,sc,mime,lmt&signature=3BB06D8D4294F8C49B3CE910B3D6849954302BB1.02ABE00700DFCEF715E72D0EFB73B67841E659F8&key=ck2&ratebypass=yes&title=%5BAnime365%5D%20Kuzu%20no%20Honkai%20-%2004%20(t1174045)"), dataSourceFactory,
                new DefaultExtractorsFactory(), null, null);
        player.prepare(mediaSource);
        player.setPlayWhenReady(true);

    }
}
 
开发者ID:CrazyDude1994,项目名称:lostfilm-android-client,代码行数:28,代码来源:MainActivity.java

示例5: 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

示例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(this);
    return player;
}
 
开发者ID:hongcwamazing,项目名称:PreviewSeekBar-master,代码行数:14,代码来源:ExoPlayerManager.java

示例7: createPreviewPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private SimpleExoPlayer createPreviewPlayer() {
    TrackSelection.Factory videoTrackSelectionFactory = new WorstVideoTrackSelection.Factory();
    TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
    LoadControl loadControl = new PreviewLoadControl();
    SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(
            new DefaultRenderersFactory(playerView.getContext()),
            trackSelector, loadControl);
    player.setPlayWhenReady(false);
    player.setVolume(0f);
    player.prepare(mediaSourceBuilder.getMediaSource(true));
    return player;
}
 
开发者ID:hongcwamazing,项目名称:PreviewSeekBar-master,代码行数:13,代码来源:ExoPlayerManager.java

示例8: pausePlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private static void pausePlayer(SimpleExoPlayer internalPlayer){
    internalPlayer.setPlayWhenReady(false);
    internalPlayer.getPlaybackState();
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:5,代码来源:ExoGifPlayer.java

示例9: startPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private static void startPlayer(SimpleExoPlayer internalPlayer){
    internalPlayer.setPlayWhenReady(true);
    internalPlayer.getPlaybackState();
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:5,代码来源:ExoGifPlayer.java

示例10: pausePlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
public static void pausePlayer(SimpleExoPlayer player) {
    player.setPlayWhenReady(false);
    player.getPlaybackState();
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:5,代码来源:ExoUtil.java

示例11: startPlayer

import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
public static void startPlayer(SimpleExoPlayer player) {
    player.setPlayWhenReady(true);
    player.getPlaybackState();
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:5,代码来源:ExoUtil.java

示例12: 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

示例13: showImagePopup

import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
public void showImagePopup(Point p, final String uri) {
        Activity context = MainActivity.this;
        //COMPLETED solving video problem

        final Dialog dialog = new Dialog(context);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.image_popup_layout);
        dialog.show();
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.copyFrom(dialog.getWindow().getAttributes());
        dialog.getWindow().setAttributes(lp);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
        dialog.getWindow().setDimAmount(0);


        // Getting a reference to Close button, and close the popup when clicked.
        FloatingActionButton close = (FloatingActionButton) dialog.findViewById(R.id.close_image_popup_button);
        ImageView statusImage = (ImageView) dialog.findViewById(R.id.full_status_image_view);
        final SimpleExoPlayerView simpleExoPlayerView = dialog.findViewById(R.id.full_status_video_view);
        final SimpleExoPlayer player;
        if (uri.endsWith(".jpg")) {
            GlideApp.with(context).load(uri).fitCenter().into(statusImage);
        } else if (uri.endsWith(".mp4")) {
            statusImage.setVisibility(View.GONE);
            simpleExoPlayerView.setVisibility(View.VISIBLE);
            Uri myUri = Uri.parse(uri); // initialize Uri here

            // 1. Create a default TrackSelector
            BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
            TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
            TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

// 2. Create a default LoadControl
            LoadControl loadControl = new DefaultLoadControl();

// 3. Create the player
            player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);

//Set media controller
            simpleExoPlayerView.setUseController(true);
            simpleExoPlayerView.requestFocus();

// Bind the player to the view.
            simpleExoPlayerView.setPlayer(player);

            //Measures bandwidth during playback. Can be null if not required.
            DefaultBandwidthMeter bandwidthMeterA = new DefaultBandwidthMeter();
//Produces DataSource instances through which media data is loaded.
            DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(this, Util.
                    getUserAgent(this, "exoplayer2example"), bandwidthMeterA);
//Produces Extractor instances for parsing the media data.
            ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();

            MediaSource videoSource = new ExtractorMediaSource(myUri, dataSourceFactory, extractorsFactory, null, null);
            player.prepare(videoSource);
            player.setPlayWhenReady(true); //run file/link when ready to play.
            dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    player.release();
                }
            });

        }
        close.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
//                popup.dismiss();
                dialog.cancel();
            }
        });
    }
 
开发者ID:Lekky71,项目名称:WhatsAppStatusSaver,代码行数:75,代码来源:MainActivity.java

示例14: doActionImpl

import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
    Surface surface) {
  player.setPlayWhenReady(playWhenReady);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:6,代码来源:Action.java


注:本文中的com.google.android.exoplayer2.SimpleExoPlayer.setPlayWhenReady方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。