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


Java SimpleExoPlayerView.setPlayer方法代码示例

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


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

示例1: prepareExoPlayerForUri

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的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

示例2: PlayerView

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
public PlayerView(Context context, SimpleExoPlayer player) {
    super(context);
    simpleExoPlayerView = new SimpleExoPlayerView(context);
    progressBar = new ProgressBar(context);
    textView = new TextView(context);
    textView.setX(40);
    textView.setY(20);
    textView.setTextColor(Color.parseColor("#FFFFFF"));
    textView.setTextSize(16);
    textView.setText("By Herudi");
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(100,100);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    simpleExoPlayerView.setLayoutParams(new SimpleExoPlayerView.LayoutParams(
            SimpleExoPlayerView.LayoutParams.MATCH_PARENT,
            SimpleExoPlayerView.LayoutParams.MATCH_PARENT
    ));
    setLayoutParams(new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT
    ));
    setBackgroundColor(ContextCompat.getColor(context, android.R.color.black));
    addView(simpleExoPlayerView);
    addView(textView);
    addView(progressBar,params);
    simpleExoPlayerView.setUseController(true);
    simpleExoPlayerView.requestFocus();
    simpleExoPlayerView.setPlayer(player);
    simpleExoPlayerView.setControllerVisibilityListener(new PlaybackControlView.VisibilityListener() {
        @Override
        public void onVisibilityChange(int visibility) {
            if (visibility==0){
                textView.setVisibility(VISIBLE);
            }else {
                textView.setVisibility(GONE);
            }
        }
    });
}
 
开发者ID:herudi,项目名称:react-native-exoplayer-intent-video,代码行数:39,代码来源:PlayerView.java

示例3: onCreate

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    Uri uri = intent.getParcelableExtra("uri");
    long playerPosition = intent.getLongExtra("position", C.TIME_UNSET);
    int playerWindow = intent.getIntExtra("windowIndex", 0);
    boolean rotation = intent.getBooleanExtra("rotation", false);
    if (rotation) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    }
    playerInstance = ExoPlayerInstance.getInstance();
    SimpleExoPlayer player = playerInstance.getPlayer();

    setContentView(R.layout.activity_video_player);
    playerView = (SimpleExoPlayerView) findViewById(R.id.player_view);
    playerView.setPlayer(player);
    if (playerPosition == C.TIME_UNSET) {
        player.seekToDefaultPosition(playerWindow);
    } else {
        player.seekTo(playerWindow, playerPosition);
    }
    playerInstance.prepare(uri, null);

    setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
 
开发者ID:mingdroid,项目名称:tumbviewer,代码行数:27,代码来源:VideoPlayerActivity.java

示例4: onServiceConnected

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
   Log.d("ServiceConnection","connected");
    MediaService.LocalBinder binder = (MediaService.LocalBinder) service;
    MediaService mediaService = binder.getService();
    player = mediaService.setUpPlayer(url);
    Log.d("ServiceConnection", player.toString());
    // ExoPlayer Views
    SimpleExoPlayerView mVideoView = findViewById(R.id.media_player);
    mVideoView.setPlayer(player);
    mVideoView.requestFocus();
    if (path.contains(".mp3") || path.contains("m4a")) {
        // mVideoView.setControllerShowTimeoutMs(-1);
        ImageView artwork = findViewById(R.id.exo_thumbnail);
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            artwork.setImageDrawable(getApplicationContext().getDrawable(R.drawable.logo));
        } else {
            artwork.setImageDrawable(getResources().getDrawable(R.drawable.logo));
        }
    } else {
        // fullscreen for video
        hideStatusBar();
    }
}
 
开发者ID:fenimore,项目名称:DemocracyDroid,代码行数:26,代码来源:MediaActivity.java

示例5: onCreate

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的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

示例6: startPlayer

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
/**
 * 播放启动视频
 */
