Search in sources :

Example 1 with MediaController

use of com.hotbitmapgg.bilibili.media.MediaController in project bilibili-android-client by HotBitmapGG.

the class VideoPlayerActivity method initMediaPlayer.

@SuppressLint("UseSparseArrays")
private void initMediaPlayer() {
    //配置播放器
    MediaController mMediaController = new MediaController(this);
    mMediaController.setTitle(title);
    mPlayerView.setMediaController(mMediaController);
    mPlayerView.setMediaBufferingIndicator(mBufferingIndicator);
    mPlayerView.requestFocus();
    mPlayerView.setOnInfoListener(onInfoListener);
    mPlayerView.setOnSeekCompleteListener(onSeekCompleteListener);
    mPlayerView.setOnCompletionListener(onCompletionListener);
    mPlayerView.setOnControllerEventsListener(onControllerEventsListener);
    //设置弹幕开关监听
    mMediaController.setDanmakuSwitchListener(this);
    //设置返回键监听
    mMediaController.setVideoBackEvent(this);
    //配置弹幕库
    mDanmakuView.enableDanmakuDrawingCache(true);
    //设置最大显示行数
    HashMap<Integer, Integer> maxLinesPair = new HashMap<>();
    //滚动弹幕最大显示5行
    maxLinesPair.put(BaseDanmaku.TYPE_SCROLL_RL, 5);
    //设置是否禁止重叠
    HashMap<Integer, Boolean> overlappingEnablePair = new HashMap<>();
    overlappingEnablePair.put(BaseDanmaku.TYPE_SCROLL_RL, true);
    overlappingEnablePair.put(BaseDanmaku.TYPE_FIX_TOP, true);
    //设置弹幕样式
    danmakuContext = DanmakuContext.create();
    danmakuContext.setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 3).setDuplicateMergingEnabled(false).setScrollSpeedFactor(1.2f).setScaleTextSize(0.8f).setMaximumLines(maxLinesPair).preventOverlapping(overlappingEnablePair);
    loadData();
}
Also used : MediaController(com.hotbitmapgg.bilibili.media.MediaController) HashMap(java.util.HashMap) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 MediaController (com.hotbitmapgg.bilibili.media.MediaController)1 HashMap (java.util.HashMap)1