<?xml version="1.0" enCoding="utf-8"?><androID.support.constraint.ConstraintLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" tools:context="com.epix.presentation.player.PlayerActivity"> <com.Google.androID.exoplayer2.ui.SimpleExoPlayerVIEw androID:ID="@+ID/vIDeo_vIEw" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" /></androID.support.constraint.ConstraintLayout>
当视频运行时,屏幕会变暗,我必须点击屏幕才能让它再次变亮.我已经尝试设置androID:keepScreenOn =“true”,这当然没有用,因为屏幕没有关闭它只是暗淡.
有没有办法防止屏幕变暗发生?
解决方法 希望这会对某人有所帮助.在视频播放时设置setKeepScreenOn&仅缓冲,&当视频暂停/未播放/发生任何错误时允许屏幕进入睡眠状态.
playerVIEw = exoPlayerLayout.findVIEwByID(R.ID.exo_player_vIEw);player = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(context),new DefaultTrackSelector(),new DefaultLoadControl());player.addListener(new PlayerEventListener());
PlayerEventListener
private class PlayerEventListener implements Player.EventListener { @OverrIDe public voID onPlayerStateChanged(boolean playWhenReady,int playbackState) { if (playbackState == Player.STATE_IDLE || playbackState == Player.STATE_ENDED || !playWhenReady) { playerVIEw.setKeepScreenOn(false); } else { // STATE_IDLE,STATE_ENDED // This prevents the screen from getting dim/lock playerVIEw.setKeepScreenOn(true); } } @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 onPlayerError(ExoPlaybackException error) { } @OverrIDe public voID onpositiondiscontinuity() { } @OverrIDe public voID onPlaybackParametersChanged(PlaybackParameters playbackParameters) { }}
如果要根据需要修改setKeepScreenOn,请检查播放状态here.
总结以上是内存溢出为你收集整理的android – Exoplayer 2可防止视频播放时屏幕变暗全部内容,希望文章能够帮你解决android – Exoplayer 2可防止视频播放时屏幕变暗所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)