private void startPlayer() {
    // 0.  set player view
    playerView = (SimpleExoPlayerView) findViewById(R.id.playerView);
    playerView.setUseController(false);
    playerView.getKeepScreenOn();
    playerView.setResizeMode(RESIZE_MODE_FILL);

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

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

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

    // 4. set player
    playerView.setPlayer(mPlayer);
    mPlayer.setPlayWhenReady(true);

    // 5. prepare to play
    File file = new File(Constants.FILE_VIDEO_FLODER, "jcode.mp4");
    if (file.isFile() && file.exists()) {
        mUri = Uri.fromFile(file);
    } else {
        Toast.makeText(this,"文件未找到",Toast.LENGTH_SHORT).show();
        return;
    }
    ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, "UserAgent");
    videoSource = new ExtractorMediaSource(mUri, dataSourceFactory, extractorsFactory, null, null);

    // 6. ready to play
    mPlayer.prepare(videoSource);
}
 
开发者ID:hiliving,项目名称:P2Video-master,代码行数:41,代码来源:PlayerActivity.java

示例7: setView

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
public void setView(SimpleExoPlayerView videoView) {
	videoView.setPlayer(player);
}
 
开发者ID:cemrich,项目名称:zapp,代码行数:4,代码来源:Player.java

示例8: initializePlayer

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
private void initializePlayer() {

        simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.player_view);
        simpleExoPlayerView.requestFocus();

        TrackSelection.Factory videoTrackSelectionFactory =
                new AdaptiveTrackSelection.Factory(bandwidthMeter);

        trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

        player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);

        simpleExoPlayerView.setPlayer(player);

        player.setPlayWhenReady(shouldAutoPlay);
/*        MediaSource mediaSource = new HlsMediaSource(Uri.parse("https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8"),
                mediaDataSourceFactory, mainHandler, null);*/

        DefaultExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();

        MediaSource mediaSource = new ExtractorMediaSource(Uri.parse("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"),
                mediaDataSourceFactory, extractorsFactory, null, null);

        player.prepare(mediaSource);

        ivHideControllerButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                simpleExoPlayerView.hideController();
            }
        });
    }
 
开发者ID:yusufcakmak,项目名称:ExoPlayerSample,代码行数:33,代码来源:VideoPlayerActivity.java

示例9: init

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
public void init(Context context, SimpleExoPlayerView simpleExoPlayerView) {
  // Create a default track selector.
  BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
  TrackSelection.Factory videoTrackSelectionFactory =
      new AdaptiveTrackSelection.Factory(bandwidthMeter);
  TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

  // Create a player instance.
  player = ExoPlayerFactory.newSimpleInstance(context, trackSelector);

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

  // Produces DataSource instances through which media data is loaded.
  DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context,
      Util.getUserAgent(context, context.getString(R.string.application_name)));

  // This is the MediaSource representing the content media (i.e. not the ad).
  String contentUrl = context.getString(R.string.content_url);
  MediaSource contentMediaSource =
      new ExtractorMediaSource.Factory(dataSourceFactory)
          .createMediaSource(Uri.parse(contentUrl));

  // Compose the content media source into a new AdsMediaSource with both ads and content.
  MediaSource mediaSourceWithAds =
      new AdsMediaSource(
          contentMediaSource,
          /* adMediaSourceFactory= */ this,
          adsLoader,
          simpleExoPlayerView.getOverlayFrameLayout(),
          /* eventHandler= */ null,
          /* eventListener= */ null);

  // Prepare the player with the source.
  player.seekTo(contentPosition);
  player.prepare(mediaSourceWithAds);
  player.setPlayWhenReady(true);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:39,代码来源:PlayerManager.java

