溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

AndroidVideoPlayer在線播放視頻

發(fā)布時間:2020-06-22 22:52:23 來源:網(wǎng)絡(luò) 閱讀:356 作者:楊光成 欄目:移動開發(fā)

AndroidVideoPlayer在線播放視頻

AndroidVideoPlayer在線播放視頻,自定義SuperVideoPlayer里面封裝了startPlayVideo()播放視頻
loadAndPlay(String videoUrl, int seekTime)加載并開始播放視頻,loadVideo(String videoUrl) 加載視頻,
playVideoAtLastPos()更換清晰度地址時,loadMultipleVideo(ArrayList<Video> allVideo) 播放多個視頻,等方法
本項(xiàng)目來源:https://github.com/xiongwei-git/AndroidVideoPlayer
本項(xiàng)目主要代碼:
據(jù)屏幕方向重新設(shè)置播放器的大小
 /***
     * 旋轉(zhuǎn)屏幕之后回調(diào)
     * @param newConfig
     */
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if(null == mSuperVideoPlayer)return;
        /***
         * 根據(jù)屏幕方向重新設(shè)置播放器的大小
         */
        if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
            getWindow().getDecorView().invalidate();
            float height = DensityUtil.getWidthInPx(this);
            float width = DensityUtil.getHeightInPx(this);
            mSuperVideoPlayer.getLayoutParams().height = (int)width;
            mSuperVideoPlayer.getLayoutParams().width = (int)height;
        } else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            final WindowManager.LayoutParams attrs = getWindow().getAttributes();
            attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
            getWindow().setAttributes(attrs);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            float width = DensityUtil.getWidthInPx(this);
            float height = DensityUtil.dip2px(this, 230.f);
            mSuperVideoPlayer.getLayoutParams().height = (int)height;
            mSuperVideoPlayer.getLayoutParams().width = (int)width;
        }
    }

     /***
     * 恢復(fù)屏幕至豎屏
     */
    private void resetPageToPortrait(){
        if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            mSuperVideoPlayer.setPageType(MediaController.PageType.SHRINK);
        }
    }

運(yùn)行效果:

  • AndroidVideoPlayer在線播放視頻

相關(guān)代碼

  • AndroidVideoPlayer在線播放視頻

  • AndroidScreenSlide項(xiàng)目切換view動畫效果

  • ScrollDownLayout ScrollView和viewpager同事存在的事件處理

  • StarRatingBar星星切換動畫

  • AnyShareOfAndroid安卓第三方登錄

  • AnimCheckBox按鈕點(diǎn)擊動畫效果

  • android市面主流側(cè)滑框架

  • PercentageCircle 自定義圓環(huán)效果

  • EmojiChat聊天頁面實(shí)現(xiàn),支持發(fā)送失敗重發(fā)

  • CircularCounter 雙層原形進(jìn)度條效果


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI