├── .gitignore
├── .idea
├── caches
│ ├── build_file_checksums.ser
│ └── gradle_models.ser
├── codeStyles
│ └── Project.xml
├── encodings.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── jarRepositories.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── local_video.mp4
│ ├── java
│ └── com
│ │ └── maning
│ │ └── mnvideoplayer
│ │ ├── MainActivity.java
│ │ └── Utils.java
│ └── res
│ ├── layout
│ └── activity_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ ├── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
│ └── xml
│ └── network_security_config.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── mnvideoplayerlibrary
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── maning
│ │ └── mnvideoplayerlibrary
│ │ ├── listener
│ │ ├── OnCompletionListener.java
│ │ ├── OnNetChangeListener.java
│ │ └── OnScreenOrientationListener.java
│ │ ├── player
│ │ └── MNViderPlayer.java
│ │ ├── utils
│ │ ├── LightnessControl.java
│ │ ├── MediaUtils.java
│ │ └── PlayerUtils.java
│ │ └── view
│ │ └── ProgressWheel.java
│ └── res
│ ├── drawable-xhdpi
│ ├── mn_player_back.png
│ ├── mn_player_backward.png
│ ├── mn_player_battery_01.png
│ ├── mn_player_battery_02.png
│ ├── mn_player_battery_03.png
│ ├── mn_player_battery_04.png
│ ├── mn_player_battery_05.png
│ ├── mn_player_center_play.png
│ ├── mn_player_error.png
│ ├── mn_player_forward.png
│ ├── mn_player_ic_fullscreen.png
│ ├── mn_player_ic_fullscreen_exit.png
│ ├── mn_player_landscape_screen_lock_close.png
│ ├── mn_player_landscape_screen_lock_open.png
│ ├── mn_player_light.png
│ ├── mn_player_pause.png
│ ├── mn_player_play.png
│ ├── mn_player_play_center.png
│ ├── mn_player_progress_no_net.png
│ ├── mn_player_volume_close.png
│ └── mn_player_volume_open.png
│ ├── drawable
│ ├── mn_palyer_bar_bottom.xml
│ ├── mn_palyer_bar_top.xml
│ ├── mn_palyer_black_bg.xml
│ ├── mn_palyer_black_circle.xml
│ ├── mn_player_progress_diy.xml
│ ├── mn_player_progressbar.xml
│ └── mn_player_thumb.xml
│ ├── layout
│ ├── mn_gesture_light_layout.xml
│ ├── mn_gesture_progress_layout.xml
│ ├── mn_gesture_volume_layout.xml
│ ├── mn_player_progress_view.xml
│ └── mn_player_view.xml
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ └── strings.xml
├── screenshots
├── videoplay_001.png
├── videoplay_002.png
├── videoplay_003.png
└── videoplay_004.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MNVideoPlayer
2 | SurfaceView + MediaPlayer 实现的视频播放器,支持横竖屏切换,手势快进快退、调节音量,亮度等。
3 | [](https://jitpack.io/#maning0303/MNVideoPlayer)
4 |
5 | ## 注意:
6 | 一个基础代码,还有很多不完善的地方,只作为一个参考。
7 |
8 | 一个基础代码,还有很多不完善的地方,只作为一个参考。
9 |
10 | 一个基础代码,还有很多不完善的地方,只作为一个参考。
11 |
12 | ## 项目截图:
13 |
14 |
15 |
16 |
17 |
18 |
19 |
24 |
25 |
26 | ## 如何添加
27 | ### Gradle添加:
28 | #### 1.在Project的build.gradle中添加仓库地址
29 | ``` gradle
30 | allprojects {
31 | repositories {
32 | ...
33 | maven { url "https://jitpack.io" }
34 | }
35 | }
36 | ```
37 |
38 | #### 2.在app目录下的build.gradle中添加依赖
39 | ``` gradle
40 | dependencies {
41 | //AndroidX
42 | implementation 'com.github.maning0303:MNVideoPlayer:V1.1.0'
43 | }
44 | ```
45 |
46 | ### moudle添加(建议这种方式代码简单,便于修改):
47 | #### 1:添加mnvideoplayerlibrary为moudle
48 |
49 | ## 使用步骤:
50 | #### 1:布局文件添加
51 | ``` java
52 |
53 |
60 |
61 | ```
62 |
63 | #### 2:代码调用
64 | ``` java
65 | mnViderPlayer.setWidthAndHeightProportion(16, 9); //设置宽高比
66 | mnViderPlayer.setIsNeedBatteryListen(true); //设置电量监听
67 | mnViderPlayer.setIsNeedNetChangeListen(true); //设置网络监听
68 | //第一次进来先设置数据
69 | mnViderPlayer.setDataSource(url2, "标题2");
70 |
71 | //播放完成监听
72 | mnViderPlayer.setOnCompletionListener(new MNViderPlayer.OnCompletionListener() {
73 | @Override
74 | public void onCompletion(MediaPlayer mediaPlayer) {
75 | Log.i(TAG, "播放完成----");
76 | }
77 | });
78 |
79 | //网络监听
80 | mnViderPlayer.setOnNetChangeListener(new MNViderPlayer.OnNetChangeListener() {
81 | @Override
82 | public void onWifi(MediaPlayer mediaPlayer) {
83 | }
84 |
85 | @Override
86 | public void onMobile(MediaPlayer mediaPlayer) {
87 | Toast.makeText(MainActivity.this, "请注意,当前网络状态切换为3G/4G网络", Toast.LENGTH_LONG).show();
88 | }
89 |
90 | @Override
91 | public void onNoAvailable(MediaPlayer mediaPlayer) {
92 | Toast.makeText(MainActivity.this, "当前网络不可用,检查网络设置", Toast.LENGTH_LONG).show();
93 | }
94 | });
95 |
96 | mnViderPlayer.setOnScreenOrientationListener(new OnScreenOrientationListener() {
97 | @Override
98 | public void orientation_landscape() {
99 | Toast.makeText(MainActivity.this, "横屏", Toast.LENGTH_SHORT).show();
100 | }
101 |
102 | @Override
103 | public void orientation_portrait() {
104 | Toast.makeText(MainActivity.this, "竖屏", Toast.LENGTH_SHORT).show();
105 | }
106 | });
107 |
108 | //----------------------------------
109 | //第二次播放调用:
110 | mnViderPlayer.playVideo(url1, "标题1");
111 |
112 |
113 | //退出销毁
114 | @Override
115 | protected void onDestroy() {
116 | //一定要记得销毁View
117 | if (mnViderPlayer != null) {
118 | mnViderPlayer.destroyVideo();
119 | mnViderPlayer = null;
120 | }
121 | super.onDestroy();
122 | }
123 |
124 | ```
125 |
126 |
127 | ## 推荐:
128 | Name | Describe |
129 | --- | --- |
130 | [GankMM](https://github.com/maning0303/GankMM) | (Material Design & MVP & Retrofit + OKHttp & RecyclerView ...)Gank.io Android客户端:每天一张美女图片,一个视频短片,若干Android,iOS等程序干货,周一到周五每天更新,数据全部由 干货集中营 提供,持续更新。 |
131 | [MNUpdateAPK](https://github.com/maning0303/MNUpdateAPK) | Android APK 版本更新的下载和安装,适配7.0,简单方便。 |
132 | [MNImageBrowser](https://github.com/maning0303/MNImageBrowser) | 交互特效的图片浏览框架,微信向下滑动动态关闭 |
133 | [MNCalendar](https://github.com/maning0303/MNCalendar) | 简单的日历控件练习,水平方向日历支持手势滑动切换,跳转月份;垂直方向日历选取区间范围。 |
134 | [MClearEditText](https://github.com/maning0303/MClearEditText) | 带有删除功能的EditText |
135 | [MNCrashMonitor](https://github.com/maning0303/MNCrashMonitor) | Debug监听程序崩溃日志,展示崩溃日志列表,方便自己平时调试。 |
136 | [MNProgressHUD](https://github.com/maning0303/MNProgressHUD) | MNProgressHUD是对常用的自定义弹框封装,加载ProgressDialog,状态显示的StatusDialog和自定义Toast,支持背景颜色,圆角,边框和文字的自定义。 |
137 | [MNXUtilsDB](https://github.com/maning0303/MNXUtilsDB) | xUtils3 数据库模块单独抽取出来,方便使用。 |
138 | [MNVideoPlayer](https://github.com/maning0303/MNVideoPlayer) | SurfaceView + MediaPlayer 实现的视频播放器,支持横竖屏切换,手势快进快退、调节音量,亮度等。------代码简单,新手可以看一看。 |
139 | [MNZXingCode](https://github.com/maning0303/MNZXingCode) | 快速集成二维码扫描和生成二维码 |
140 | [MNChangeSkin](https://github.com/maning0303/MNChangeSkin) | Android夜间模式,通过Theme实现 |
141 | [SwitcherView](https://github.com/maning0303/SwitcherView) | 垂直滚动的广告栏文字展示。 |
142 | [MNPasswordEditText](https://github.com/maning0303/MNPasswordEditText) | 类似微信支付宝的密码输入框。 |
143 | [MNSwipeToLoadDemo](https://github.com/maning0303/MNSwipeToLoadDemo) | 利用SwipeToLoadLayout实现的各种下拉刷新效果(饿了吗,京东,百度外卖,美团外卖,天猫下拉刷新等)。 |
144 |
145 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 |
6 | defaultConfig {
7 | applicationId "com.maning.mnvideoplayer"
8 | minSdkVersion 14
9 | targetSdkVersion 28
10 | versionCode 3
11 | versionName "1.0.1"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | // 支持 JDK 1.8
20 | compileOptions {
21 | targetCompatibility JavaVersion.VERSION_1_8
22 | sourceCompatibility JavaVersion.VERSION_1_8
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 | implementation 'androidx.appcompat:appcompat:1.2.0'
29 | implementation 'com.github.getActivity:XXPermissions:10.8'
30 | implementation 'com.blankj:utilcodex:1.30.6'
31 |
32 | implementation project(':mnvideoplayerlibrary')
33 |
34 | //测试
35 | // implementation 'com.github.maning0303:MNVideoPlayer:V1.1.0'
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/maning/Desktop/Android/AndroidStudioSDK/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/assets/local_video.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/app/src/main/assets/local_video.mp4
--------------------------------------------------------------------------------
/app/src/main/java/com/maning/mnvideoplayer/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.maning.mnvideoplayer;
2 |
3 | import android.media.MediaPlayer;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.widget.Toast;
8 |
9 | import androidx.appcompat.app.AppCompatActivity;
10 |
11 | import com.hjq.permissions.OnPermissionCallback;
12 | import com.hjq.permissions.Permission;
13 | import com.hjq.permissions.XXPermissions;
14 | import com.maning.mnvideoplayerlibrary.listener.OnCompletionListener;
15 | import com.maning.mnvideoplayerlibrary.listener.OnNetChangeListener;
16 | import com.maning.mnvideoplayerlibrary.listener.OnScreenOrientationListener;
17 | import com.maning.mnvideoplayerlibrary.player.MNViderPlayer;
18 |
19 | import java.io.File;
20 | import java.util.List;
21 |
22 | public class MainActivity extends AppCompatActivity {
23 |
24 | private static final String TAG = "MNViderPlayer";
25 |
26 | private final String url1 = "http://vfx.mtime.cn/Video/2019/03/19/mp4/190319125415785691.mp4";
27 | private final String url2 = "http://vfx.mtime.cn/Video/2019/03/19/mp4/190319125415785691.mp4";
28 | //这个地址是错误的
29 | private final String url3 = "http://weibo.com/xxxx";
30 |
31 | private MNViderPlayer mnViderPlayer;
32 | private boolean isInit = false;
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_main);
38 |
39 | initViews();
40 | initPermission();
41 | initPlayer();
42 | }
43 |
44 | private void initPermission() {
45 | XXPermissions.with(this)
46 | .permission(Permission.WRITE_EXTERNAL_STORAGE)
47 | .request(new OnPermissionCallback() {
48 | @Override
49 | public void onGranted(List permissions, boolean all) {
50 |
51 | }
52 | });
53 | }
54 |
55 | private void initViews() {
56 | mnViderPlayer = (MNViderPlayer) findViewById(R.id.mn_videoplayer);
57 | }
58 |
59 | private void initPlayer() {
60 | if (isInit) {
61 | return;
62 | }
63 | isInit = true;
64 | //初始化相关参数(必须放在Play前面)
65 | //设置宽高比
66 | mnViderPlayer.setWidthAndHeightProportion(16, 9);
67 | //设置电量监听
68 | mnViderPlayer.setIsNeedBatteryListen(true);
69 | //设置网络监听
70 | mnViderPlayer.setIsNeedNetChangeListen(true);
71 | //播放完成监听
72 | mnViderPlayer.setOnCompletionListener(new OnCompletionListener() {
73 | @Override
74 | public void onCompletion(MediaPlayer mediaPlayer) {
75 | Log.i(TAG, "播放完成----");
76 | }
77 | });
78 |
79 | mnViderPlayer.setOnScreenOrientationListener(new OnScreenOrientationListener() {
80 | @Override
81 | public void orientation_landscape() {
82 | Toast.makeText(MainActivity.this, "横屏", Toast.LENGTH_SHORT).show();
83 | }
84 |
85 | @Override
86 | public void orientation_portrait() {
87 | Toast.makeText(MainActivity.this, "竖屏", Toast.LENGTH_SHORT).show();
88 | }
89 | });
90 |
91 | //网络监听
92 | mnViderPlayer.setOnNetChangeListener(new OnNetChangeListener() {
93 | @Override
94 | public void onWifi(MediaPlayer mediaPlayer) {
95 | }
96 |
97 | @Override
98 | public void onMobile(MediaPlayer mediaPlayer) {
99 | Toast.makeText(MainActivity.this, "请注意,当前网络状态切换为3G/4G网络", Toast.LENGTH_LONG).show();
100 | }
101 |
102 | @Override
103 | public void onNoAvailable(MediaPlayer mediaPlayer) {
104 | Toast.makeText(MainActivity.this, "当前网络不可用,检查网络设置", Toast.LENGTH_LONG).show();
105 | }
106 | });
107 | //第一次进来先设置数据
108 | mnViderPlayer.setDataSource(url1,"标题1");
109 | }
110 |
111 | public void btn01(View view) {
112 | mnViderPlayer.playVideo(url1, "标题1");
113 | }
114 |
115 | public void btn02(View view) {
116 | //position表示需要跳转到的位置
117 | mnViderPlayer.playVideo(url2, "标题2", 30 * 1000);
118 | }
119 |
120 | public void btn03(View view) {
121 | mnViderPlayer.playVideo(url3, "错误的播放地址");
122 | }
123 |
124 | public void btn04(View view) {
125 | String name = "local_video.mp4";
126 | String path = getExternalCacheDir().getPath();
127 | String url_local = path + "/" + name;
128 | //判断本地有没有这个文件
129 | File file = new File(url_local);
130 | if (file.exists()) {
131 | mnViderPlayer.playVideo(url_local, "本地视频播放");
132 | } else {
133 | Utils.copy(this, name, path, name);
134 | mnViderPlayer.playVideo(url_local, "本地视频播放");
135 | }
136 | }
137 |
138 | @Override
139 | protected void onPause() {
140 | super.onPause();
141 | //暂停
142 | mnViderPlayer.pauseVideo();
143 | }
144 |
145 | @Override
146 | protected void onResume() {
147 | super.onResume();
148 | }
149 |
150 | @Override
151 | public void onBackPressed() {
152 | if (mnViderPlayer.isFullScreen()) {
153 | mnViderPlayer.setOrientationPortrait();
154 | return;
155 | }
156 | super.onBackPressed();
157 | }
158 |
159 | @Override
160 | protected void onDestroy() {
161 | //一定要记得销毁View
162 | if (mnViderPlayer != null) {
163 | mnViderPlayer.destroyVideo();
164 | mnViderPlayer = null;
165 | }
166 | super.onDestroy();
167 | }
168 |
169 | }
170 |
--------------------------------------------------------------------------------
/app/src/main/java/com/maning/mnvideoplayer/Utils.java:
--------------------------------------------------------------------------------
1 | package com.maning.mnvideoplayer;
2 |
3 | import android.content.Context;
4 |
5 | import java.io.File;
6 | import java.io.FileOutputStream;
7 | import java.io.InputStream;
8 |
9 | /**
10 | * @author : maning
11 | * @date : 2021/5/12
12 | * @desc :
13 | */
14 | public class Utils {
15 |
16 | public static void copy(Context myContext, String ASSETS_NAME,
17 | String savePath, String saveName) {
18 | String filename = savePath + "/" + saveName;
19 | File dir = new File(savePath);
20 | // 如果目录不中存在,创建这个目录
21 | if (!dir.exists())
22 | dir.mkdir();
23 | try {
24 | if (!(new File(filename)).exists()) {
25 | InputStream is = myContext.getResources().getAssets()
26 | .open(ASSETS_NAME);
27 | FileOutputStream fos = new FileOutputStream(filename);
28 | byte[] buffer = new byte[7168];
29 | int count = 0;
30 | while ((count = is.read(buffer)) > 0) {
31 | fos.write(buffer, 0, count);
32 | }
33 | fos.close();
34 | is.close();
35 | }
36 | } catch (Exception e) {
37 | e.printStackTrace();
38 | }
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
25 |
26 |
29 |
30 |
35 |
36 |
46 |
47 |
57 |
58 |
68 |
69 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MNVideoPlayer
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 | mavenCentral()
8 | maven { url "https://jitpack.io" }
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:4.0.0'
12 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 | mavenCentral()
24 | maven { url "https://jitpack.io" }
25 | }
26 | }
27 |
28 | task clean(type: Delete) {
29 | delete rootProject.buildDir
30 | }
31 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 | android.enableJetifier=true
20 | android.useAndroidX=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jun 03 11:38:14 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 |
4 | group='com.github.maning0303'
5 |
6 | android {
7 | compileSdkVersion 28
8 |
9 | defaultConfig {
10 | minSdkVersion 14
11 | targetSdkVersion 28
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | implementation fileTree(dir: 'libs', include: ['*.jar'])
25 | compileOnly 'androidx.appcompat:appcompat:1.2.0'
26 | }
27 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/maning/Desktop/Android/AndroidStudioSDK/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/java/com/maning/mnvideoplayerlibrary/listener/OnCompletionListener.java:
--------------------------------------------------------------------------------
1 | package com.maning.mnvideoplayerlibrary.listener;
2 |
3 | import android.media.MediaPlayer;
4 |
5 | /**
6 | * Created by maning on 2017/11/8.
7 | */
8 |
9 | public interface OnCompletionListener {
10 | void onCompletion(MediaPlayer mediaPlayer);
11 | }
12 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/java/com/maning/mnvideoplayerlibrary/listener/OnNetChangeListener.java:
--------------------------------------------------------------------------------
1 | package com.maning.mnvideoplayerlibrary.listener;
2 |
3 | import android.media.MediaPlayer;
4 |
5 | /**
6 | * Created by maning on 2017/11/8.
7 | */
8 |
9 | public interface OnNetChangeListener {
10 |
11 | //wifi
12 | void onWifi(MediaPlayer mediaPlayer);
13 |
14 | //手机
15 | void onMobile(MediaPlayer mediaPlayer);
16 |
17 | //不可用
18 | void onNoAvailable(MediaPlayer mediaPlayer);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/java/com/maning/mnvideoplayerlibrary/listener/OnScreenOrientationListener.java:
--------------------------------------------------------------------------------
1 | package com.maning.mnvideoplayerlibrary.listener;
2 |
3 | /**
4 | * Created by maning on 2017/11/8.
5 | * 屏幕方向的监听
6 | */
7 |
8 | public interface OnScreenOrientationListener {
9 | //横屏
10 | void orientation_landscape();
11 |
12 | //竖屏
13 | void orientation_portrait();
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/java/com/maning/mnvideoplayerlibrary/player/MNViderPlayer.java:
--------------------------------------------------------------------------------
1 | package com.maning.mnvideoplayerlibrary.player;
2 |
3 | import android.app.Activity;
4 | import android.content.BroadcastReceiver;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.IntentFilter;
8 | import android.content.pm.ActivityInfo;
9 | import android.content.pm.PackageManager;
10 | import android.content.res.Configuration;
11 | import android.content.res.TypedArray;
12 | import android.graphics.Bitmap;
13 | import android.media.AudioManager;
14 | import android.media.MediaPlayer;
15 | import android.net.ConnectivityManager;
16 | import android.net.NetworkInfo;
17 | import android.os.Build;
18 | import android.os.Handler;
19 | import android.os.Looper;
20 | import android.text.TextUtils;
21 | import android.util.AttributeSet;
22 | import android.util.DisplayMetrics;
23 | import android.util.Log;
24 | import android.view.Display;
25 | import android.view.GestureDetector;
26 | import android.view.MotionEvent;
27 | import android.view.SurfaceHolder;
28 | import android.view.SurfaceView;
29 | import android.view.View;
30 | import android.view.ViewGroup;
31 | import android.view.ViewTreeObserver;
32 | import android.view.WindowManager;
33 | import android.widget.FrameLayout;
34 | import android.widget.ImageView;
35 | import android.widget.LinearLayout;
36 | import android.widget.ProgressBar;
37 | import android.widget.RelativeLayout;
38 | import android.widget.SeekBar;
39 | import android.widget.TextView;
40 | import android.widget.Toast;
41 |
42 | import com.maning.mnvideoplayerlibrary.R;
43 | import com.maning.mnvideoplayerlibrary.listener.OnCompletionListener;
44 | import com.maning.mnvideoplayerlibrary.listener.OnNetChangeListener;
45 | import com.maning.mnvideoplayerlibrary.listener.OnScreenOrientationListener;
46 | import com.maning.mnvideoplayerlibrary.utils.LightnessControl;
47 | import com.maning.mnvideoplayerlibrary.utils.MediaUtils;
48 | import com.maning.mnvideoplayerlibrary.utils.PlayerUtils;
49 | import com.maning.mnvideoplayerlibrary.view.ProgressWheel;
50 |
51 | import java.lang.reflect.Method;
52 | import java.util.Timer;
53 | import java.util.TimerTask;
54 |
55 |
56 | /**
57 | * Created by maning on 16/6/14.
58 | * 播放器
59 | */
60 | public class MNViderPlayer extends FrameLayout implements View.OnClickListener, SeekBar.OnSeekBarChangeListener,
61 | SurfaceHolder.Callback, GestureDetector.OnGestureListener, MediaPlayer.OnCompletionListener,
62 | MediaPlayer.OnPreparedListener, MediaPlayer.OnErrorListener, MediaPlayer.OnBufferingUpdateListener {
63 |
64 | private static final String TAG = "MNViderPlayer";
65 | private Context context;
66 | private Activity activity;
67 |
68 | static final Handler myHandler = new Handler(Looper.getMainLooper());
69 |
70 | // SurfaceView的创建比较耗时,要注意
71 | private SurfaceHolder surfaceHolder;
72 | private MediaPlayer mediaPlayer;
73 |
74 | //标记暂停和播放状态
75 | private boolean isPlaying = false;
76 | //自动播放
77 | private boolean autoPlay = true;
78 |
79 | //地址
80 | private String videoPath;
81 | private String videoTitle;
82 | private int video_position = 0;
83 |
84 | //控件的位置信息
85 | private float mediaPlayerX;
86 | private float mediaPlayerY;
87 | private int playerViewW;
88 | private int playerViewH;
89 |
90 | // 计时器
91 | private Timer timer_video_time;
92 | private TimerTask task_video_timer;
93 | private Timer timer_controller;
94 | private TimerTask task_controller;
95 |
96 | //是否是横屏
97 | private boolean isFullscreen = false;
98 | private boolean isLockScreen = false;
99 | private boolean isPrepare = false;
100 | private boolean isNeedBatteryListen = true;
101 | private boolean isNeedNetChangeListen = true;
102 |
103 | //默认宽高比16:9
104 | private int defaultWidthProportion = 16;
105 | private int defaultHeightProportion = 9;
106 |
107 | //控件
108 | private LinearLayout mn_player_surface_bg;
109 | private RelativeLayout mn_rl_bottom_menu;
110 | private SurfaceView mn_palyer_surfaceView;
111 | private ImageView mn_iv_play_pause;
112 | private ImageView mn_iv_fullScreen;
113 | private TextView mn_tv_time;
114 | private SeekBar mn_seekBar;
115 | private ImageView mn_iv_back;
116 | private TextView mn_tv_title;
117 | private TextView mn_tv_system_time;
118 | private RelativeLayout mn_rl_top_menu;
119 | private RelativeLayout mn_player_rl_progress;
120 | private ImageView mn_player_iv_lock;
121 | private LinearLayout mn_player_ll_error;
122 | private TextView tv_error_content;
123 | private LinearLayout mn_player_ll_net;
124 | private ProgressWheel mn_player_progressBar;
125 | private ImageView mn_iv_battery;
126 | private ImageView mn_player_iv_play_center;
127 | private ImageView iv_video_thumbnail;
128 |
129 | public MNViderPlayer(Context context) {
130 | this(context, null);
131 | }
132 |
133 | public MNViderPlayer(Context context, AttributeSet attrs) {
134 | this(context, attrs, 0);
135 | }
136 |
137 | public MNViderPlayer(Context context, AttributeSet attrs, int defStyleAttr) {
138 | super(context, attrs, defStyleAttr);
139 | this.context = context;
140 | activity = (Activity) this.context;
141 | //自定义属性相关
142 | initAttrs(context, attrs);
143 | //其他
144 | init();
145 | }
146 |
147 | private void initAttrs(Context context, AttributeSet attrs) {
148 | //获取自定义属性
149 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MNViderPlayer);
150 | //遍历拿到自定义属性
151 | for (int i = 0; i < typedArray.getIndexCount(); i++) {
152 | int index = typedArray.getIndex(i);
153 | if (index == R.styleable.MNViderPlayer_mnVideo_autoPlay) {
154 | autoPlay = typedArray.getBoolean(R.styleable.MNViderPlayer_mnVideo_autoPlay, true);
155 | }
156 | }
157 | //销毁
158 | typedArray.recycle();
159 | }
160 |
161 | @Override
162 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
163 | super.onLayout(changed, left, top, right, bottom);
164 |
165 | }
166 |
167 | @Override
168 | public void onConfigurationChanged(Configuration newConfig) {
169 | super.onConfigurationChanged(newConfig);
170 |
171 | int screenWidth = PlayerUtils.getScreenWidth(activity);
172 |
173 | ViewGroup.LayoutParams layoutParams = getLayoutParams();
174 |
175 | //newConfig.orientation获得当前屏幕状态是横向或者竖向
176 | //Configuration.ORIENTATION_PORTRAIT 表示竖向
177 | //Configuration.ORIENTATION_LANDSCAPE 表示横屏
178 | if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
179 | activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
180 | //计算视频的大小16:9
181 | layoutParams.width = screenWidth;
182 | layoutParams.height = screenWidth * defaultHeightProportion / defaultWidthProportion;
183 | setX(mediaPlayerX);
184 | setY(mediaPlayerY);
185 | //竖屏通知
186 | if (onScreenOrientationListener != null) {
187 | onScreenOrientationListener.orientation_portrait();
188 | }
189 | }
190 | if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
191 | activity.getWindow().setFlags(
192 | WindowManager.LayoutParams.FLAG_FULLSCREEN,
193 | WindowManager.LayoutParams.FLAG_FULLSCREEN);
194 | if (PlayerUtils.checkNavigationBarShow(activity)) {
195 | PlayerUtils.hideBottomUIMenu(activity);
196 | }
197 | layoutParams.width = screenWidth - PlayerUtils.getStatusBarHeight(activity);
198 | layoutParams.height = PlayerUtils.getScreenHeight(activity);
199 | setX(0);
200 | setY(0);
201 | //横屏通知
202 | if (onScreenOrientationListener != null) {
203 | onScreenOrientationListener.orientation_landscape();
204 | }
205 | }
206 | setLayoutParams(layoutParams);
207 |
208 | playerViewW = screenWidth;
209 | playerViewH = layoutParams.height;
210 |
211 | //适配大小
212 | fitVideoSize();
213 | }
214 |
215 | //获取屏幕原始尺寸高度,包括虚拟功能键高度
216 | public static int getDpi(Context context) {
217 | int dpi = 0;
218 | WindowManager windowManager = (WindowManager)
219 | context.getSystemService(Context.WINDOW_SERVICE);
220 | Display display = windowManager.getDefaultDisplay();
221 | DisplayMetrics displayMetrics = new DisplayMetrics();
222 | @SuppressWarnings("rawtypes")
223 | Class c;
224 | try {
225 | c = Class.forName("android.view.Display");
226 | @SuppressWarnings("unchecked")
227 | Method method = c.getMethod("getRealMetrics", DisplayMetrics.class);
228 | method.invoke(display, displayMetrics);
229 | dpi = displayMetrics.widthPixels;
230 | } catch (Exception e) {
231 | e.printStackTrace();
232 | }
233 | return dpi;
234 | }
235 |
236 | //获取屏幕高度 不包含虚拟按键
237 | public static int getScreenWidth(Context context) {
238 | DisplayMetrics dm = context.getResources().getDisplayMetrics();
239 | return dm.widthPixels;
240 | }
241 |
242 |
243 | //初始化
244 | private void init() {
245 | View inflate = View.inflate(context, R.layout.mn_player_view, this);
246 | mn_rl_bottom_menu = (RelativeLayout) inflate.findViewById(R.id.mn_rl_bottom_menu);
247 | mn_palyer_surfaceView = (SurfaceView) inflate.findViewById(R.id.mn_palyer_surfaceView);
248 | mn_iv_play_pause = (ImageView) inflate.findViewById(R.id.mn_iv_play_pause);
249 | mn_iv_fullScreen = (ImageView) inflate.findViewById(R.id.mn_iv_fullScreen);
250 | mn_tv_time = (TextView) inflate.findViewById(R.id.mn_tv_time);
251 | mn_tv_system_time = (TextView) inflate.findViewById(R.id.mn_tv_system_time);
252 | mn_seekBar = (SeekBar) inflate.findViewById(R.id.mn_seekBar);
253 | mn_iv_back = (ImageView) inflate.findViewById(R.id.mn_iv_back);
254 | mn_tv_title = (TextView) inflate.findViewById(R.id.mn_tv_title);
255 | mn_rl_top_menu = (RelativeLayout) inflate.findViewById(R.id.mn_rl_top_menu);
256 | mn_player_rl_progress = (RelativeLayout) inflate.findViewById(R.id.mn_player_rl_progress);
257 | mn_player_iv_lock = (ImageView) inflate.findViewById(R.id.mn_player_iv_lock);
258 | mn_player_ll_error = (LinearLayout) inflate.findViewById(R.id.mn_player_ll_error);
259 | tv_error_content = (TextView) inflate.findViewById(R.id.tv_error_content);
260 | mn_player_ll_net = (LinearLayout) inflate.findViewById(R.id.mn_player_ll_net);
261 | mn_player_progressBar = (ProgressWheel) inflate.findViewById(R.id.mn_player_progressBar);
262 | mn_iv_battery = (ImageView) inflate.findViewById(R.id.mn_iv_battery);
263 | mn_player_iv_play_center = (ImageView) inflate.findViewById(R.id.mn_player_iv_play_center);
264 | mn_player_surface_bg = (LinearLayout) inflate.findViewById(R.id.mn_player_surface_bg);
265 | iv_video_thumbnail = (ImageView) inflate.findViewById(R.id.iv_video_thumbnail);
266 |
267 | mn_seekBar.setOnSeekBarChangeListener(this);
268 | mn_iv_play_pause.setOnClickListener(this);
269 | mn_iv_fullScreen.setOnClickListener(this);
270 | mn_iv_back.setOnClickListener(this);
271 | mn_player_iv_lock.setOnClickListener(this);
272 | mn_player_ll_error.setOnClickListener(this);
273 | mn_player_ll_net.setOnClickListener(this);
274 | mn_player_iv_play_center.setOnClickListener(this);
275 |
276 | //初始化
277 | initViews();
278 |
279 | if (!autoPlay) {
280 | mn_player_iv_play_center.setVisibility(View.VISIBLE);
281 | mn_player_progressBar.setVisibility(View.GONE);
282 | }
283 |
284 | //初始化SurfaceView
285 | initSurfaceView();
286 |
287 | //初始化手势
288 | initGesture();
289 |
290 | //存储控件的位置信息
291 | getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
292 | @Override
293 | public void onGlobalLayout() {
294 | if (playerViewW == 0) {
295 | mediaPlayerX = getX();
296 | mediaPlayerY = getY();
297 | playerViewW = getWidth();
298 | playerViewH = getHeight();
299 | }
300 | }
301 | });
302 |
303 | //判断广播相关
304 | if (isNeedBatteryListen) {
305 | registerBatteryReceiver();
306 | } else {
307 | unRegisterBatteryReceiver();
308 | mn_iv_battery.setVisibility(View.GONE);
309 | }
310 | //网络监听的广播
311 | if (isNeedNetChangeListen) {
312 | registerNetReceiver();
313 | } else {
314 | unregisterNetReceiver();
315 | }
316 | }
317 |
318 | private void initViews() {
319 |
320 | mn_palyer_surfaceView.setAlpha(0);
321 |
322 | mn_tv_system_time.setText(PlayerUtils.getCurrentHHmmTime());
323 | mn_rl_bottom_menu.setVisibility(View.GONE);
324 | mn_rl_top_menu.setVisibility(View.GONE);
325 | mn_player_iv_lock.setVisibility(View.GONE);
326 | initLock();
327 | mn_player_rl_progress.setVisibility(View.VISIBLE);
328 | mn_player_progressBar.setVisibility(View.VISIBLE);
329 | mn_player_ll_error.setVisibility(View.GONE);
330 | mn_player_ll_net.setVisibility(View.GONE);
331 | mn_player_iv_play_center.setVisibility(View.GONE);
332 | initTopMenu();
333 |
334 | mn_player_iv_play_center.setVisibility(View.VISIBLE);
335 | mn_player_progressBar.setVisibility(View.GONE);
336 |
337 | }
338 |
339 | private void setVideoThumbnail() {
340 | if (PlayerUtils.isNetworkConnected(context)) {
341 | MediaUtils.getImageForVideo(getContext(), videoPath, new MediaUtils.OnLoadVideoImageListener() {
342 | @Override
343 | public void onLoadImage(MediaUtils.VideoInfoBean videoInfoBean) {
344 | if (videoInfoBean != null && videoInfoBean.bitmap != null) {
345 | Log.e(">>>>>>", "getImageForVideo-videoInfoBean:" + videoInfoBean.toString());
346 | iv_video_thumbnail.setVisibility(View.VISIBLE);
347 | iv_video_thumbnail.setImageBitmap(videoInfoBean.bitmap);
348 | } else {
349 | Log.e(">>>>>>", "getImageForVideo-videoInfoBean:" + null);
350 | iv_video_thumbnail.setVisibility(View.GONE);
351 | }
352 | }
353 | });
354 | }
355 | }
356 |
357 | private void initLock() {
358 | if (isFullscreen) {
359 | mn_player_iv_lock.setVisibility(View.VISIBLE);
360 | } else {
361 | mn_player_iv_lock.setVisibility(View.GONE);
362 | }
363 | }
364 |
365 | private void initSurfaceView() {
366 | // 得到SurfaceView容器,播放的内容就是显示在这个容器里面
367 | surfaceHolder = mn_palyer_surfaceView.getHolder();
368 | surfaceHolder.setKeepScreenOn(true);
369 | // SurfaceView的一个回调方法
370 | surfaceHolder.addCallback(this);
371 | }
372 |
373 | private void initTopMenu() {
374 | mn_tv_title.setText(videoTitle);
375 | if (isFullscreen) {
376 | mn_rl_top_menu.setVisibility(View.VISIBLE);
377 | } else {
378 | mn_rl_top_menu.setVisibility(View.GONE);
379 | }
380 | }
381 |
382 | @Override
383 | public void onClick(View v) {
384 | int i = v.getId();
385 | if (i == R.id.mn_iv_play_pause) {
386 | if (mediaPlayer != null) {
387 | if (mediaPlayer.isPlaying()) {
388 | pauseVideo();
389 | } else {
390 | startVideo();
391 | }
392 | }
393 | } else if (i == R.id.mn_iv_fullScreen) {
394 | if (isFullscreen) {
395 | setProtrait();
396 | } else {
397 | setLandscape();
398 | }
399 | } else if (i == R.id.mn_iv_back) {
400 | setProtrait();
401 | } else if (i == R.id.mn_player_iv_lock) {
402 | if (isFullscreen) {
403 | if (isLockScreen) {
404 | unLockScreen();
405 | initBottomMenuState();
406 | } else {
407 | lockScreen();
408 | destroyControllerTask(true);
409 | }
410 | }
411 | } else if (i == R.id.mn_player_ll_error || i == R.id.mn_player_ll_net || i == R.id.mn_player_iv_play_center) {
412 | if (!videoPath.startsWith("http") && !hasWritePermission()) {
413 | Toast.makeText(activity, "缺少存储权限,播放失败", Toast.LENGTH_SHORT).show();
414 | } else {
415 | playVideo(videoPath, videoTitle, video_position);
416 | }
417 | }
418 | }
419 |
420 | //--------------------------------------------------------------------------------------
421 | // ######## 相关View的操作 ########
422 | //--------------------------------------------------------------------------------------
423 |
424 | private void unLockScreen() {
425 | isLockScreen = false;
426 | mn_player_iv_lock.setImageResource(R.drawable.mn_player_landscape_screen_lock_open);
427 | }
428 |
429 | private void lockScreen() {
430 | isLockScreen = true;
431 | mn_player_iv_lock.setImageResource(R.drawable.mn_player_landscape_screen_lock_close);
432 | }
433 |
434 | //下面菜单的显示和隐藏
435 | private void initBottomMenuState() {
436 | mn_tv_system_time.setText(PlayerUtils.getCurrentHHmmTime());
437 | if (mn_rl_bottom_menu.getVisibility() == View.GONE) {
438 | initControllerTask();
439 | mn_rl_bottom_menu.setVisibility(View.VISIBLE);
440 | if (isFullscreen) {
441 | mn_rl_top_menu.setVisibility(View.VISIBLE);
442 | mn_player_iv_lock.setVisibility(View.VISIBLE);
443 | }
444 | } else {
445 | destroyControllerTask(true);
446 | }
447 | }
448 |
449 | private void dismissControllerMenu() {
450 | if (isFullscreen && !isLockScreen) {
451 | mn_player_iv_lock.setVisibility(View.GONE);
452 | }
453 | mn_rl_top_menu.setVisibility(View.GONE);
454 | mn_rl_bottom_menu.setVisibility(View.GONE);
455 | }
456 |
457 | private void showErrorView() {
458 | showErrorView("");
459 | }
460 |
461 | private void showErrorView(String errorMsg) {
462 | mn_player_iv_play_center.setVisibility(View.GONE);
463 | mn_player_ll_net.setVisibility(View.GONE);
464 | mn_player_progressBar.setVisibility(View.GONE);
465 | iv_video_thumbnail.setVisibility(View.GONE);
466 | mn_player_ll_error.setVisibility(View.VISIBLE);
467 | if (TextUtils.isEmpty(errorMsg)) {
468 | errorMsg = "加载异常\n点击重新加载";
469 | }
470 | tv_error_content.setText(errorMsg);
471 | }
472 |
473 | private void showNoNetView() {
474 | mn_player_iv_play_center.setVisibility(View.GONE);
475 | mn_player_progressBar.setVisibility(View.GONE);
476 | mn_player_ll_error.setVisibility(View.GONE);
477 | iv_video_thumbnail.setVisibility(View.GONE);
478 | mn_player_ll_net.setVisibility(View.VISIBLE);
479 | }
480 |
481 | private void setLandscape() {
482 | isFullscreen = true;
483 | //设置横屏
484 | ((Activity) context).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
485 | if (mn_rl_bottom_menu.getVisibility() == View.VISIBLE) {
486 | mn_rl_top_menu.setVisibility(View.VISIBLE);
487 | }
488 | initLock();
489 | }
490 |
491 | private void setProtrait() {
492 | isFullscreen = false;
493 | //设置横屏
494 | ((Activity) context).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
495 | mn_rl_top_menu.setVisibility(View.GONE);
496 | unLockScreen();
497 | initLock();
498 | }
499 |
500 | //--------------------------------------------------------------------------------------
501 | // ######## 计时器相关操作 ########
502 | //--------------------------------------------------------------------------------------
503 |
504 | private void initTimeTask() {
505 | timer_video_time = new Timer();
506 | task_video_timer = new TimerTask() {
507 | @Override
508 | public void run() {
509 | myHandler.post(new Runnable() {
510 | @Override
511 | public void run() {
512 | if (mediaPlayer == null) {
513 | return;
514 | }
515 | //设置时间
516 | mn_tv_time.setText(String.valueOf(PlayerUtils.converLongTimeToStr(mediaPlayer.getCurrentPosition()) + " / " + PlayerUtils.converLongTimeToStr(mediaPlayer.getDuration())));
517 | //进度条
518 | int progress = mediaPlayer.getCurrentPosition();
519 | mn_seekBar.setProgress(progress);
520 | }
521 | });
522 | }
523 | };
524 | timer_video_time.schedule(task_video_timer, 0, 1000);
525 | }
526 |
527 | private void destroyTimeTask() {
528 | if (timer_video_time != null && task_video_timer != null) {
529 | timer_video_time.cancel();
530 | task_video_timer.cancel();
531 | timer_video_time = null;
532 | task_video_timer = null;
533 | }
534 | }
535 |
536 | private void initControllerTask() {
537 | // 设置计时器,控制器的影藏和显示
538 | timer_controller = new Timer();
539 | task_controller = new TimerTask() {
540 | @Override
541 | public void run() {
542 | destroyControllerTask(false);
543 | }
544 | };
545 | timer_controller.schedule(task_controller, 5000);
546 | initTimeTask();
547 | }
548 |
549 | private void destroyControllerTask(boolean isMainThread) {
550 | if (isMainThread) {
551 | dismissControllerMenu();
552 | } else {
553 | myHandler.post(new Runnable() {
554 | @Override
555 | public void run() {
556 | dismissControllerMenu();
557 | }
558 | });
559 | }
560 | if (timer_controller != null && task_controller != null) {
561 | timer_controller.cancel();
562 | task_controller.cancel();
563 | timer_controller = null;
564 | task_controller = null;
565 | }
566 | destroyTimeTask();
567 | }
568 |
569 | //--------------------------------------------------------------------------------------
570 | // ######## 接口方法实现 ########
571 | //--------------------------------------------------------------------------------------
572 | @Override
573 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
574 |
575 | }
576 |
577 | @Override
578 | public void onStartTrackingTouch(SeekBar seekBar) {
579 |
580 | }
581 |
582 | @Override
583 | public void onStopTrackingTouch(SeekBar seekBar) {
584 | if (mediaPlayer != null && mediaPlayer.isPlaying()) {
585 | int maxCanSeekTo = seekBar.getMax() - 5 * 1000;
586 | if (seekBar.getProgress() < maxCanSeekTo) {
587 | mediaPlayer.seekTo(seekBar.getProgress());
588 | } else {
589 | //不能拖到最后
590 | mediaPlayer.seekTo(maxCanSeekTo);
591 | }
592 | }
593 | }
594 |
595 | //播放
596 | @Override
597 | public void surfaceCreated(SurfaceHolder holder) {
598 | mediaPlayer = new MediaPlayer();
599 | mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
600 | mediaPlayer.setDisplay(holder); // 添加到容器中
601 | //播放完成的监听
602 | mediaPlayer.setOnCompletionListener(this);
603 | // 异步准备的一个监听函数,准备好了就调用里面的方法
604 | mediaPlayer.setOnPreparedListener(this);
605 | //播放错误的监听
606 | mediaPlayer.setOnErrorListener(this);
607 | mediaPlayer.setOnBufferingUpdateListener(this);
608 |
609 | //第一次初始化需不需要主动播放
610 | if (autoPlay) {
611 | playVideo(videoPath, videoTitle);
612 | autoPlay = true;
613 | }
614 | }
615 |
616 | @Override
617 | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
618 | }
619 |
620 | @Override
621 | public void surfaceDestroyed(SurfaceHolder holder) {
622 | //保存播放位置
623 | if (mediaPlayer != null) {
624 | mediaPlayer.pause();
625 | mn_iv_play_pause.setImageResource(R.drawable.mn_player_play);
626 | video_position = mediaPlayer.getCurrentPosition();
627 | }
628 | destroyControllerTask(true);
629 | }
630 |
631 | //MediaPlayer
632 | @Override
633 | public void onCompletion(MediaPlayer mediaPlayer) {
634 | mn_iv_play_pause.setImageResource(R.drawable.mn_player_play);
635 | isPlaying = false;
636 | destroyControllerTask(true);
637 | video_position = 0;
638 | if (onCompletionListener != null) {
639 | onCompletionListener.onCompletion(mediaPlayer);
640 | }
641 | }
642 |
643 | @Override
644 | public void onBufferingUpdate(MediaPlayer mp, int percent) {
645 | // Log.i(TAG, "二级缓存onBufferingUpdate: " + percent);
646 | if (percent >= 0 && percent <= 100) {
647 | int secondProgress = mp.getDuration() * percent / 100;
648 | mn_seekBar.setSecondaryProgress(secondProgress);
649 | }
650 | }
651 |
652 | @Override
653 | public boolean onError(MediaPlayer mp, int what, int extra) {
654 | // Log.i(TAG, "发生错误error:" + what);
655 | if (what != -38) { //这个错误不管
656 | showErrorView();
657 | }
658 | return true;
659 | }
660 |
661 | @Override
662 | public void onPrepared(final MediaPlayer mediaPlayer) {
663 | //恢复显示,隐藏列缩图
664 | mn_palyer_surfaceView.setAlpha(1);
665 | iv_video_thumbnail.setVisibility(View.GONE);
666 |
667 | mediaPlayer.start();
668 | mn_iv_play_pause.setImageResource(R.drawable.mn_player_pause);
669 | isPrepare = true;
670 | isPlaying = true;
671 | // 把得到的总长度和进度条的匹配
672 | mn_seekBar.setMax(mediaPlayer.getDuration());
673 | mn_tv_time.setText(PlayerUtils.converLongTimeToStr(mediaPlayer.getCurrentPosition()) + "/" + PlayerUtils.converLongTimeToStr(mediaPlayer.getDuration()));
674 | //延时:避免出现上一个视频的画面闪屏
675 | myHandler.postDelayed(new Runnable() {
676 | @Override
677 | public void run() {
678 | initBottomMenuState();
679 | mn_player_rl_progress.setVisibility(View.GONE);
680 |
681 | //跳转指定位置
682 | if (video_position > 0) {
683 | Log.i(TAG, "onPrepared---video_position:" + video_position);
684 | MNViderPlayer.this.mediaPlayer.seekTo(video_position);
685 | video_position = 0;
686 | }
687 | }
688 | }, 500);
689 | //适配大小
690 | fitVideoSize();
691 | }
692 |
693 | private void fitVideoSize() {
694 | if (mediaPlayer == null) {
695 | return;
696 | }
697 | if (playerViewW == 0) {
698 | playerViewW = getWidth();
699 | playerViewH = getHeight();
700 | }
701 | //适配视频的高度
702 | int videoWidth = mediaPlayer.getVideoWidth();
703 | int videoHeight = mediaPlayer.getVideoHeight();
704 | Log.e(">>>>>>>>", "videoWidth:" + videoWidth + ",videoHeight:" + videoHeight);
705 | int parentWidth = playerViewW;
706 | int parentHeight = playerViewH;
707 | Log.e(">>>>>>>>", "parentWidth:" + parentWidth + ",parentHeight:" + parentHeight);
708 | //判断视频宽高和父布局的宽高
709 | int surfaceViewW;
710 | int surfaceViewH;
711 | if ((float) videoWidth / (float) videoHeight > (float) parentWidth / (float) parentHeight) {
712 | surfaceViewW = parentWidth;
713 | surfaceViewH = videoHeight * surfaceViewW / videoWidth;
714 | } else {
715 | surfaceViewH = parentHeight;
716 | surfaceViewW = videoWidth * parentHeight / videoHeight;
717 | }
718 | //改变surfaceView的大小
719 | ViewGroup.LayoutParams params = mn_player_surface_bg.getLayoutParams();
720 | params.height = surfaceViewH;
721 | params.width = surfaceViewW;
722 | Log.e(">>>>>>>>", "surfaceViewW:" + surfaceViewW + ",surfaceViewH:" + surfaceViewH);
723 | mn_player_surface_bg.setLayoutParams(params);
724 | }
725 |
726 | //--------------------------------------------------------------------------------------
727 | // ######## 手势相关 ########
728 | //--------------------------------------------------------------------------------------
729 | private RelativeLayout gesture_volume_layout;// 音量控制布局
730 | private TextView geture_tv_volume_percentage;// 音量百分比
731 | private ProgressBar geture_tv_volume_percentage_progress;// 音量百分比
732 | private ImageView gesture_iv_player_volume;// 音量图标
733 | private RelativeLayout gesture_light_layout;// 亮度布局
734 | private TextView geture_tv_light_percentage;// 亮度百分比
735 | private ProgressBar geture_tv_light_percentageProgress;// 亮度百分比
736 | private RelativeLayout gesture_progress_layout;// 进度图标
737 | private TextView geture_tv_progress_time;// 播放时间进度
738 | private ImageView gesture_iv_progress;// 快进或快退标志
739 | private GestureDetector gestureDetector;
740 | private AudioManager audiomanager;
741 | private int maxVolume, currentVolume;
742 | private static final float STEP_PROGRESS = 2f;// 设定进度滑动时的步长,避免每次滑动都改变,导致改变过快
743 | private static final float STEP_VOLUME = 2f;// 协调音量滑动时的步长,避免每次滑动都改变,导致改变过快
744 | private static final float STEP_LIGHT = 2f;// 协调亮度滑动时的步长,避免每次滑动都改变,导致改变过快
745 | private int GESTURE_FLAG = 0;// 1,调节进度,2,调节音量
746 | private static final int GESTURE_MODIFY_PROGRESS = 1;
747 | private static final int GESTURE_MODIFY_VOLUME = 2;
748 | private static final int GESTURE_MODIFY_BRIGHTNESS = 3;
749 |
750 | private void initGesture() {
751 | gesture_volume_layout = (RelativeLayout) findViewById(R.id.mn_gesture_volume_layout);
752 | geture_tv_volume_percentage = (TextView) findViewById(R.id.mn_gesture_tv_volume_percentage);
753 | geture_tv_volume_percentage_progress = (ProgressBar) findViewById(R.id.mn_gesture_tv_volume_percentage_progress);
754 | gesture_iv_player_volume = (ImageView) findViewById(R.id.mn_gesture_iv_player_volume);
755 |
756 | gesture_progress_layout = (RelativeLayout) findViewById(R.id.mn_gesture_progress_layout);
757 | geture_tv_progress_time = (TextView) findViewById(R.id.mn_gesture_tv_progress_time);
758 | gesture_iv_progress = (ImageView) findViewById(R.id.mn_gesture_iv_progress);
759 |
760 | //亮度的布局
761 | gesture_light_layout = (RelativeLayout) findViewById(R.id.mn_gesture_light_layout);
762 | geture_tv_light_percentage = (TextView) findViewById(R.id.mn_geture_tv_light_percentage);
763 | geture_tv_light_percentageProgress = (ProgressBar) findViewById(R.id.mn_geture_tv_light_percentage_progress);
764 |
765 | gesture_volume_layout.setVisibility(View.GONE);
766 | gesture_progress_layout.setVisibility(View.GONE);
767 | gesture_light_layout.setVisibility(View.GONE);
768 |
769 | gestureDetector = new GestureDetector(getContext(), this);
770 | setLongClickable(true);
771 | gestureDetector.setIsLongpressEnabled(true);
772 | audiomanager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
773 | maxVolume = audiomanager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); // 获取系统最大音量
774 | currentVolume = audiomanager.getStreamVolume(AudioManager.STREAM_MUSIC); // 获取当前值
775 | }
776 |
777 | @Override
778 | public boolean onDown(MotionEvent e) {
779 | return true;
780 | }
781 |
782 | @Override
783 | public void onShowPress(MotionEvent e) {
784 | }
785 |
786 | @Override
787 | public boolean onSingleTapUp(MotionEvent e) {
788 | if (!isPrepare || isLockScreen) {
789 | return false;
790 | }
791 | initBottomMenuState();
792 | return false;
793 | }
794 |
795 | @Override
796 | public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
797 |
798 | if (!isPrepare || isLockScreen) {
799 | return false;
800 | }
801 |
802 | int FLAG = 0;
803 |
804 | // 横向的距离变化大则调整进度,纵向的变化大则调整音量
805 | if (Math.abs(distanceX) >= Math.abs(distanceY)) {
806 | if (mediaPlayer != null && mediaPlayer.isPlaying()) {
807 | FLAG = GESTURE_MODIFY_PROGRESS;
808 | }
809 | } else {
810 | int intX = (int) e1.getX();
811 | int screenWidth = PlayerUtils.getScreenWidth((Activity) context);
812 | if (intX > screenWidth / 2) {
813 | FLAG = GESTURE_MODIFY_VOLUME;
814 | } else {
815 | //左边是亮度
816 | FLAG = GESTURE_MODIFY_BRIGHTNESS;
817 | }
818 | }
819 |
820 | if (GESTURE_FLAG != 0 && GESTURE_FLAG != FLAG) {
821 | return false;
822 | }
823 |
824 | GESTURE_FLAG = FLAG;
825 |
826 | if (FLAG == GESTURE_MODIFY_PROGRESS) {
827 | //表示是横向滑动,可以添加快进
828 | // distanceX=lastScrollPositionX-currentScrollPositionX,因此为正时是快进
829 | gesture_volume_layout.setVisibility(View.GONE);
830 | gesture_light_layout.setVisibility(View.GONE);
831 | gesture_progress_layout.setVisibility(View.VISIBLE);
832 | try {
833 | if (mediaPlayer != null && mediaPlayer.isPlaying()) {
834 | if (Math.abs(distanceX) > Math.abs(distanceY)) {// 横向移动大于纵向移动
835 | if (distanceX >= PlayerUtils.dip2px(context, STEP_PROGRESS)) {// 快退,用步长控制改变速度,可微调
836 | gesture_iv_progress
837 | .setImageResource(R.drawable.mn_player_backward);
838 | if (mediaPlayer.getCurrentPosition() > 3 * 1000) {// 避免为负
839 | int cpos = mediaPlayer.getCurrentPosition();
840 | mediaPlayer.seekTo(cpos - 3000);
841 | mn_seekBar.setProgress(mediaPlayer.getCurrentPosition());
842 | } else {
843 | //什么都不做
844 | mediaPlayer.seekTo(3000);
845 | }
846 | } else if (distanceX <= -PlayerUtils.dip2px(context, STEP_PROGRESS)) {// 快进
847 | gesture_iv_progress
848 | .setImageResource(R.drawable.mn_player_forward);
849 | if (mediaPlayer.getCurrentPosition() < mediaPlayer.getDuration() - 5 * 1000) {// 避免超过总时长
850 | int cpos = mediaPlayer.getCurrentPosition();
851 | mediaPlayer.seekTo(cpos + 3000);
852 | // 把当前位置赋值给进度条
853 | mn_seekBar.setProgress(mediaPlayer.getCurrentPosition());
854 | }
855 | }
856 | }
857 | String timeStr = PlayerUtils.converLongTimeToStr(mediaPlayer.getCurrentPosition()) + " / "
858 | + PlayerUtils.converLongTimeToStr(mediaPlayer.getDuration());
859 | geture_tv_progress_time.setText(timeStr);
860 |
861 | }
862 | } catch (IllegalStateException e) {
863 | e.printStackTrace();
864 | }
865 | }
866 | // 如果每次触摸屏幕后第一次scroll是调节音量,那之后的scroll事件都处理音量调节,直到离开屏幕执行下一次操作
867 | else if (FLAG == GESTURE_MODIFY_VOLUME) {
868 | //右边是音量
869 | gesture_volume_layout.setVisibility(View.VISIBLE);
870 | gesture_light_layout.setVisibility(View.GONE);
871 | gesture_progress_layout.setVisibility(View.GONE);
872 | currentVolume = audiomanager.getStreamVolume(AudioManager.STREAM_MUSIC); // 获取当前值
873 | if (Math.abs(distanceY) > Math.abs(distanceX)) {// 纵向移动大于横向移动
874 | if (currentVolume == 0) {// 静音,设定静音独有的图片
875 | gesture_iv_player_volume.setImageResource(R.drawable.mn_player_volume_close);
876 | }
877 | if (distanceY >= PlayerUtils.dip2px(context, STEP_VOLUME)) {// 音量调大,注意横屏时的坐标体系,尽管左上角是原点,但横向向上滑动时distanceY为正
878 | if (currentVolume < maxVolume) {// 为避免调节过快,distanceY应大于一个设定值
879 | currentVolume++;
880 | }
881 | gesture_iv_player_volume.setImageResource(R.drawable.mn_player_volume_open);
882 | } else if (distanceY <= -PlayerUtils.dip2px(context, STEP_VOLUME)) {// 音量调小
883 | if (currentVolume > 0) {
884 | currentVolume--;
885 | if (currentVolume == 0) {// 静音,设定静音独有的图片
886 | gesture_iv_player_volume.setImageResource(R.drawable.mn_player_volume_close);
887 | }
888 | }
889 | }
890 | int percentage = (currentVolume * 100) / maxVolume;
891 | geture_tv_volume_percentage.setText(String.valueOf(percentage + "%"));
892 | geture_tv_volume_percentage_progress.setProgress(percentage);
893 | audiomanager.setStreamVolume(AudioManager.STREAM_MUSIC, currentVolume, 0);
894 | }
895 | }
896 | //调节亮度
897 | else if (FLAG == GESTURE_MODIFY_BRIGHTNESS) {
898 | gesture_volume_layout.setVisibility(View.GONE);
899 | gesture_light_layout.setVisibility(View.VISIBLE);
900 | gesture_progress_layout.setVisibility(View.GONE);
901 | currentVolume = audiomanager.getStreamVolume(AudioManager.STREAM_MUSIC); // 获取当前值
902 | if (Math.abs(distanceY) > Math.abs(distanceX)) {// 纵向移动大于横向移动
903 | // 亮度调大,注意横屏时的坐标体系,尽管左上角是原点,但横向向上滑动时distanceY为正
904 | if (distanceY >= PlayerUtils.dip2px(context, STEP_LIGHT)) {
905 | LightnessControl.SetLightness((Activity) context, 10);
906 | } else if (distanceY <= -PlayerUtils.dip2px(context, STEP_LIGHT)) {// 亮度调小
907 | LightnessControl.SetLightness((Activity) context, -10);
908 | }
909 | //获取当前亮度
910 | int currentLight = LightnessControl.GetLightness((Activity) context);
911 | int percentage = (currentLight * 100) / 255;
912 | geture_tv_light_percentage.setText(percentage + "%");
913 | geture_tv_light_percentageProgress.setProgress(percentage);
914 | }
915 | }
916 | return false;
917 | }
918 |
919 | @Override
920 | public void onLongPress(MotionEvent e) {
921 | }
922 |
923 | @Override
924 | public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
925 | return false;
926 | }
927 |
928 | @Override
929 | public boolean onTouchEvent(MotionEvent event) {
930 | // 手势里除了singleTapUp,没有其他检测up的方法
931 | if (event.getAction() == MotionEvent.ACTION_UP) {
932 | GESTURE_FLAG = 0;// 手指离开屏幕后,重置调节音量或进度的标志
933 | gesture_volume_layout.setVisibility(View.GONE);
934 | gesture_progress_layout.setVisibility(View.GONE);
935 | gesture_light_layout.setVisibility(View.GONE);
936 | }
937 | return gestureDetector.onTouchEvent(event);
938 | }
939 |
940 | //--------------------------------------------------------------------------------------
941 | // ######## 对外提供的方法 ########
942 | //--------------------------------------------------------------------------------------
943 |
944 | /**
945 | * 设置宽高比:默认16:9
946 | */
947 | public void setWidthAndHeightProportion(int width, int height) {
948 | this.defaultWidthProportion = width;
949 | this.defaultHeightProportion = height;
950 | }
951 |
952 | /**
953 | * 设置视频信息
954 | *
955 | * @param url 视频地址
956 | * @param title 视频标题
957 | */
958 | public void setDataSource(String url, String title) {
959 | //赋值
960 | videoPath = url;
961 | videoTitle = title;
962 | setVideoThumbnail();
963 | }
964 |
965 | /**
966 | * 播放视频
967 | *
968 | * @param url 视频地址
969 | * @param title 视频标题
970 | */
971 | public void playVideo(String url, String title) {
972 | playVideo(url, title, video_position);
973 | }
974 |
975 | /**
976 | * 播放视频(支持上次播放位置)
977 | * 自己记录上一次播放的位置,然后传递position进来就可以了
978 | *
979 | * @param url 视频地址
980 | * @param title 视频标题
981 | * @param position 视频跳转的位置(毫秒)
982 | */
983 | public void playVideo(String url, String title, int position) {
984 | //地址判空处理
985 | if (TextUtils.isEmpty(url)) {
986 | Toast.makeText(context, context.getString(R.string.mnPlayerUrlEmptyHint), Toast.LENGTH_SHORT).show();
987 | return;
988 | }
989 | //销毁ControllerView
990 | destroyControllerTask(true);
991 |
992 | //赋值
993 | videoPath = url;
994 | videoTitle = title;
995 | video_position = position;
996 | isPrepare = false;
997 |
998 | //初始化View
999 | initViews();
1000 |
1001 | //判断当前有没有网络(播放的是网络视频)
1002 | if (!PlayerUtils.isNetworkConnected(context) && url.startsWith("http")) {
1003 | Toast.makeText(context, context.getString(R.string.mnPlayerNoNetHint), Toast.LENGTH_SHORT).show();
1004 | showNoNetView();
1005 | return;
1006 | }
1007 | //手机网络给提醒
1008 | if (PlayerUtils.isMobileConnected(context) && url.startsWith("http")) {
1009 | Toast.makeText(context, context.getString(R.string.mnPlayerMobileNetHint), Toast.LENGTH_SHORT).show();
1010 | }
1011 |
1012 | //本地权限问题
1013 | if (!url.startsWith("http") && !hasWritePermission()) {
1014 | showErrorView("没有存储权限\n点击重新加载");
1015 | return;
1016 | }
1017 |
1018 | //重置MediaPlayer
1019 | resetMediaPlayer();
1020 | }
1021 |
1022 | public boolean hasWritePermission() {
1023 | int perm = activity.checkCallingOrSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE");
1024 | return perm == PackageManager.PERMISSION_GRANTED;
1025 | }
1026 |
1027 | private void resetMediaPlayer() {
1028 | try {
1029 | if (mediaPlayer != null) {
1030 | if (mediaPlayer.isPlaying()) {
1031 | mediaPlayer.pause();
1032 | mediaPlayer.stop();
1033 | }
1034 | //重置mediaPlayer
1035 | mediaPlayer.reset();
1036 | //添加播放路径
1037 | mediaPlayer.setDataSource(videoPath);
1038 | // 准备开始,异步准备,自动在子线程中
1039 | mediaPlayer.prepareAsync();
1040 | //视频缩放模式
1041 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
1042 | mediaPlayer.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT);
1043 | }
1044 | } else {
1045 | //TODO:播放器初始化失败后怎么操作
1046 | Toast.makeText(context, "播放器初始化失败", Toast.LENGTH_SHORT).show();
1047 | }
1048 | } catch (Exception e) {
1049 | e.printStackTrace();
1050 | }
1051 | }
1052 |
1053 | /**
1054 | * 播放视频
1055 | */
1056 | public void startVideo() {
1057 | if (mediaPlayer != null) {
1058 | mediaPlayer.start();
1059 | mn_iv_play_pause.setImageResource(R.drawable.mn_player_pause);
1060 | isPlaying = true;
1061 | }
1062 | }
1063 |
1064 | /**
1065 | * 暂停视频
1066 | */
1067 | public void pauseVideo() {
1068 | if (mediaPlayer != null) {
1069 | mediaPlayer.pause();
1070 | mn_iv_play_pause.setImageResource(R.drawable.mn_player_play);
1071 | video_position = mediaPlayer.getCurrentPosition();
1072 | isPlaying = false;
1073 | }
1074 | }
1075 |
1076 | /**
1077 | * 竖屏
1078 | */
1079 | public void setOrientationPortrait() {
1080 | setProtrait();
1081 | }
1082 |
1083 | /**
1084 | * 横屏
1085 | */
1086 | public void setOrientationLandscape() {
1087 | setLandscape();
1088 | }
1089 |
1090 | /**
1091 | * 设置是否需要电量监听
1092 | */
1093 | public void setIsNeedBatteryListen(boolean isNeedBatteryListen) {
1094 | this.isNeedBatteryListen = isNeedBatteryListen;
1095 | }
1096 |
1097 | /**
1098 | * 设置是否需要网络变化监听
1099 | */
1100 | public void setIsNeedNetChangeListen(boolean isNeedNetChangeListen) {
1101 | this.isNeedNetChangeListen = isNeedNetChangeListen;
1102 | }
1103 |
1104 | /**
1105 | * 判断是不是全屏状态
1106 | *
1107 | * @return
1108 | */
1109 | public boolean isFullScreen() {
1110 | return isFullscreen;
1111 | }
1112 |
1113 | /**
1114 | * 获取当前播放的位置
1115 | */
1116 | public int getVideoCurrentPosition() {
1117 | int position = 0;
1118 | if (mediaPlayer != null) {
1119 | position = mediaPlayer.getCurrentPosition();
1120 | }
1121 | return position;
1122 | }
1123 |
1124 | /**
1125 | * 获取视频总长度
1126 | */
1127 | public int getVideoTotalDuration() {
1128 | int position = 0;
1129 | if (mediaPlayer != null) {
1130 | position = mediaPlayer.getDuration();
1131 | }
1132 | return position;
1133 | }
1134 |
1135 | /**
1136 | * 获取管理者
1137 | */
1138 | public MediaPlayer getMediaPlayer() {
1139 | return mediaPlayer;
1140 | }
1141 |
1142 | /**
1143 | * 销毁资源
1144 | */
1145 | public void destroyVideo() {
1146 | if (mediaPlayer != null) {
1147 | mediaPlayer.stop();
1148 | mediaPlayer.release();// 释放资源
1149 | mediaPlayer = null;
1150 | }
1151 | surfaceHolder = null;
1152 | mn_palyer_surfaceView = null;
1153 | video_position = 0;
1154 | unRegisterBatteryReceiver();
1155 | unregisterNetReceiver();
1156 | removeAllListener();
1157 | destroyTimeTask();
1158 | myHandler.removeCallbacksAndMessages(null);
1159 | }
1160 |
1161 |
1162 | //--------------------------------------------------------------------------------------
1163 | // ######## 广播相关 ########
1164 | //--------------------------------------------------------------------------------------
1165 |
1166 | /**
1167 | * 电量广播接受者
1168 | */
1169 | class BatteryReceiver extends BroadcastReceiver {
1170 | @Override
1171 | public void onReceive(Context context, Intent intent) {
1172 | //判断它是否是为电量变化的Broadcast Action
1173 | if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
1174 | //获取当前电量
1175 | int level = intent.getIntExtra("level", 0);
1176 | //电量的总刻度
1177 | int scale = intent.getIntExtra("scale", 100);
1178 |
1179 | int battery = (level * 100) / scale;
1180 |
1181 | //把它转成百分比
1182 | Log.i(TAG, "电池电量为" + battery + "%");
1183 |
1184 | mn_iv_battery.setVisibility(View.VISIBLE);
1185 | if (battery > 0 && battery < 20) {
1186 | mn_iv_battery.setImageResource(R.drawable.mn_player_battery_01);
1187 | } else if (battery >= 20 && battery < 40) {
1188 | mn_iv_battery.setImageResource(R.drawable.mn_player_battery_02);
1189 | } else if (battery >= 40 && battery < 65) {
1190 | mn_iv_battery.setImageResource(R.drawable.mn_player_battery_03);
1191 | } else if (battery >= 65 && battery < 90) {
1192 | mn_iv_battery.setImageResource(R.drawable.mn_player_battery_04);
1193 | } else if (battery >= 90 && battery <= 100) {
1194 | mn_iv_battery.setImageResource(R.drawable.mn_player_battery_05);
1195 | } else {
1196 | mn_iv_battery.setVisibility(View.GONE);
1197 | }
1198 |
1199 |
1200 | }
1201 | }
1202 | }
1203 |
1204 | private BatteryReceiver batteryReceiver;
1205 |
1206 | private void registerBatteryReceiver() {
1207 | if (batteryReceiver == null) {
1208 | //注册广播接受者
1209 | IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
1210 | //创建广播接受者对象
1211 | batteryReceiver = new BatteryReceiver();
1212 | //注册receiver
1213 | context.registerReceiver(batteryReceiver, intentFilter);
1214 | }
1215 | }
1216 |
1217 | private void unRegisterBatteryReceiver() {
1218 | if (batteryReceiver != null) {
1219 | context.unregisterReceiver(batteryReceiver);
1220 | }
1221 | }
1222 |
1223 | //-------------------------网络变化监听
1224 | public class NetChangeReceiver extends BroadcastReceiver {
1225 | @Override
1226 | public void onReceive(Context context, Intent intent) {
1227 | if (onNetChangeListener == null || !isNeedNetChangeListen) {
1228 | return;
1229 | }
1230 | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
1231 | NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo();
1232 | if (netInfo != null && netInfo.isAvailable()) {
1233 | if (netInfo.getType() == ConnectivityManager.TYPE_WIFI) { //WiFi网络
1234 | onNetChangeListener.onWifi(mediaPlayer);
1235 | } else if (netInfo.getType() == ConnectivityManager.TYPE_MOBILE) { //3g网络
1236 | onNetChangeListener.onMobile(mediaPlayer);
1237 | } else { //其他
1238 | Log.i(TAG, "其他网络");
1239 | }
1240 | } else {
1241 | onNetChangeListener.onNoAvailable(mediaPlayer);
1242 | }
1243 | }
1244 | }
1245 |
1246 | private NetChangeReceiver netChangeReceiver;
1247 |
1248 | private void registerNetReceiver() {
1249 | if (netChangeReceiver == null) {
1250 | IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
1251 | netChangeReceiver = new NetChangeReceiver();
1252 | context.registerReceiver(netChangeReceiver, filter);
1253 | }
1254 | }
1255 |
1256 | private void unregisterNetReceiver() {
1257 | if (netChangeReceiver != null) {
1258 | context.unregisterReceiver(netChangeReceiver);
1259 | }
1260 | }
1261 |
1262 |
1263 | //--------------------------------------------------------------------------------------
1264 | // ######## 自定义回调 ########
1265 | //--------------------------------------------------------------------------------------
1266 |
1267 | private void removeAllListener() {
1268 | if (onNetChangeListener != null) {
1269 | onNetChangeListener = null;
1270 | }
1271 | if (onCompletionListener != null) {
1272 | onCompletionListener = null;
1273 | }
1274 | }
1275 |
1276 |
1277 | //网络监听回调
1278 | private OnNetChangeListener onNetChangeListener;
1279 |
1280 | public void setOnNetChangeListener(OnNetChangeListener onNetChangeListener) {
1281 | this.onNetChangeListener = onNetChangeListener;
1282 | }
1283 |
1284 | //-----------------------播放完回调
1285 | private OnCompletionListener onCompletionListener;
1286 |
1287 | public void setOnCompletionListener(OnCompletionListener onCompletionListener) {
1288 | this.onCompletionListener = onCompletionListener;
1289 | }
1290 |
1291 | //-----------------------屏幕方向的监听
1292 | private OnScreenOrientationListener onScreenOrientationListener;
1293 |
1294 | public void setOnScreenOrientationListener(OnScreenOrientationListener onScreenOrientationListener) {
1295 | this.onScreenOrientationListener = onScreenOrientationListener;
1296 | }
1297 |
1298 | }
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/java/com/maning/mnvideoplayerlibrary/utils/LightnessControl.java:
--------------------------------------------------------------------------------
1 | package com.maning.mnvideoplayerlibrary.utils;
2 |
3 | import android.app.Activity;
4 | import android.content.ContentResolver;
5 | import android.nfc.Tag;
6 | import android.provider.Settings;
7 | import android.util.Log;
8 | import android.view.WindowManager;
9 | import android.widget.Toast;
10 |
11 | /**
12 | * 调节屏幕亮度的类
13 | */
14 | public class LightnessControl {
15 |
16 | // 改变亮度
17 | public static void SetLightness(Activity act, int value) {
18 | try {
19 | WindowManager.LayoutParams lp = act.getWindow().getAttributes();
20 | Log.e(">>>>>>>>>", "lp.screenBrightness:" + lp.screenBrightness);
21 | if (lp.screenBrightness == -1.0) {
22 | lp.screenBrightness = 0.5f;
23 | }
24 | lp.screenBrightness = lp.screenBrightness + value / 255.0f;
25 | if (lp.screenBrightness > 1) {
26 | lp.screenBrightness = 1;
27 | } else if (lp.screenBrightness < 0) {
28 | lp.screenBrightness = 0f;
29 | }
30 | act.getWindow().setAttributes(lp);
31 | } catch (Exception e) {
32 | }
33 | }
34 |
35 | // 获取亮度0~255
36 | public static int GetLightness(Activity act) {
37 | WindowManager.LayoutParams lp = act.getWindow().getAttributes();
38 | return (int) (lp.screenBrightness * 255f);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/java/com/maning/mnvideoplayerlibrary/utils/MediaUtils.java:
--------------------------------------------------------------------------------
1 | package com.maning.mnvideoplayerlibrary.utils;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Matrix;
6 | import android.media.MediaMetadataRetriever;
7 | import android.media.ThumbnailUtils;
8 | import android.os.AsyncTask;
9 | import android.os.Build;
10 | import android.util.Log;
11 |
12 | import java.io.Serializable;
13 | import java.security.MessageDigest;
14 | import java.util.HashMap;
15 | import java.util.Map;
16 |
17 | /**
18 | * @author : maning
19 | * @date : 2020-04-24
20 | * @desc :
21 | */
22 | public class MediaUtils {
23 |
24 | private static Map mVideoInfoCacheMap = new HashMap<>();
25 |
26 | public static class VideoInfoBean implements Serializable {
27 | private static final long serialVersionUID = 432751628698075887L;
28 | public int duration;
29 | public int width;
30 | public int height;
31 | public Bitmap bitmap;
32 |
33 | @Override
34 | public String toString() {
35 | return "VideoInfoBean{" +
36 | "duration=" + duration +
37 | ", width=" + width +
38 | ", height=" + height +
39 | ", bitmap=" + bitmap +
40 | '}';
41 | }
42 | }
43 |
44 | public static VideoInfoBean getLocalVideoInfo(String path) {
45 | if (mVideoInfoCacheMap.containsKey(path)) {
46 | VideoInfoBean videoInfoBeanCache = mVideoInfoCacheMap.get(path);
47 | return videoInfoBeanCache;
48 | }
49 | VideoInfoBean videoInfoBean = new VideoInfoBean();
50 | //视频支持的格式有:3gp、mp4、mkv、avi、m4v、ts、swf等
51 | //不支持:rmvb、rm、wmv。
52 | MediaMetadataRetriever retriever = new MediaMetadataRetriever();
53 | int videoWidth = 0;
54 | int videoHeight = 0;
55 | int duration = 0;
56 | try {
57 | //根据url获取缩略图
58 | retriever.setDataSource(path);
59 | //获得第一帧图片
60 | Bitmap bitmap = retriever.getFrameAtTime();
61 | if (bitmap != null) {
62 | videoInfoBean.bitmap = bitmap;
63 | videoWidth = bitmap.getWidth();
64 | videoHeight = bitmap.getHeight();
65 | } else {
66 | videoWidth = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
67 | videoHeight = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
68 | //竖屏的时候 orientation = 90,横屏 orientation = 0
69 | String orientation = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);
70 | if ("90".equals(orientation) || "270".equals(orientation)) {
71 | //交换一下高度
72 | int tempWidth = videoWidth;
73 | videoWidth = videoHeight;
74 | videoHeight = tempWidth;
75 | }
76 | }
77 | duration = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
78 | } catch (Exception e) {
79 | e.printStackTrace();
80 | videoWidth = 0;
81 | videoHeight = 0;
82 | duration = 0;
83 | } finally {
84 | try {
85 | retriever.release();
86 | } catch (RuntimeException ex) {
87 | // Ignore failures while cleaning up.
88 | }
89 | }
90 | videoInfoBean.width = videoWidth;
91 | videoInfoBean.height = videoHeight;
92 | videoInfoBean.duration = duration / 1000;
93 | mVideoInfoCacheMap.put(path, videoInfoBean);
94 | return videoInfoBean;
95 | }
96 |
97 | /**
98 | * 获取视频的第一帧图片
99 | */
100 | public static void getImageForVideo(Context context, String path, OnLoadVideoImageListener listener) {
101 | getImageForVideo(context, path, 0, 0, listener);
102 | }
103 |
104 | public static void getImageForVideo(Context context, String path, int width, int height, OnLoadVideoImageListener listener) {
105 | if (mVideoInfoCacheMap.containsKey(path)) {
106 | VideoInfoBean videoInfoBean = mVideoInfoCacheMap.get(path);
107 | listener.onLoadImage(videoInfoBean);
108 | return;
109 | }
110 | LoadVideoImageTask task = new LoadVideoImageTask(listener, width, height);
111 | task.execute(path);
112 | }
113 |
114 | public static class LoadVideoImageTask extends AsyncTask {
115 | private OnLoadVideoImageListener listener;
116 | private int width;
117 | private int height;
118 |
119 | public LoadVideoImageTask(OnLoadVideoImageListener listener, int width, int height) {
120 | this.listener = listener;
121 | this.width = width;
122 | this.height = height;
123 | }
124 |
125 | @Override
126 | protected VideoInfoBean doInBackground(String... params) {
127 | String path = params[0];
128 | VideoInfoBean videoInfoBean = getNetVideoBitmap(path, width, height);
129 | mVideoInfoCacheMap.put(path, videoInfoBean);
130 | return videoInfoBean;
131 | }
132 |
133 | @Override
134 | protected void onPostExecute(VideoInfoBean videoInfoBean) {
135 | super.onPostExecute(videoInfoBean);
136 | if (listener != null) {
137 | listener.onLoadImage(videoInfoBean);
138 | }
139 | }
140 | }
141 |
142 | public interface OnLoadVideoImageListener {
143 | void onLoadImage(VideoInfoBean videoInfoBean);
144 |
145 | }
146 |
147 | public static VideoInfoBean getNetVideoBitmap(String videoUrl, int width, int height) {
148 | VideoInfoBean videoInfoBean = new VideoInfoBean();
149 | MediaMetadataRetriever retriever = new MediaMetadataRetriever();
150 | try {
151 | int videoWidth;
152 | int videoHeight;
153 |
154 | //根据url获取缩略图
155 | retriever.setDataSource(videoUrl, new HashMap());
156 | //获得第一帧图片
157 | Bitmap bitmap = retriever.getFrameAtTime();
158 | if (bitmap != null) {
159 | if (width > 0 && height > 0) {
160 | bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,
161 | ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
162 | }
163 | //尝试压缩
164 | bitmap = compressBitmap(bitmap);
165 |
166 | videoWidth = bitmap.getWidth();
167 | videoHeight = bitmap.getHeight();
168 | } else {
169 | videoWidth = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
170 | videoHeight = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
171 | //竖屏的时候 orientation = 90,横屏 orientation = 0
172 | String orientation = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);
173 | if ("90".equals(orientation) || "270".equals(orientation)) {
174 | //交换一下高度
175 | int tempWidth = videoWidth;
176 | videoWidth = videoHeight;
177 | videoHeight = tempWidth;
178 | }
179 | }
180 | int duration = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
181 |
182 | videoInfoBean.bitmap = bitmap;
183 | videoInfoBean.width = videoWidth;
184 | videoInfoBean.height = videoHeight;
185 | videoInfoBean.duration = duration / 1000;
186 | } catch (Exception e) {
187 | e.printStackTrace();
188 | } finally {
189 | try {
190 | retriever.release();
191 | } catch (RuntimeException ex) {
192 | // Ignore failures while cleaning up.
193 | }
194 | }
195 | return videoInfoBean;
196 | }
197 |
198 | /**
199 | * 压缩图片
200 | *
201 | * @param bitmap 被压缩的图片
202 | * @return 压缩后的图片
203 | */
204 | private static Bitmap compressBitmap(Bitmap bitmap) {
205 | int bitmapSize = getBitmapSize(bitmap);
206 | Log.e("======", "压缩前:bitmapSize:" + bitmapSize);
207 | Matrix matrix = new Matrix();
208 | matrix.setScale(0.5f, 0.5f);
209 | Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
210 | int bitmapSizeCompress = getBitmapSize(newBitmap);
211 | Log.e("======", "压缩后:bitmapSizeCompress:" + bitmapSizeCompress);
212 | return newBitmap;
213 | }
214 |
215 |
216 | /**
217 | * 得到bitmap的大小
218 | */
219 | private static int getBitmapSize(Bitmap bitmap) {
220 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //API 19
221 | return bitmap.getAllocationByteCount();
222 | }
223 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {//API 12
224 | return bitmap.getByteCount();
225 | }
226 | // 在低版本中用一行的字节x高度
227 | return bitmap.getRowBytes() * bitmap.getHeight();
228 | }
229 |
230 | //加密字符串
231 | private static String getMD5Code(String info) {
232 | try {
233 | MessageDigest md5 = MessageDigest.getInstance("MD5");
234 | md5.update(info.getBytes("utf-8"));
235 | byte[] encryption = md5.digest();
236 | StringBuffer stringBuffer = new StringBuffer();
237 | for (int i = 0; i < encryption.length; i++) {
238 | if (Integer.toHexString(0xff & encryption[i]).length() == 1) {
239 | stringBuffer.append("0").append(Integer.toHexString(0xff & encryption[i]));
240 | } else {
241 | stringBuffer.append(Integer.toHexString(0xff & encryption[i]));
242 | }
243 | }
244 | return stringBuffer.toString();
245 | } catch (Exception e) {
246 | return info;
247 | }
248 | }
249 |
250 | }
251 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/java/com/maning/mnvideoplayerlibrary/utils/PlayerUtils.java:
--------------------------------------------------------------------------------
1 | package com.maning.mnvideoplayerlibrary.utils;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.res.Resources;
6 | import android.graphics.Bitmap;
7 | import android.graphics.Point;
8 | import android.media.MediaMetadataRetriever;
9 | import android.media.ThumbnailUtils;
10 | import android.net.ConnectivityManager;
11 | import android.net.NetworkInfo;
12 | import android.os.Build;
13 | import android.provider.Settings;
14 | import androidx.annotation.NonNull;
15 |
16 | import android.view.View;
17 | import android.view.WindowManager;
18 |
19 | import java.lang.reflect.Method;
20 | import java.text.SimpleDateFormat;
21 | import java.util.Date;
22 | import java.util.HashMap;
23 |
24 | /**
25 | * Created by maning on 16/6/15.
26 | */
27 | public class PlayerUtils {
28 |
29 | public static final SimpleDateFormat HHmm = new SimpleDateFormat("HH:mm");
30 |
31 | /**
32 | * 转换毫秒数成“分、秒”,如“01:53”。若超过60分钟则显示“时、分、秒”,如“01:01:30
33 | *
34 | * @param
35 | */
36 | public static String converLongTimeToStr(long time) {
37 | int ss = 1000;
38 | int mi = ss * 60;
39 | int hh = mi * 60;
40 |
41 | long hour = (time) / hh;
42 | long minute = (time - hour * hh) / mi;
43 | long second = (time - hour * hh - minute * mi) / ss;
44 |
45 | String strHour = hour < 10 ? "0" + hour : "" + hour;
46 | String strMinute = minute < 10 ? "0" + minute : "" + minute;
47 | String strSecond = second < 10 ? "0" + second : "" + second;
48 | if (hour > 0) {
49 | return strHour + ":" + strMinute + ":" + strSecond;
50 | } else {
51 | return strMinute + ":" + strSecond;
52 | }
53 | }
54 |
55 | /**
56 | * 得到屏幕宽度
57 | *
58 | * @return 宽度
59 | */
60 | public static int getScreenWidth(Activity activity) {
61 | WindowManager wm = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
62 | Point point = new Point();
63 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
64 | //noinspection ConstantConditions
65 | wm.getDefaultDisplay().getRealSize(point);
66 | } else {
67 | //noinspection ConstantConditions
68 | wm.getDefaultDisplay().getSize(point);
69 | }
70 | return point.x;
71 | }
72 |
73 | /**
74 | * 得到屏幕高度
75 | *
76 | * @return 高度
77 | */
78 | public static int getScreenHeight(Activity activity) {
79 | WindowManager wm = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
80 | Point point = new Point();
81 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
82 | //noinspection ConstantConditions
83 | wm.getDefaultDisplay().getRealSize(point);
84 | } else {
85 | //noinspection ConstantConditions
86 | wm.getDefaultDisplay().getSize(point);
87 | }
88 | return point.y;
89 | }
90 |
91 | /**
92 | * 状态栏高度
93 | *
94 | * @param context
95 | * @return
96 | */
97 | public static int getStatusBarHeight(Context context) {
98 | int result = 0;
99 | int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
100 | if (resourceId > 0) {
101 | result = context.getResources().getDimensionPixelSize(resourceId);
102 | }
103 | return result;
104 | }
105 |
106 | /**
107 | * 根据手机的分辨率�?dp 的单�?转成�?px(像素)
108 | */
109 | public static int dip2px(Context context, float dpValue) {
110 | final float scale = context.getResources().getDisplayMetrics().density;
111 | return (int) (dpValue * scale + 0.5f);
112 | }
113 |
114 | /**
115 | * 根据手机的分辨率�?px(像素) 的单�?转成�?dp
116 | */
117 | public static int px2dip(Context context, float pxValue) {
118 | final float scale = context.getResources().getDisplayMetrics().density;
119 | return (int) (pxValue / scale + 0.5f);
120 | }
121 |
122 | /**
123 | * 获取当前时间
124 | */
125 | public static String getCurrentHHmmTime() {
126 | return HHmm.format(new Date());
127 | }
128 |
129 | private static ConnectivityManager mConnectivityManager = null;
130 |
131 | private static ConnectivityManager getConnectivityManager(Context context) {
132 | if (mConnectivityManager == null) {
133 | mConnectivityManager = (ConnectivityManager) context
134 | .getSystemService(Context.CONNECTIVITY_SERVICE);
135 | }
136 | return mConnectivityManager;
137 | }
138 |
139 | public static boolean isNetworkConnected(Context context) {
140 | if (context != null) {
141 | NetworkInfo mNetworkInfo = getConnectivityManager(context).getActiveNetworkInfo();
142 | if (mNetworkInfo != null) {
143 | return mNetworkInfo.isAvailable();
144 | }
145 | }
146 | return false;
147 | }
148 |
149 | public static boolean isWifiConnected(Context context) {
150 | if (context != null) {
151 | NetworkInfo mWiFiNetworkInfo = getConnectivityManager(context).getActiveNetworkInfo();
152 | if (mWiFiNetworkInfo != null) {
153 | return (mWiFiNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI);
154 | }
155 | }
156 | return false;
157 | }
158 |
159 | public static boolean isMobileConnected(Context context) {
160 | if (context != null) {
161 | NetworkInfo mNetworkInfo = getConnectivityManager(context).getActiveNetworkInfo();
162 | if (mNetworkInfo != null) {
163 | return (mNetworkInfo.getType() == ConnectivityManager.TYPE_MOBILE);
164 | }
165 | }
166 | return false;
167 | }
168 |
169 | /**
170 | * 获取视频略缩图
171 | *
172 | * @param url
173 | * @param width
174 | * @param height
175 | * @return
176 | */
177 | public static Bitmap createVideoThumbnail(String url, int width, int height) {
178 | Bitmap bitmap = null;
179 | MediaMetadataRetriever retriever = new MediaMetadataRetriever();
180 | try {
181 | if (Build.VERSION.SDK_INT >= 14) {
182 | retriever.setDataSource(url, new HashMap());
183 | } else {
184 | retriever.setDataSource(url);
185 | }
186 | bitmap = retriever.getFrameAtTime();
187 | if (bitmap != null) {
188 | bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,
189 | ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
190 | }
191 | } catch (Exception ex) {
192 | // Assume this is a corrupt video file.
193 | } finally {
194 | try {
195 | retriever.release();
196 | } catch (RuntimeException ex) {
197 | // Ignore failures while cleaning up.
198 | }
199 | }
200 | return bitmap;
201 | }
202 |
203 |
204 | /**
205 | * 判断虚拟导航栏是否显示
206 | *
207 | * @param context 上下文对象
208 | * @return true(显示虚拟导航栏),false(不显示或不支持虚拟导航栏)
209 | */
210 | public static boolean checkNavigationBarShow(@NonNull Context context) {
211 | boolean hasNavigationBar = false;
212 | Resources rs = context.getResources();
213 | int id = rs.getIdentifier("config_showNavigationBar", "bool", "android");
214 | if (id > 0) {
215 | hasNavigationBar = rs.getBoolean(id);
216 | }
217 | try {
218 | Class systemPropertiesClass = Class.forName("android.os.SystemProperties");
219 | Method m = systemPropertiesClass.getMethod("get", String.class);
220 | String navBarOverride = (String) m.invoke(systemPropertiesClass, "qemu.hw.mainkeys");
221 | //判断是否隐藏了底部虚拟导航
222 | int navigationBarIsMin = 0;
223 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
224 | navigationBarIsMin = Settings.System.getInt(context.getContentResolver(),
225 | "navigationbar_is_min", 0);
226 | } else {
227 | navigationBarIsMin = Settings.Global.getInt(context.getContentResolver(),
228 | "navigationbar_is_min", 0);
229 | }
230 | if ("1".equals(navBarOverride) || 1 == navigationBarIsMin) {
231 | hasNavigationBar = false;
232 | } else if ("0".equals(navBarOverride)) {
233 | hasNavigationBar = true;
234 | }
235 | } catch (Exception e) {
236 | }
237 | return hasNavigationBar;
238 | }
239 |
240 |
241 | /**
242 | * 隐藏虚拟按键,并且全屏
243 | */
244 | public static void hideBottomUIMenu(Activity activity) {
245 | if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
246 | View v = activity.getWindow().getDecorView();
247 | v.setSystemUiVisibility(View.GONE);
248 | } else if (Build.VERSION.SDK_INT >= 19) {
249 | //for new api versions.
250 | View decorView = activity.getWindow().getDecorView();
251 | int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
252 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
253 | decorView.setSystemUiVisibility(uiOptions);
254 | }
255 |
256 | }
257 |
258 | }
259 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/java/com/maning/mnvideoplayerlibrary/view/ProgressWheel.java:
--------------------------------------------------------------------------------
1 | package com.maning.mnvideoplayerlibrary.view;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.content.res.TypedArray;
6 | import android.graphics.Canvas;
7 | import android.graphics.Paint;
8 | import android.graphics.Paint.Style;
9 | import android.graphics.RectF;
10 | import android.os.Build;
11 | import android.os.Parcel;
12 | import android.os.Parcelable;
13 | import android.os.SystemClock;
14 | import android.provider.Settings;
15 | import android.util.AttributeSet;
16 | import android.util.DisplayMetrics;
17 | import android.util.TypedValue;
18 | import android.view.View;
19 |
20 | import com.maning.mnvideoplayerlibrary.R;
21 |
22 |
23 | /**
24 | * A Material style progress wheel, compatible up to 2.2.
25 | * Todd Davies' Progress Wheel https://github.com/Todd-Davies/ProgressWheel
26 | *
27 | * @author Nico Hormazábal
28 | *
29 | * Licensed under the Apache License 2.0 license see:
30 | * http://www.apache.org/licenses/LICENSE-2.0
31 | */
32 | public class ProgressWheel extends View {
33 | private static final String TAG = ProgressWheel.class.getSimpleName();
34 | private final int barLength = 16;
35 | private final int barMaxLength = 270;
36 | private final long pauseGrowingTime = 200;
37 | /**
38 | * *********
39 | * DEFAULTS *
40 | * **********
41 | */
42 | //Sizes (with defaults in DP)
43 | private int circleRadius = 28;
44 | private int barWidth = 4;
45 | private int rimWidth = 4;
46 | private boolean fillRadius = false;
47 | private double timeStartGrowing = 0;
48 | private double barSpinCycleTime = 460;
49 | private float barExtraLength = 0;
50 | private boolean barGrowingFromFront = true;
51 | private long pausedTimeWithoutGrowing = 0;
52 | //Colors (with defaults)
53 | private int barColor = 0xAA000000;
54 | private int rimColor = 0x00FFFFFF;
55 |
56 | //Paints
57 | private Paint barPaint = new Paint();
58 | private Paint rimPaint = new Paint();
59 |
60 | //Rectangles
61 | private RectF circleBounds = new RectF();
62 |
63 | //Animation
64 | //The amount of degrees per second
65 | private float spinSpeed = 230.0f;
66 | //private float spinSpeed = 120.0f;
67 | // The last time the spinner was animated
68 | private long lastTimeAnimated = 0;
69 |
70 | private boolean linearProgress;
71 |
72 | private float mProgress = 0.0f;
73 | private float mTargetProgress = 0.0f;
74 | private boolean isSpinning = false;
75 |
76 | private ProgressCallback callback;
77 |
78 | private boolean shouldAnimate;
79 |
80 | /**
81 | * The constructor for the ProgressWheel
82 | */
83 | public ProgressWheel(Context context, AttributeSet attrs) {
84 | super(context, attrs);
85 |
86 | parseAttributes(context.obtainStyledAttributes(attrs, R.styleable.ProgressWheel));
87 |
88 | setAnimationEnabled();
89 | }
90 |
91 | /**
92 | * The constructor for the ProgressWheel
93 | */
94 | public ProgressWheel(Context context) {
95 | super(context);
96 | setAnimationEnabled();
97 | }
98 |
99 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void setAnimationEnabled() {
100 | int currentApiVersion = Build.VERSION.SDK_INT;
101 |
102 | float animationValue;
103 | if (currentApiVersion >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
104 | animationValue = Settings.Global.getFloat(getContext().getContentResolver(),
105 | Settings.Global.ANIMATOR_DURATION_SCALE, 1);
106 | } else {
107 | animationValue = Settings.System.getFloat(getContext().getContentResolver(),
108 | Settings.System.ANIMATOR_DURATION_SCALE, 1);
109 | }
110 |
111 | shouldAnimate = animationValue != 0;
112 | }
113 |
114 | //----------------------------------
115 | //Setting up stuff
116 | //----------------------------------
117 |
118 | @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
119 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
120 |
121 | int viewWidth = circleRadius + this.getPaddingLeft() + this.getPaddingRight();
122 | int viewHeight = circleRadius + this.getPaddingTop() + this.getPaddingBottom();
123 |
124 | int widthMode = MeasureSpec.getMode(widthMeasureSpec);
125 | int widthSize = MeasureSpec.getSize(widthMeasureSpec);
126 | int heightMode = MeasureSpec.getMode(heightMeasureSpec);
127 | int heightSize = MeasureSpec.getSize(heightMeasureSpec);
128 |
129 | int width;
130 | int height;
131 |
132 | //Measure Width
133 | if (widthMode == MeasureSpec.EXACTLY) {
134 | //Must be this size
135 | width = widthSize;
136 | } else if (widthMode == MeasureSpec.AT_MOST) {
137 | //Can't be bigger than...
138 | width = Math.min(viewWidth, widthSize);
139 | } else {
140 | //Be whatever you want
141 | width = viewWidth;
142 | }
143 |
144 | //Measure Height
145 | if (heightMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.EXACTLY) {
146 | //Must be this size
147 | height = heightSize;
148 | } else if (heightMode == MeasureSpec.AT_MOST) {
149 | //Can't be bigger than...
150 | height = Math.min(viewHeight, heightSize);
151 | } else {
152 | //Be whatever you want
153 | height = viewHeight;
154 | }
155 |
156 | setMeasuredDimension(width, height);
157 | }
158 |
159 | /**
160 | * Use onSizeChanged instead of onAttachedToWindow to get the dimensions of the view,
161 | * because this method is called after measuring the dimensions of MATCH_PARENT & WRAP_CONTENT.
162 | * Use this dimensions to setup the bounds and paints.
163 | */
164 | @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) {
165 | super.onSizeChanged(w, h, oldw, oldh);
166 |
167 | setupBounds(w, h);
168 | setupPaints();
169 | invalidate();
170 | }
171 |
172 | /**
173 | * Set the properties of the paints we're using to
174 | * draw the progress wheel
175 | */
176 | private void setupPaints() {
177 | barPaint.setColor(barColor);
178 | barPaint.setAntiAlias(true);
179 | barPaint.setStyle(Style.STROKE);
180 | barPaint.setStrokeWidth(barWidth);
181 |
182 | rimPaint.setColor(rimColor);
183 | rimPaint.setAntiAlias(true);
184 | rimPaint.setStyle(Style.STROKE);
185 | rimPaint.setStrokeWidth(rimWidth);
186 | }
187 |
188 | /**
189 | * Set the bounds of the component
190 | */
191 | private void setupBounds(int layout_width, int layout_height) {
192 | int paddingTop = getPaddingTop();
193 | int paddingBottom = getPaddingBottom();
194 | int paddingLeft = getPaddingLeft();
195 | int paddingRight = getPaddingRight();
196 |
197 | if (!fillRadius) {
198 | // Width should equal to Height, find the min value to setup the circle
199 | int minValue = Math.min(layout_width - paddingLeft - paddingRight,
200 | layout_height - paddingBottom - paddingTop);
201 |
202 | int circleDiameter = Math.min(minValue, circleRadius * 2 - barWidth * 2);
203 |
204 | // Calc the Offset if needed for centering the wheel in the available space
205 | int xOffset = (layout_width - paddingLeft - paddingRight - circleDiameter) / 2 + paddingLeft;
206 | int yOffset = (layout_height - paddingTop - paddingBottom - circleDiameter) / 2 + paddingTop;
207 |
208 | circleBounds =
209 | new RectF(xOffset + barWidth, yOffset + barWidth, xOffset + circleDiameter - barWidth,
210 | yOffset + circleDiameter - barWidth);
211 | } else {
212 | circleBounds = new RectF(paddingLeft + barWidth, paddingTop + barWidth,
213 | layout_width - paddingRight - barWidth, layout_height - paddingBottom - barWidth);
214 | }
215 | }
216 |
217 | /**
218 | * Parse the attributes passed to the view from the XML
219 | *
220 | * @param a the attributes to parse
221 | */
222 | private void parseAttributes(TypedArray a) {
223 | // We transform the default values from DIP to pixels
224 | DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
225 | barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics);
226 | rimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics);
227 | circleRadius =
228 | (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, circleRadius, metrics);
229 |
230 | circleRadius =
231 | (int) a.getDimension(R.styleable.ProgressWheel_matProg_circleRadius, circleRadius);
232 |
233 | fillRadius = a.getBoolean(R.styleable.ProgressWheel_matProg_fillRadius, false);
234 |
235 | barWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_barWidth, barWidth);
236 |
237 | rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_rimWidth, rimWidth);
238 |
239 | float baseSpinSpeed =
240 | a.getFloat(R.styleable.ProgressWheel_matProg_spinSpeed, spinSpeed / 360.0f);
241 | spinSpeed = baseSpinSpeed * 360;
242 |
243 | barSpinCycleTime =
244 | a.getInt(R.styleable.ProgressWheel_matProg_barSpinCycleTime, (int) barSpinCycleTime);
245 |
246 | barColor = a.getColor(R.styleable.ProgressWheel_matProg_barColor, barColor);
247 |
248 | rimColor = a.getColor(R.styleable.ProgressWheel_matProg_rimColor, rimColor);
249 |
250 | linearProgress = a.getBoolean(R.styleable.ProgressWheel_matProg_linearProgress, false);
251 |
252 | if (a.getBoolean(R.styleable.ProgressWheel_matProg_progressIndeterminate, false)) {
253 | spin();
254 | }
255 |
256 | // Recycle
257 | a.recycle();
258 | }
259 |
260 | public void setCallback(ProgressCallback progressCallback) {
261 | callback = progressCallback;
262 |
263 | if (!isSpinning) {
264 | runCallback();
265 | }
266 | }
267 |
268 | //----------------------------------
269 | //Animation stuff
270 | //----------------------------------
271 |
272 | protected void onDraw(Canvas canvas) {
273 | super.onDraw(canvas);
274 |
275 | canvas.drawArc(circleBounds, 360, 360, false, rimPaint);
276 |
277 | boolean mustInvalidate = false;
278 |
279 | if (!shouldAnimate) {
280 | return;
281 | }
282 |
283 | if (isSpinning) {
284 | //Draw the spinning bar
285 | mustInvalidate = true;
286 |
287 | long deltaTime = (SystemClock.uptimeMillis() - lastTimeAnimated);
288 | float deltaNormalized = deltaTime * spinSpeed / 1000.0f;
289 |
290 | updateBarLength(deltaTime);
291 |
292 | mProgress += deltaNormalized;
293 | if (mProgress > 360) {
294 | mProgress -= 360f;
295 |
296 | // A full turn has been completed
297 | // we run the callback with -1 in case we want to
298 | // do something, like changing the color
299 | runCallback(-1.0f);
300 | }
301 | lastTimeAnimated = SystemClock.uptimeMillis();
302 |
303 | float from = mProgress - 90;
304 | float length = barLength + barExtraLength;
305 |
306 | if (isInEditMode()) {
307 | from = 0;
308 | length = 135;
309 | }
310 |
311 | canvas.drawArc(circleBounds, from, length, false, barPaint);
312 | } else {
313 | float oldProgress = mProgress;
314 |
315 | if (mProgress != mTargetProgress) {
316 | //We smoothly increase the progress bar
317 | mustInvalidate = true;
318 |
319 | float deltaTime = (float) (SystemClock.uptimeMillis() - lastTimeAnimated) / 1000;
320 | float deltaNormalized = deltaTime * spinSpeed;
321 |
322 | mProgress = Math.min(mProgress + deltaNormalized, mTargetProgress);
323 | lastTimeAnimated = SystemClock.uptimeMillis();
324 | }
325 |
326 | if (oldProgress != mProgress) {
327 | runCallback();
328 | }
329 |
330 | float offset = 0.0f;
331 | float progress = mProgress;
332 | if (!linearProgress) {
333 | float factor = 2.0f;
334 | offset = (float) (1.0f - Math.pow(1.0f - mProgress / 360.0f, 2.0f * factor)) * 360.0f;
335 | progress = (float) (1.0f - Math.pow(1.0f - mProgress / 360.0f, factor)) * 360.0f;
336 | }
337 |
338 | if (isInEditMode()) {
339 | progress = 360;
340 | }
341 |
342 | canvas.drawArc(circleBounds, offset - 90, progress, false, barPaint);
343 | }
344 |
345 | if (mustInvalidate) {
346 | invalidate();
347 | }
348 | }
349 |
350 | @Override protected void onVisibilityChanged(View changedView, int visibility) {
351 | super.onVisibilityChanged(changedView, visibility);
352 |
353 | if (visibility == VISIBLE) {
354 | lastTimeAnimated = SystemClock.uptimeMillis();
355 | }
356 | }
357 |
358 | private void updateBarLength(long deltaTimeInMilliSeconds) {
359 | if (pausedTimeWithoutGrowing >= pauseGrowingTime) {
360 | timeStartGrowing += deltaTimeInMilliSeconds;
361 |
362 | if (timeStartGrowing > barSpinCycleTime) {
363 | // We completed a size change cycle
364 | // (growing or shrinking)
365 | timeStartGrowing -= barSpinCycleTime;
366 | //if(barGrowingFromFront) {
367 | pausedTimeWithoutGrowing = 0;
368 | //}
369 | barGrowingFromFront = !barGrowingFromFront;
370 | }
371 |
372 | float distance =
373 | (float) Math.cos((timeStartGrowing / barSpinCycleTime + 1) * Math.PI) / 2 + 0.5f;
374 | float destLength = (barMaxLength - barLength);
375 |
376 | if (barGrowingFromFront) {
377 | barExtraLength = distance * destLength;
378 | } else {
379 | float newLength = destLength * (1 - distance);
380 | mProgress += (barExtraLength - newLength);
381 | barExtraLength = newLength;
382 | }
383 | } else {
384 | pausedTimeWithoutGrowing += deltaTimeInMilliSeconds;
385 | }
386 | }
387 |
388 | /**
389 | * Check if the wheel is currently spinning
390 | */
391 |
392 | public boolean isSpinning() {
393 | return isSpinning;
394 | }
395 |
396 | /**
397 | * Reset the count (in increment mode)
398 | */
399 | public void resetCount() {
400 | mProgress = 0.0f;
401 | mTargetProgress = 0.0f;
402 | invalidate();
403 | }
404 |
405 | /**
406 | * Turn off spin mode
407 | */
408 | public void stopSpinning() {
409 | isSpinning = false;
410 | mProgress = 0.0f;
411 | mTargetProgress = 0.0f;
412 | invalidate();
413 | }
414 |
415 | /**
416 | * Puts the view on spin mode
417 | */
418 | public void spin() {
419 | lastTimeAnimated = SystemClock.uptimeMillis();
420 | isSpinning = true;
421 | invalidate();
422 | }
423 |
424 | private void runCallback(float value) {
425 | if (callback != null) {
426 | callback.onProgressUpdate(value);
427 | }
428 | }
429 |
430 | private void runCallback() {
431 | if (callback != null) {
432 | float normalizedProgress = (float) Math.round(mProgress * 100 / 360.0f) / 100;
433 | callback.onProgressUpdate(normalizedProgress);
434 | }
435 | }
436 |
437 | /**
438 | * Set the progress to a specific value,
439 | * the bar will be set instantly to that value
440 | *
441 | * @param progress the progress between 0 and 1
442 | */
443 | public void setInstantProgress(float progress) {
444 | if (isSpinning) {
445 | mProgress = 0.0f;
446 | isSpinning = false;
447 | }
448 |
449 | if (progress > 1.0f) {
450 | progress -= 1.0f;
451 | } else if (progress < 0) {
452 | progress = 0;
453 | }
454 |
455 | if (progress == mTargetProgress) {
456 | return;
457 | }
458 |
459 | mTargetProgress = Math.min(progress * 360.0f, 360.0f);
460 | mProgress = mTargetProgress;
461 | lastTimeAnimated = SystemClock.uptimeMillis();
462 | invalidate();
463 | }
464 |
465 | // Great way to save a view's state http://stackoverflow.com/a/7089687/1991053
466 | @Override public Parcelable onSaveInstanceState() {
467 | Parcelable superState = super.onSaveInstanceState();
468 |
469 | WheelSavedState ss = new WheelSavedState(superState);
470 |
471 | // We save everything that can be changed at runtime
472 | ss.mProgress = this.mProgress;
473 | ss.mTargetProgress = this.mTargetProgress;
474 | ss.isSpinning = this.isSpinning;
475 | ss.spinSpeed = this.spinSpeed;
476 | ss.barWidth = this.barWidth;
477 | ss.barColor = this.barColor;
478 | ss.rimWidth = this.rimWidth;
479 | ss.rimColor = this.rimColor;
480 | ss.circleRadius = this.circleRadius;
481 | ss.linearProgress = this.linearProgress;
482 | ss.fillRadius = this.fillRadius;
483 |
484 | return ss;
485 | }
486 |
487 | @Override public void onRestoreInstanceState(Parcelable state) {
488 | if (!(state instanceof WheelSavedState)) {
489 | super.onRestoreInstanceState(state);
490 | return;
491 | }
492 |
493 | WheelSavedState ss = (WheelSavedState) state;
494 | super.onRestoreInstanceState(ss.getSuperState());
495 |
496 | this.mProgress = ss.mProgress;
497 | this.mTargetProgress = ss.mTargetProgress;
498 | this.isSpinning = ss.isSpinning;
499 | this.spinSpeed = ss.spinSpeed;
500 | this.barWidth = ss.barWidth;
501 | this.barColor = ss.barColor;
502 | this.rimWidth = ss.rimWidth;
503 | this.rimColor = ss.rimColor;
504 | this.circleRadius = ss.circleRadius;
505 | this.linearProgress = ss.linearProgress;
506 | this.fillRadius = ss.fillRadius;
507 |
508 | this.lastTimeAnimated = SystemClock.uptimeMillis();
509 | }
510 |
511 | /**
512 | * @return the current progress between 0.0 and 1.0,
513 | * if the wheel is indeterminate, then the result is -1
514 | */
515 | public float getProgress() {
516 | return isSpinning ? -1 : mProgress / 360.0f;
517 | }
518 |
519 | //----------------------------------
520 | //Getters + setters
521 | //----------------------------------
522 |
523 | /**
524 | * Set the progress to a specific value,
525 | * the bar will smoothly animate until that value
526 | *
527 | * @param progress the progress between 0 and 1
528 | */
529 | public void setProgress(float progress) {
530 | if (isSpinning) {
531 | mProgress = 0.0f;
532 | isSpinning = false;
533 |
534 | runCallback();
535 | }
536 |
537 | if (progress > 1.0f) {
538 | progress -= 1.0f;
539 | } else if (progress < 0) {
540 | progress = 0;
541 | }
542 |
543 | if (progress == mTargetProgress) {
544 | return;
545 | }
546 |
547 | // If we are currently in the right position
548 | // we set again the last time animated so the
549 | // animation starts smooth from here
550 | if (mProgress == mTargetProgress) {
551 | lastTimeAnimated = SystemClock.uptimeMillis();
552 | }
553 |
554 | mTargetProgress = Math.min(progress * 360.0f, 360.0f);
555 |
556 | invalidate();
557 | }
558 |
559 | /**
560 | * Sets the determinate progress mode
561 | *
562 | * @param isLinear if the progress should increase linearly
563 | */
564 | public void setLinearProgress(boolean isLinear) {
565 | linearProgress = isLinear;
566 | if (!isSpinning) {
567 | invalidate();
568 | }
569 | }
570 |
571 | /**
572 | * @return the radius of the wheel in pixels
573 | */
574 | public int getCircleRadius() {
575 | return circleRadius;
576 | }
577 |
578 | /**
579 | * Sets the radius of the wheel
580 | *
581 | * @param circleRadius the expected radius, in pixels
582 | */
583 | public void setCircleRadius(int circleRadius) {
584 | this.circleRadius = circleRadius;
585 | if (!isSpinning) {
586 | invalidate();
587 | }
588 | }
589 |
590 | /**
591 | * @return the width of the spinning bar
592 | */
593 | public int getBarWidth() {
594 | return barWidth;
595 | }
596 |
597 | /**
598 | * Sets the width of the spinning bar
599 | *
600 | * @param barWidth the spinning bar width in pixels
601 | */
602 | public void setBarWidth(int barWidth) {
603 | this.barWidth = barWidth;
604 | if (!isSpinning) {
605 | invalidate();
606 | }
607 | }
608 |
609 | /**
610 | * @return the color of the spinning bar
611 | */
612 | public int getBarColor() {
613 | return barColor;
614 | }
615 |
616 | /**
617 | * Sets the color of the spinning bar
618 | *
619 | * @param barColor The spinning bar color
620 | */
621 | public void setBarColor(int barColor) {
622 | this.barColor = barColor;
623 | setupPaints();
624 | if (!isSpinning) {
625 | invalidate();
626 | }
627 | }
628 |
629 | /**
630 | * @return the color of the wheel's contour
631 | */
632 | public int getRimColor() {
633 | return rimColor;
634 | }
635 |
636 | /**
637 | * Sets the color of the wheel's contour
638 | *
639 | * @param rimColor the color for the wheel
640 | */
641 | public void setRimColor(int rimColor) {
642 | this.rimColor = rimColor;
643 | setupPaints();
644 | if (!isSpinning) {
645 | invalidate();
646 | }
647 | }
648 |
649 | /**
650 | * @return the base spinning speed, in full circle turns per second
651 | * (1.0 equals on full turn in one second), this value also is applied for
652 | * the smoothness when setting a progress
653 | */
654 | public float getSpinSpeed() {
655 | return spinSpeed / 360.0f;
656 | }
657 |
658 | /**
659 | * Sets the base spinning speed, in full circle turns per second
660 | * (1.0 equals on full turn in one second), this value also is applied for
661 | * the smoothness when setting a progress
662 | *
663 | * @param spinSpeed the desired base speed in full turns per second
664 | */
665 | public void setSpinSpeed(float spinSpeed) {
666 | this.spinSpeed = spinSpeed * 360.0f;
667 | }
668 |
669 | /**
670 | * @return the width of the wheel's contour in pixels
671 | */
672 | public int getRimWidth() {
673 | return rimWidth;
674 | }
675 |
676 | /**
677 | * Sets the width of the wheel's contour
678 | *
679 | * @param rimWidth the width in pixels
680 | */
681 | public void setRimWidth(int rimWidth) {
682 | this.rimWidth = rimWidth;
683 | if (!isSpinning) {
684 | invalidate();
685 | }
686 | }
687 |
688 | public interface ProgressCallback {
689 | /**
690 | * Method to call when the progress reaches a value
691 | * in order to avoid float precision issues, the progress
692 | * is rounded to a float with two decimals.
693 | *
694 | * In indeterminate mode, the callback is called each time
695 | * the wheel completes an animation cycle, with, the progress value is -1.0f
696 | *
697 | * @param progress a double value between 0.00 and 1.00 both included
698 | */
699 | public void onProgressUpdate(float progress);
700 | }
701 |
702 | static class WheelSavedState extends BaseSavedState {
703 | //required field that makes Parcelables from a Parcel
704 | public static final Creator CREATOR =
705 | new Creator() {
706 | public WheelSavedState createFromParcel(Parcel in) {
707 | return new WheelSavedState(in);
708 | }
709 |
710 | public WheelSavedState[] newArray(int size) {
711 | return new WheelSavedState[size];
712 | }
713 | };
714 | float mProgress;
715 | float mTargetProgress;
716 | boolean isSpinning;
717 | float spinSpeed;
718 | int barWidth;
719 | int barColor;
720 | int rimWidth;
721 | int rimColor;
722 | int circleRadius;
723 | boolean linearProgress;
724 | boolean fillRadius;
725 |
726 | WheelSavedState(Parcelable superState) {
727 | super(superState);
728 | }
729 |
730 | private WheelSavedState(Parcel in) {
731 | super(in);
732 | this.mProgress = in.readFloat();
733 | this.mTargetProgress = in.readFloat();
734 | this.isSpinning = in.readByte() != 0;
735 | this.spinSpeed = in.readFloat();
736 | this.barWidth = in.readInt();
737 | this.barColor = in.readInt();
738 | this.rimWidth = in.readInt();
739 | this.rimColor = in.readInt();
740 | this.circleRadius = in.readInt();
741 | this.linearProgress = in.readByte() != 0;
742 | this.fillRadius = in.readByte() != 0;
743 | }
744 |
745 | @Override public void writeToParcel(Parcel out, int flags) {
746 | super.writeToParcel(out, flags);
747 | out.writeFloat(this.mProgress);
748 | out.writeFloat(this.mTargetProgress);
749 | out.writeByte((byte) (isSpinning ? 1 : 0));
750 | out.writeFloat(this.spinSpeed);
751 | out.writeInt(this.barWidth);
752 | out.writeInt(this.barColor);
753 | out.writeInt(this.rimWidth);
754 | out.writeInt(this.rimColor);
755 | out.writeInt(this.circleRadius);
756 | out.writeByte((byte) (linearProgress ? 1 : 0));
757 | out.writeByte((byte) (fillRadius ? 1 : 0));
758 | }
759 | }
760 | }
761 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_back.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_backward.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_backward.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_battery_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_battery_01.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_battery_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_battery_02.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_battery_03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_battery_03.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_battery_04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_battery_04.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_battery_05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_battery_05.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_center_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_center_play.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_error.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_forward.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_forward.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_ic_fullscreen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_ic_fullscreen.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_ic_fullscreen_exit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_ic_fullscreen_exit.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_landscape_screen_lock_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_landscape_screen_lock_close.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_landscape_screen_lock_open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_landscape_screen_lock_open.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_light.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_pause.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_play.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_play_center.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_play_center.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_progress_no_net.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_progress_no_net.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_volume_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_volume_close.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_volume_open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/mnvideoplayerlibrary/src/main/res/drawable-xhdpi/mn_player_volume_open.png
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable/mn_palyer_bar_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable/mn_palyer_bar_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable/mn_palyer_black_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable/mn_palyer_black_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
12 |
13 |
16 |
17 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable/mn_player_progress_diy.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
16 | -
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable/mn_player_progressbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
12 |
13 |
14 |
15 | -
16 |
17 |
18 |
19 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/drawable/mn_player_thumb.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
12 |
13 |
18 |
19 |
23 |
24 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/layout/mn_gesture_light_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
23 |
24 |
34 |
35 |
47 |
48 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/layout/mn_gesture_progress_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
22 |
23 |
33 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/layout/mn_gesture_volume_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
23 |
24 |
36 |
37 |
49 |
50 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/layout/mn_player_progress_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
21 |
28 |
29 |
30 |
37 |
38 |
43 |
44 |
53 |
54 |
55 |
56 |
64 |
65 |
69 |
70 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/layout/mn_player_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
18 |
19 |
26 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
47 |
48 |
56 |
57 |
64 |
65 |
73 |
74 |
91 |
92 |
93 |
94 |
102 |
103 |
109 |
110 |
121 |
122 |
132 |
133 |
146 |
147 |
148 |
149 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #A4000000
5 | #FFFFFF
6 |
7 | #e1767676
8 | #c1c1c1
9 | #FFFFFF
10 |
11 | #00000000
12 |
13 |
--------------------------------------------------------------------------------
/mnvideoplayerlibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MNVideoPlayerLibrary
3 |
4 |
5 | 当前网络不可用,检查网络设置
6 | 播放地址为空
7 | 视频播放失败
8 | 请注意,当前网络状态切换为3G/4G网络
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/screenshots/videoplay_001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/screenshots/videoplay_001.png
--------------------------------------------------------------------------------
/screenshots/videoplay_002.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/screenshots/videoplay_002.png
--------------------------------------------------------------------------------
/screenshots/videoplay_003.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/screenshots/videoplay_003.png
--------------------------------------------------------------------------------
/screenshots/videoplay_004.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maning0303/MNVideoPlayer/6563326e93816f0f291be83b64133c58931ec17c/screenshots/videoplay_004.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':mnvideoplayerlibrary'
2 |
--------------------------------------------------------------------------------