示例10: onCreate

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);
    Bundle bundle = getIntent().getExtras();
    if(bundle!=null && bundle.containsKey("multimedia")) {

        Multimedia multimedia = bundle.getParcelable("multimedia");
        SimpleExoPlayerView videoView = (SimpleExoPlayerView) findViewById(R.id.video);

        // 1. Crea un slector de pista por defecto
        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

        // 2. Creo un control para el player
        LoadControl loadControl = new DefaultLoadControl();

        // 3. Creo el player con los componentes anteriores
        player = ExoPlayerFactory.newSimpleInstance(getApplicationContext(), trackSelector, loadControl);

        //Obtengo la URL completa del archivo de video
        Uri uri = Uri.parse(ConsultasBBDD.server + ConsultasBBDD.imagenes +  multimedia.getUrl());

        //A la vista le establezco el reproductor que va a usar
        videoView.setPlayer(player);

        // Procuce que se instancie el DataSource a través de los datos del video que ha sido cargado.
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(), Util.getUserAgent(getApplicationContext(), "SmartU"));
        // Produce un extractor que parsea el video.
        ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
        // Construyo un MediaSource con el formato y los datos del video para asignarselo al reproductor.
        MediaSource videoSource = new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, null, null);
        // If has subtitles load video with subtitles
        if (multimedia.getUrlSubtitulos() != null && multimedia.getUrlSubtitulos().compareTo("") != 0) {
            //Obtengo la URL completa para los subtitulos del video
            Uri subtitulosUri = Uri.parse(ConsultasBBDD.server + ConsultasBBDD.imagenes +  multimedia.getUrlSubtitulos());
            //Asigno el formato de los subtitulos
            Format textFormat = Format.createTextSampleFormat(null, MimeTypes.TEXT_VTT,
                    null, Format.NO_VALUE, Format.NO_VALUE, Locale.getDefault().getLanguage(), null);
            //Creo un MediaSource para los subtitulos para añadirselos al video
            MediaSource subtitleSource = new SingleSampleMediaSource(subtitulosUri, dataSourceFactory, textFormat, C.TIME_UNSET);
            // Mezcla el video con los subtitulos
            MergingMediaSource mergedSource = new MergingMediaSource(videoSource, subtitleSource);
            // Preparo el reproductor con los subtitulos y el video
            player.prepare(mergedSource);
        } else // Si no tiene subtitulos preparo solo el video
            player.prepare(videoSource);
    }
}
 
开发者ID:nen155,项目名称:TFG-SmartU-La-red-social,代码行数:51,代码来源:VideoActivity.java

示例11: showImagePopup

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的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

示例12: initPlayer

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
private void initPlayer() {
    // Produces DataSource instances through which media data is loaded.
    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
            Util.getUserAgent(this, getString(R.string.app_name)), null);
    // Produces Extractor instances for parsing the media data.
    ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
    // This is the MediaSource representing the media to be played.
    MediaSource videoSource = new ExtractorMediaSource(videoUri,
            dataSourceFactory, extractorsFactory, null, null);

    DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(this);

    // Create the player
    player = ExoPlayerFactory.newSimpleInstance(renderersFactory,
            new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(null)),
            new DefaultLoadControl());

    // Bind the player to the view.
    SimpleExoPlayerView simpleExoPlayerView = findViewById(R.id.simpleExoPlayerView);
    simpleExoPlayerView.setPlayer(player);

    // Prepare the player with the source.
    player.prepare(videoSource);
    player.setRepeatMode(Player.REPEAT_MODE_ONE);
    player.setPlayWhenReady(true);

    final ImageButton playPause = findViewById(R.id.play_pause);
    player.addListener(new SimpleEventListener() {
        @Override
        public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
            //update PlayPause-Button
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                if (player.getPlayWhenReady()) {
                    playPause.setImageResource(R.drawable.play_to_pause_avd);
                } else {
                    playPause.setImageResource(R.drawable.pause_to_play_avd);
                }

                Drawable d = playPause.getDrawable();
                if (d instanceof Animatable) {
                    ((Animatable) d).start();
                }
            } else {
                if (player.getPlayWhenReady()) {
                    playPause.setImageResource(R.drawable.ic_pause_white_24dp);
                } else {
                    playPause.setImageResource(R.drawable.ic_play_arrow_white_24dp);
                }
            }
        }
    });
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:53,代码来源:VideoPlayerActivity.java

