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


Java SimpleExoPlayerView类代码示例

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


SimpleExoPlayerView类属于com.google.android.exoplayer2.ui包,在下文中一共展示了SimpleExoPlayerView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

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

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

示例5: onCreate

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    SimpleExoPlayerView playerView = findViewById(R.id.player_view);
    previewTimeBar = playerView.findViewById(R.id.exo_progress);
    previewTimeBarLayout = findViewById(R.id.previewSeekBarLayout);
    previewTimeBarLayout.setTintColorResource(R.color.colorPrimary);
    previewTimeBar.addOnPreviewChangeListener(this);
    exoPlayerManager = new ExoPlayerManager(playerView, previewTimeBarLayout,
            (ImageView) findViewById(R.id.imageView), getString(R.string.url_thumbnails));
    exoPlayerManager.play(Uri.parse(getString(R.string.url_dash)));
    previewTimeBarLayout.setPreviewLoader(exoPlayerManager);
    requestFullScreenIfLandscape();
}
 
开发者ID:rubensousa,项目名称:PreviewSeekBar,代码行数:17,代码来源:MainActivity.java

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

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

示例8: _initialize

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入依赖的package包/类
@Hide
@Override
public void _initialize(final BA ba, Object activityClass, String EventName) {
	final SimpleExoPlayerView view = new SimpleExoPlayerView(ba.context);
	final String eventName = EventName.toLowerCase(BA.cul);
	setObject(view);
	innerInitialize(ba, eventName, true);
}
 
开发者ID:AnywhereSoftware,项目名称:B4A_ExoPlayer,代码行数:9,代码来源:SimpleExoPlayerViewWrapper.java

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

示例10: ExoPlayerManager

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入依赖的package包/类
public ExoPlayerManager(SimpleExoPlayerView playerView,
                        PreviewTimeBarLayout previewTimeBarLayout, ImageView imageView,
                        String thumbnailsUrl) {
    this.playerView = playerView;
    this.imageView = imageView;
    this.previewTimeBarLayout = previewTimeBarLayout;
    this.mediaSourceBuilder = new ExoPlayerMediaSourceBuilder(playerView.getContext());
    this.thumbnailsUrl = thumbnailsUrl;
}
 
开发者ID:rubensousa,项目名称:PreviewSeekBar,代码行数:10,代码来源:ExoPlayerManager.java

示例11: onCreate

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    SimpleExoPlayerView playerView = findViewById(R.id.player_view);
    SimpleExoPlayerView previewPlayerView
            = findViewById(R.id.previewPlayerView);
    previewTimeBar = playerView.findViewById(R.id.exo_progress);
    previewTimeBarLayout = findViewById(R.id.previewSeekBarLayout);


    previewTimeBarLayout.setTintColorResource(R.color.colorPrimary);

    previewTimeBar.addOnPreviewChangeListener(this);
    exoPlayerManager = new ExoPlayerManager(playerView, previewPlayerView, previewTimeBarLayout);
    exoPlayerManager.play(Uri.parse(getString(R.string.url_hls)));
    previewTimeBarLayout.setup(exoPlayerManager);

    View view = previewPlayerView.getVideoSurfaceView();

    if (view instanceof SurfaceView) {
        SurfaceView surfaceView = (SurfaceView) view;
        surfaceView.setZOrderMediaOverlay(true);
        surfaceView.setZOrderOnTop(true);
        surfaceView.setVisibility(View.INVISIBLE);
    }

    requestFullScreenIfLandscape();
}
 
开发者ID:hongcwamazing,项目名称:PreviewSeekBar-master,代码行数:31,代码来源:MainActivity.java

示例12: ExoPlayerManager

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入依赖的package包/类
public ExoPlayerManager(SimpleExoPlayerView playerView, SimpleExoPlayerView previewPlayerView,
                        PreviewTimeBarLayout previewTimeBarLayout) {
    this.playerView = playerView;
    this.previewPlayerView = previewPlayerView;
    this.previewTimeBarLayout = previewTimeBarLayout;
    this.mediaSourceBuilder = new ExoPlayerMediaSourceBuilder(playerView.getContext());
}
 
开发者ID:hongcwamazing,项目名称:PreviewSeekBar-master,代码行数:8,代码来源:ExoPlayerManager.java

示例13: onPictureInPictureModeChanged

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入依赖的package包/类
@Override
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
    super.onPictureInPictureModeChanged(isInPictureInPictureMode);
    SimpleExoPlayerView simpleExoPlayerView = findViewById(R.id.simpleExoPlayerView);
    if (isInPictureInPictureMode) {
        // Hide the controls in picture-in-picture mode.
        simpleExoPlayerView.hideController();
    } else {
        // Restore the playback UI based on the playback status.
        simpleExoPlayerView.showController();
    }
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:13,代码来源:VideoPlayerActivity.java

示例14: onCreate

import com.google.android.exoplayer2.ui.SimpleExoPlayerView; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    SimpleExoPlayerView playerView = findViewById(R.id.simple_exoplayer_view);

    String videoUrl = "http://docs.evostream.com/sample_content/assets/bunny.mp4";
    getLifecycle().addObserver(new VideoPlayerComponent(getApplicationContext(), playerView, videoUrl));

}
 
开发者ID:riggaroo,项目名称:android-arch-components-lifecycle,代码行数:11,代码来源:VideoPlayerActivity.java

示例15: setView

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


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