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


Java SimpleExoPlayerView.requestFocus方法代码示例

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


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

示例1: onCreate

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    shouldAutoPlay = true;
    clearResumePosition();
    mediaDataSourceFactory = buildDataSourceFactory(true);
    mainHandler = new Handler();
    if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) {
        CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
    }

    setContentView(R.layout.player_activity);
    View rootView = findViewById(R.id.root);
    rootView.setOnClickListener(this);
    debugRootView = (LinearLayout) findViewById(R.id.controls_root);
    debugTextView = (TextView) findViewById(R.id.debug_text_view);
    retryButton = (Button) findViewById(R.id.retry_button);
    retryButton.setOnClickListener(this);

    simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.player_view);
    simpleExoPlayerView.setControllerVisibilityListener(this);
    simpleExoPlayerView.requestFocus();
}
 
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:24,代码来源:PlayerActivity.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: 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

示例4: onCreate

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        shouldAutoPlay = true;
        mediaDataSourceFactory = buildDataSourceFactory(true);
        mainHandler = new Handler();
        window = new Timeline.Window();
        if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) {
            CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
        }

        setContentView(R.layout.player_activity_v2);
//        View rootView = findViewById(root);

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

        /**不使用ExoPlayer自带的mediaController**/
        simpleExoPlayerView.setUseController(false);

        controller = (MediaControlView) findViewById(R.id.player_control);
        controller.setVisibilityListener(new MediaControlView.VisibilityListener() {
            @Override
            public void onVisibilityChange(int visibility) {

            }
        });
        EventBus.getDefault().register(this);
    }
 
开发者ID:AndroidTips,项目名称:MDVideo,代码行数:31,代码来源:PlayerActivityV2.java

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

示例6: onCreate

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  shouldAutoPlay = true;
  mediaDataSourceFactory = buildDataSourceFactory(true);
  mainHandler = new Handler();
  window = new Timeline.Window();
  if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) {
    CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
  }

  setContentView(R.layout.player_activity);
  View rootView = findViewById(R.id.root);
  rootView.setOnClickListener(this);
  debugRootView = (LinearLayout) findViewById(R.id.controls_root);
  debugTextView = (TextView) findViewById(R.id.debug_text_view);
  retryButton = (Button) findViewById(R.id.retry_button);
  retryButton.setOnClickListener(this);

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

  String title = getIntent().getStringExtra(PLAYER_TITLE);
  setTitle(title);
  tracker.setScreenName("播放器: " + title);
  tracker.send(new HitBuilders.ScreenViewBuilder().build());
}
 
开发者ID:TakumaMochizuki,项目名称:Komica,代码行数:29,代码来源:PlayerActivity.java

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

示例8: 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.requestFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。