示例13: onViewCreated

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
@Override
public void onViewCreated(final View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
    videoView = (SimpleExoPlayerView) view.findViewById(R.id.ec_video_view);
    mediaDataSourceFactory = buildDataSourceFactory(true);
    if (videoView != null){
        @SimpleExoPlayer.ExtensionRendererMode int extensionRendererMode = SimpleExoPlayer.EXTENSION_RENDERER_MODE_ON;//SimpleExoPlayer.EXTENSION_RENDERER_MODE_OFF;
        TrackSelection.Factory videoTrackSelectionFactory =
                        new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER);
        TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
        //trackSelectionHelper = new TrackSelectionHelper(trackSelector, videoTrackSelectionFactory);
        player = ExoPlayerFactory.newSimpleInstance(getActivity(), trackSelector, new DefaultLoadControl(),
                null, extensionRendererMode);
        player.setPlayWhenReady(false);
        videoView.setPlayer(player);
        //videoView.setOnClickListener(showButtonOnClickLister);
    }
    mediaController = new ECMediaController(getActivity(), new NGEPlayerInterface() {
        @Override
        public boolean isPlaying() {
            if (player != null) {
                return player.getPlaybackState() == ExoPlayer.STATE_READY && player.getPlayWhenReady();
            }
            return false;
        }
    });
    mediaController.setMediaPlayer(playerControl);
    previewImageView = (ImageView)view.findViewById(R.id.ec_video_preview_image);
    previewFrame = (RelativeLayout)view.findViewById(R.id.ec_video_preview_image_frame);
    previewPlayBtn = (ImageButton)view.findViewById(R.id.ec_video_preview_playButton);
    aspectRatioFrame = (FixedAspectRatioFrameLayout) view.findViewById(R.id.ec_video_aspect_ratio_frame);
    countDownCountainer = view.findViewById(R.id.count_down_container);
    countDownTextView = (TextView) view.findViewById(R.id.count_down_text_view);
    countDownProgressBar = (ProgressBar) view.findViewById(R.id.count_down_progressBar);

    loadingView = (ProgressBar)view.findViewById(R.id.next_gen_loading_progress_bar);
    if (loadingView != null){
        loadingView.setBackgroundColor(getResources().getColor(android.R.color.transparent));

    }

    if (countDownCountainer != null)
        countDownCountainer.setVisibility(View.INVISIBLE);
    if (countDownProgressBar != null){
        countDownProgressBar.setMax(COUNT_DOWN_SECONDS);
    }

    if (aspectRatioFrame != null){
        aspectRatioFrame.setAspectRatioPriority(aspectFramePriority);
    }

    if (previewPlayBtn != null) {
        previewPlayBtn.setVisibility(View.GONE);
        previewPlayBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (previewFrame != null)
                    previewFrame.setVisibility(View.GONE);
                playerControl.start();
                NGEAnalyticData.reportEvent(getActivity(), ECVideoViewFragment.this, NGEAnalyticData.AnalyticAction.ACTION_SELECT_VIDEO, selectedAVItem.videoId, null);
            }
        });
    }

    player.addListener(ecVideoViewListener);

    videoView.requestFocus();

    bgImageView = (ImageView) view.findViewById(R.id.ec_video_frame_bg);

    if (bgImageView != null && !StringHelper.isEmpty(bgImageUrl)){
        NextGenGlide.load(getActivity(), bgImageUrl).fitCenter().into(bgImageView);
    }
    if (selectedAVItem != null){
        setAudioVisualItem(selectedAVItem);
    }
}
 
开发者ID:warnerbros,项目名称:cpe-manifest-android-experience,代码行数:79,代码来源:ECVideoViewFragment.java


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