• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

UniversalVideoView: Android UniversalVideoView

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

UniversalVideoView

开源软件地址:

https://gitee.com/dictfb/UniversalVideoView

开源软件介绍:

Android UniversalVideoView

中文版说明请点击这里

UniversalVideoView is a Android widget helps playing video easier, which is similar with the Android system native VideoView,but providing more customization feature: fitXY or keeping aspect ratio fullscreen videoView, auto switch to fullscreen on landscape mode, customised control UI...

Sample Screenshot 1Sample Screenshot 2

Usage

For a working implementation of this project see the sample app.

  1. add library dependency to your build.gradle file.
            dependencies {                compile 'com.linsea:universalvideoview:1.1.0@aar'            }
  1. Include the UniversalVideoView and UniversalMediaController widget in your layout. This should usually be placedin the same parent ViewGroup, which makes sense when in full screen state.
            <FrameLayout                android:id="@+id/video_layout"                android:layout_width="fill_parent"                android:layout_height="200dp"                android:background="@android:color/black">                <com.universalvideoview.UniversalVideoView                    android:id="@+id/videoView"                    android:layout_width="fill_parent"                    android:layout_height="fill_parent"                    android:layout_gravity="center"                    app:uvv_autoRotation="true"                    app:uvv_fitXY="false" />                <com.universalvideoview.UniversalMediaController                    android:id="@+id/media_controller"                    android:layout_width="fill_parent"                    android:layout_height="fill_parent"                    app:uvv_scalable="true" />            </FrameLayout>
  1. In your onCreate method, set the UniversalMediaController to the UniversalVideoView and implements the UniversalVideoView.VideoViewCallback Callback.
            View mBottomLayout;            View mVideoLayout;            UniversalVideoView mVideoView;            UniversalMediaController mMediaController;            mVideoView = (UniversalVideoView) findViewById(R.id.videoView);            mMediaController = (UniversalMediaController) findViewById(R.id.media_controller);            mVideoView.setMediaController(mMediaController);            mVideoView.setVideoViewCallback(new UniversalVideoView.VideoViewCallback() {                @Override                public void onScaleChange(boolean isFullscreen) {                    this.isFullscreen = isFullscreen;                    if (isFullscreen) {                        ViewGroup.LayoutParams layoutParams = mVideoLayout.getLayoutParams();                        layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;                        layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;                        mVideoLayout.setLayoutParams(layoutParams);                        //GONE the unconcerned views to leave room for video and controller                        mBottomLayout.setVisibility(View.GONE);                    } else {                        ViewGroup.LayoutParams layoutParams = mVideoLayout.getLayoutParams();                        layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;                        layoutParams.height = this.cachedHeight;                        mVideoLayout.setLayoutParams(layoutParams);                        mBottomLayout.setVisibility(View.VISIBLE);                    }                }                @Override                public void onPause(MediaPlayer mediaPlayer) { // Video pause                    Log.d(TAG, "onPause UniversalVideoView callback");                }                @Override                public void onStart(MediaPlayer mediaPlayer) { // Video start/resume to play                    Log.d(TAG, "onStart UniversalVideoView callback");                }                @Override                public void onBufferingStart(MediaPlayer mediaPlayer) {// steam start loading                    Log.d(TAG, "onBufferingStart UniversalVideoView callback");                }                @Override                public void onBufferingEnd(MediaPlayer mediaPlayer) {// steam end loading                    Log.d(TAG, "onBufferingEnd UniversalVideoView callback");                }            });

##Note

  • Support Android Gingerbread V2.3(API Level 9 and above).
  • UniversalVideoView does not retain its full state when going into the background.You should save or restore the state and take care of the Activity Lifecycle.
  • You may need to set the android:configChanges="orientation|keyboardHidden|screenSize" for your Activity in AndroidManifest.xmlto prevent the system from recreate the Activity while phone rotation.

Customization

##UniversalVideoView attribute

  • uvv_fitXY, Video scale to fill the VideoView's dimension or keep Aspect Ratio (default) likes Android framework VideoView.
  • uvv_autoRotation, auto switch to landscape(fullscreen) or portrait mode according to the orientation sensor.

##UniversalMediaController attribute

  • uvv_scalable, show or hide the scale button. if you will not play the video in fullscreen.

TODO

  • Brightness control on UniversalMediaController.
  • Volume Control on UniversalMediaController.

License

Copyright 2015 The UniversalVideoView author <[email protected]>Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at   http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap