├── .gitignore
├── LICENSE
├── README.md
├── Tvscreenshot.png
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── app
│ │ └── mxvideoplayer
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── concat.ffconcat
│ ├── java
│ │ └── com
│ │ │ └── app
│ │ │ └── mxvideoplayer
│ │ │ ├── ListActivity.java
│ │ │ ├── ListAutoInsertActivity.java
│ │ │ ├── MobileActivity.java
│ │ │ ├── TvActivity.java
│ │ │ ├── VideoListAdapter.java
│ │ │ └── util
│ │ │ └── playUtils.java
│ └── res
│ │ ├── layout
│ │ ├── activity_auto_tiny.xml
│ │ ├── activity_list.xml
│ │ ├── activity_mobile.xml
│ │ ├── activity_mobile_section.xml
│ │ ├── activity_tv.xml
│ │ ├── head_normal_list.xml
│ │ └── layout_item_list.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
│ └── test
│ └── java
│ └── com
│ └── app
│ └── mxvideoplayer
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshot1.jpg
├── screenshot2.jpg
├── screenshot3.jpg
├── screenshot4.jpg
├── settings.gradle
└── xvideoplayer
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── mxvideoplayer
│ └── app
│ └── com
│ └── xvideoplayer
│ └── ApplicationTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── hb
│ │ └── xvideoplayer
│ │ ├── MxDragLayout.java
│ │ ├── MxImageView.java
│ │ ├── MxMediaManager.java
│ │ ├── MxMediaPlayerListener.java
│ │ ├── MxTextureView.java
│ │ ├── MxTvPlayerWidget.java
│ │ ├── MxUserAction.java
│ │ ├── MxUtils.java
│ │ ├── MxVideoPlayer.java
│ │ ├── MxVideoPlayerManager.java
│ │ └── MxVideoPlayerWidget.java
└── res
│ ├── drawable-xhdpi
│ ├── mx_back.png
│ ├── mx_backward_icon.png
│ ├── mx_brightness_icon.png
│ ├── mx_enlarge.png
│ ├── mx_error_normal.png
│ ├── mx_error_pressed.png
│ ├── mx_forward_icon.png
│ ├── mx_loading_bg.png
│ ├── mx_pause_normal.png
│ ├── mx_pause_pressed.png
│ ├── mx_play_normal.png
│ ├── mx_play_pressed.png
│ ├── mx_quit_tiny_normal.png
│ ├── mx_quit_tiny_pressed.png
│ ├── mx_shrink.png
│ ├── mx_volume_icon.png
│ └── mx_volume_no.png
│ ├── drawable
│ ├── mx_bottom_bg.xml
│ ├── mx_bottom_progress.xml
│ ├── mx_click_error_selector.xml
│ ├── mx_click_pause_selector.xml
│ ├── mx_click_play_selector.xml
│ ├── mx_click_quit_tiny_selector.xml
│ ├── mx_dialog_progress.xml
│ ├── mx_dialog_progress_bg.xml
│ ├── mx_loading.xml
│ ├── mx_seek_progress.xml
│ ├── mx_seek_thumb.xml
│ ├── mx_seek_thumb_normal.xml
│ ├── mx_seek_thumb_pressed.xml
│ ├── mx_title_bg.xml
│ └── mx_volume_progress_bg.xml
│ ├── layout
│ ├── mx_mobile_brightness_dialog.xml
│ ├── mx_mobile_volume_dialog.xml
│ ├── mx_progress_dialog.xml
│ ├── mx_tv_progress_dialog.xml
│ ├── mx_tv_volume_dialog.xml
│ ├── mx_video_layout_mobile.xml
│ └── mx_video_layout_tv.xml
│ ├── values-zh
│ └── strings.xml
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── ids.xml
│ ├── strings.xml
│ └── styles.xml
└── test
└── java
└── mxvideoplayer
└── app
└── com
└── xvideoplayer
└── ExampleUnitTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 |
39 | # Keystore files
40 | *.jks
41 |
--------------------------------------------------------------------------------
/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 | # MxVideoPlayer
2 | A simple video player support mobile and TV. Video playback base on [ijkplayer](https://github.com/Bilibili/ijkplayer). The player supports more video formats by default.
3 |
4 | ## ScreenShot
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | ## Usage
20 | First you can add gradle dependency with command :
21 | ```
22 | defaultConfig {
23 | ......
24 | minSdkVersion 16 // at least 16
25 | ......
26 | }
27 | dependencies {
28 | ......
29 | compile 'com.henryblue.mxvideoplayer:xvideoplayer:1.2.1'
30 | }
31 |
32 | ```
33 | To add gradle dependency you need to open build.gradle (in your app folder,not in a project folder) then copy and add the dependencies there in the dependencies block.
34 |
35 | MxVideoPlayer default only support 'armeabi-v7a' CPU style.
36 | If you want to support more CPU types, you can choose version 1.1.6, which supports 'armeabi', 'armeabi-v7a', 'arm64-v8a' 'x86' and 'x86_64', but it will make your project Larger, you can configure the type of CPU you need in your project. The configuration is as follows:
37 | ```
38 | android {
39 | ........
40 |
41 | defaultConfig {
42 | ........
43 |
44 | ndk {
45 | // config you want to support device
46 | abiFilters 'arm64-v8a', 'armeabi', 'armeabi-v7a', 'x86'
47 | }
48 | }
49 | }
50 | ```
51 |
52 | ## Use in mobile
53 | 1. Add to layout
54 | ```
55 |
59 | ```
60 | 2. set play url and start video
61 | ```
62 | @Override
63 | protected void onCreate(Bundle savedInstanceState) {
64 | .......
65 | MxVideoPlayerWidget videoPlayerWidget = (MxVideoPlayerWidget) findViewById(R.id.mpw_video_player);
66 | videoPlayerWidget.startPlay("play url", MxVideoPlayer.SCREEN_LAYOUT_NORMAL, "video name");
67 | .......
68 | }
69 |
70 | @Override
71 | protected void onPause() {
72 | super.onPause();
73 | MxVideoPlayer.releaseAllVideos();
74 | }
75 |
76 | @Override
77 | public void onBackPressed() {
78 | if (MxVideoPlayer.backPress()) {
79 | return;
80 | }
81 | super.onBackPressed();
82 | }
83 | ```
84 | if you want auto fullscreen, you can do that:
85 | ```
86 | MxVideoPlayerWidget.startFullscreen(this, MxVideoPlayerWidget.class, "video url", "video name");
87 | ```
88 |
89 | ## Usage in TV
90 | 1. Add to layout
91 | ```
92 |
96 | ```
97 | 2. set play url and start video
98 | ```
99 | @Override
100 | protected void onCreate(Bundle savedInstanceState) {
101 | ........
102 | mVideoPlayerWidget = (MxTvPlayerWidget) findViewById(R.id.mpw_video_player);
103 | mVideoPlayerWidget.startPlay("video url", "video name");
104 | ........
105 | }
106 |
107 |
108 | @Override
109 | public boolean onKeyDown(int keyCode, KeyEvent event) {
110 | return mVideoPlayerWidget.requestKeyDown(keyCode, event);
111 | }
112 |
113 | @Override
114 | public boolean onKeyUp(int keyCode, KeyEvent event) {
115 | return mVideoPlayerWidget.requestKeyUp(keyCode, event);
116 | }
117 |
118 | @Override
119 | protected void onPause() {
120 | super.onPause();
121 | MxVideoPlayer.releaseAllVideos();
122 | }
123 | ```
124 | MxTvPlayerWidget handle Key event including KEYCODE_VOLUME_DOWN, KEYCODE_VOLUME_UP, KEYCODE_DPAD_UP, KEYCODE_DPAD_DOWN, KEYCODE_DPAD_RIGHT, KEYCODE_DPAD_LEFT, KEYCODE_BACK and KEYCODE_ENTER.
125 |
--------------------------------------------------------------------------------
/Tvscreenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/Tvscreenshot.png
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion '29.0.2'
6 |
7 | defaultConfig {
8 | applicationId "com.app.mxvideoplayer"
9 | minSdkVersion 16
10 | targetSdkVersion 24
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation fileTree(dir: 'libs', include: ['*.jar'])
24 | testImplementation 'junit:junit:4.12'
25 | implementation project(':xvideoplayer')
26 | implementation 'com.android.support:appcompat-v7:24.2.1'
27 | implementation 'com.github.bumptech.glide:glide:3.7.0'
28 | }
29 |
--------------------------------------------------------------------------------
/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 D:\android-studio-sdk-windows/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/androidTest/java/com/app/mxvideoplayer/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.app.mxvideoplayer;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
23 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/assets/concat.ffconcat:
--------------------------------------------------------------------------------
1 | ffconcat version 1.0
2 | file 'http://k.youku.com/player/getFlvPath/sid/04894778187142012049c_00/st/flv/fileid/030002040050E73EC81C38080D51C61F6AB399-532A-C3BC-0EBA-2ACC1D6C2EEF?k=c08050053e4995822412f08f&hd=0&myp=0&ts=394&ymovie=1&sign=7772e08869a718ecaddf5930e5b5170a&sid=04894778187142012049c&token=6568&oip=3059212228&ctype=20&did=d9a48de7e5fafe351d6710560c4717d3&ev=1&ep=HHnB8bYszFnnKErA8HJYjN4lhTA8NuwMqNo3M7almO%2Bgq%2FXB8kpLMmeIOtMekp5XpwfGqrbAvzNbyTm%2FIKih8tn3%2FMNUOjbd%2Fb2ktTGSX1P0JYc%2BV1KRFulfDgAIe4UK'
3 | duration 394
4 | file 'http://k.youku.com/player/getFlvPath/sid/04894778187142012049c_01/st/flv/fileid/030002040150E73EC81C38080D51C61F6AB399-532A-C3BC-0EBA-2ACC1D6C2EEF?k=0493857965365067282c314e&hd=0&myp=0&ts=396&ymovie=1&sign=fd15b8acdf234b000cfd730edb627a75&sid=04894778187142012049c&token=6568&oip=3059212228&ctype=20&did=d9a48de7e5fafe351d6710560c4717d3&ev=1&ep=HHnB8bYszFnnKErA8HJYjCUM7yOXatgB3tx6ir2%2F6ESgq%2FXB8kpLMmeIOtMekp5XpwfGqrbAvzNbyTm%2FIKih8tn3%2FMNUOjbd%2Fb2ktTGSX1P0JYc%2BV1KRFulfDgAIe4UK'
5 | duration 396
6 | file 'http://k.youku.com/player/getFlvPath/sid/04894778187142012049c_02/st/flv/fileid/030002040250E73EC81C38080D51C61F6AB399-532A-C3BC-0EBA-2ACC1D6C2EEF?k=dc5a6801751107e32412f08f&hd=0&myp=0&ts=277&ymovie=1&sign=00162fe1a1b73b17bb5d1d3575e89d40&sid=04894778187142012049c&token=6568&oip=3059212228&ctype=20&did=d9a48de7e5fafe351d6710560c4717d3&ev=1&ep=HHnB8bYszFnnKErA8HJYjMA0ehMEMGKAtqaXKB2D8iKgq%2FXB8kpLMmeIOtMekp5XpwfGqrbAvzNbyTm%2FIKih8tn3%2FMNUOjbd%2Fb2ktTGSX1P0JYc%2BV1KRFulfDgAIe4UK'
7 | duration 277
8 | file 'http://k.youku.com/player/getFlvPath/sid/04894778187142012049c_03/st/flv/fileid/030002040350E73EC81C38080D51C61F6AB399-532A-C3BC-0EBA-2ACC1D6C2EEF?k=e666fdb2361c24962412f08f&hd=0&myp=0&ts=301&ymovie=1&sign=d6e3dfd00e5aca7e100129dbd2e974a6&sid=04894778187142012049c&token=6568&oip=3059212228&ctype=20&did=d9a48de7e5fafe351d6710560c4717d3&ev=1&ep=HHnB8bYszFnnKErA8HJYjC4pQJHm8oBwUDQmMZiBwPmgq%2FXB8kpLMmeIOtMekp5XpwfGqrbAvzNbyTm%2FIKih8tn3%2FMNUOjbd%2Fb2ktTGSX1P0JYc%2BV1KRFulfDgAIe4UK'
9 | duration 301
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/app/mxvideoplayer/ListActivity.java:
--------------------------------------------------------------------------------
1 | package com.app.mxvideoplayer;
2 |
3 | import android.hardware.Sensor;
4 | import android.hardware.SensorManager;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.widget.ListView;
8 |
9 | import hb.xvideoplayer.MxVideoPlayer;
10 |
11 | public class ListActivity extends AppCompatActivity {
12 |
13 | private SensorManager mSensorManager;
14 | private MxVideoPlayer.MxAutoFullscreenListener mSensorEventListener;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_list);
20 | ListView mListView = (ListView) findViewById(R.id.test_list_view);
21 | mListView.setAdapter(new VideoListAdapter(ListActivity.this));
22 | mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
23 | mSensorEventListener = new MxVideoPlayer.MxAutoFullscreenListener();
24 | }
25 |
26 | @Override
27 | public void onBackPressed() {
28 | if (MxVideoPlayer.backPress()) {
29 | return;
30 | }
31 | super.onBackPressed();
32 | }
33 |
34 | @Override
35 | protected void onResume() {
36 | super.onResume();
37 | Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
38 | mSensorManager.registerListener(mSensorEventListener, sensor, SensorManager.SENSOR_DELAY_NORMAL);
39 | }
40 |
41 | @Override
42 | protected void onPause() {
43 | super.onPause();
44 | mSensorManager.unregisterListener(mSensorEventListener);
45 | MxVideoPlayer.releaseAllVideos();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/app/mxvideoplayer/ListAutoInsertActivity.java:
--------------------------------------------------------------------------------
1 | package com.app.mxvideoplayer;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.widget.ArrayAdapter;
7 | import android.widget.ListView;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | import hb.xvideoplayer.MxVideoPlayer;
13 | import hb.xvideoplayer.MxVideoPlayerWidget;
14 |
15 | public class ListAutoInsertActivity extends AppCompatActivity {
16 |
17 | private List dataList = new ArrayList<>();
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_list);
23 | ListView mListView = (ListView) findViewById(R.id.test_list_view);
24 | for (int i = 1; i <= 40; ++i) {
25 | dataList.add("item" + i);
26 | }
27 | View view = View.inflate(ListAutoInsertActivity.this, R.layout.head_normal_list, null);
28 | mListView.addHeaderView(view);
29 | final MxVideoPlayerWidget playerWidget = (MxVideoPlayerWidget) view.findViewById(R.id.mx_video_player);
30 | playerWidget.startPlay("http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/b0d244d75285890811387532689/v.f30.mp4",
31 | MxVideoPlayer.SCREEN_LAYOUT_NORMAL, "明天你是否依然爱我");
32 | playerWidget.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
33 | @Override
34 | public void onViewAttachedToWindow(View v) {
35 | if (playerWidget.getState() == MxVideoPlayer.CURRENT_STATE_PLAYING) {
36 | playerWidget.quitWindowTiny();
37 | }
38 | }
39 |
40 | @Override
41 | public void onViewDetachedFromWindow(View v) {
42 | if (playerWidget.getState() == MxVideoPlayer.CURRENT_STATE_PLAYING) {
43 | playerWidget.startWindowTiny();
44 | }
45 | }
46 | });
47 |
48 | mListView.setAdapter(new ArrayAdapter<>(ListAutoInsertActivity.this,
49 | android.R.layout.simple_list_item_1, dataList));
50 | }
51 |
52 | @Override
53 | public void onBackPressed() {
54 | if (MxVideoPlayer.backPress()) {
55 | return;
56 | }
57 | super.onBackPressed();
58 | }
59 |
60 | @Override
61 | protected void onPause() {
62 | super.onPause();
63 | MxVideoPlayer.releaseAllVideos();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/java/com/app/mxvideoplayer/MobileActivity.java:
--------------------------------------------------------------------------------
1 | package com.app.mxvideoplayer;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | import hb.xvideoplayer.MxVideoPlayer;
10 | import hb.xvideoplayer.MxVideoPlayerWidget;
11 |
12 |
13 | public class MobileActivity extends AppCompatActivity {
14 |
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_mobile);
20 |
21 | MxVideoPlayerWidget videoPlayerWidget = (MxVideoPlayerWidget) findViewById(R.id.mpw_video_player);
22 | videoPlayerWidget.autoStartPlay(
23 | "http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/7cfe01a45285890811342490244/v.f30.mp4",
24 | MxVideoPlayer.SCREEN_LAYOUT_NORMAL,
25 | "汽车"
26 | );
27 |
28 |
29 | Button buttonList = (Button) findViewById(R.id.button_list);
30 | buttonList.setOnClickListener(new View.OnClickListener() {
31 | @Override
32 | public void onClick(View v) {
33 | Intent intent = new Intent(MobileActivity.this, ListActivity.class);
34 | startActivity(intent);
35 | }
36 | });
37 |
38 | Button buttonAutoList = (Button) findViewById(R.id.button_auto_list);
39 | buttonAutoList.setOnClickListener(new View.OnClickListener() {
40 | @Override
41 | public void onClick(View v) {
42 | Intent intent = new Intent(MobileActivity.this, ListAutoInsertActivity.class);
43 | startActivity(intent);
44 | }
45 | });
46 |
47 | Button btnFullscreen = (Button) findViewById(R.id.button_auto_fullscreen);
48 | btnFullscreen.setOnClickListener(new View.OnClickListener() {
49 | @Override
50 | public void onClick(View v) {
51 | MxVideoPlayerWidget.startFullscreen(MobileActivity.this, MxVideoPlayerWidget.class,
52 | "http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/7cfe01a45285890811342490244/v.f30.mp4"
53 | , "汽车");
54 | }
55 | });
56 | }
57 |
58 | @Override
59 | protected void onResume() {
60 | super.onResume();
61 | }
62 |
63 | @Override
64 | protected void onPause() {
65 | super.onPause();
66 | MxVideoPlayer.releaseAllVideos();
67 | }
68 |
69 | @Override
70 | public void onBackPressed() {
71 | if (MxVideoPlayer.backPress()) {
72 | return;
73 | }
74 | super.onBackPressed();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/app/src/main/java/com/app/mxvideoplayer/TvActivity.java:
--------------------------------------------------------------------------------
1 | package com.app.mxvideoplayer;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.ActionBar;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.KeyEvent;
7 | import android.view.View;
8 |
9 | import hb.xvideoplayer.MxTvPlayerWidget;
10 | import hb.xvideoplayer.MxVideoPlayer;
11 |
12 |
13 | public class TvActivity extends AppCompatActivity {
14 |
15 | private MxTvPlayerWidget mVideoPlayerWidget;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_tv);
21 | View decorView = getWindow().getDecorView();
22 | int option = View.SYSTEM_UI_FLAG_FULLSCREEN;
23 | decorView.setSystemUiVisibility(option);
24 | ActionBar actionBar = getSupportActionBar();
25 | if (actionBar != null) {
26 | actionBar.hide();
27 | }
28 |
29 | mVideoPlayerWidget = (MxTvPlayerWidget) findViewById(R.id.mpw_video_player);
30 | mVideoPlayerWidget.startPlay("http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/7cfe01a45285890811342490244/v.f30.mp4",
31 | "汽车");
32 |
33 | mVideoPlayerWidget.setOnPlayStateListener(new MxTvPlayerWidget.OnPlayStateListener() {
34 | @Override
35 | public void onPlayPrepared() {
36 | }
37 |
38 | @Override
39 | public void onPlayBufferingUpdate(int percent) {
40 | }
41 |
42 | @Override
43 | public void OnPlayCompletion() {
44 | }
45 | });
46 |
47 | mVideoPlayerWidget.addOnKeyListener(new MxTvPlayerWidget.IOnKeyListener() {
48 | @Override
49 | public boolean onKeyDown(int keyCode, KeyEvent event) {
50 | return false;
51 | }
52 |
53 | @Override
54 | public boolean onKeyUp(int keyCode, KeyEvent event) {
55 | return false;
56 | }
57 | });
58 | }
59 |
60 | @Override
61 | public boolean onKeyDown(int keyCode, KeyEvent event) {
62 | return mVideoPlayerWidget.requestKeyDown(keyCode, event);
63 | }
64 |
65 | @Override
66 | public boolean onKeyUp(int keyCode, KeyEvent event) {
67 | return mVideoPlayerWidget.requestKeyUp(keyCode, event);
68 | }
69 |
70 | @Override
71 | protected void onPause() {
72 | super.onPause();
73 | MxVideoPlayer.releaseAllVideos();
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/app/src/main/java/com/app/mxvideoplayer/VideoListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.app.mxvideoplayer;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 |
9 | import com.app.mxvideoplayer.util.playUtils;
10 | import com.bumptech.glide.Glide;
11 |
12 | import hb.xvideoplayer.MxVideoPlayer;
13 | import hb.xvideoplayer.MxVideoPlayerWidget;
14 |
15 |
16 | public class VideoListAdapter extends BaseAdapter {
17 |
18 | private final Context mContext;
19 | int[] mVideoIds = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
20 |
21 | public VideoListAdapter(Context context) {
22 | mContext = context;
23 | }
24 | @Override
25 | public int getCount() {
26 | return mVideoIds.length;
27 | }
28 |
29 | @Override
30 | public Object getItem(int position) {
31 | return null;
32 | }
33 |
34 | @Override
35 | public long getItemId(int position) {
36 | return position;
37 | }
38 |
39 | @Override
40 | public View getView(int position, View convertView, ViewGroup parent) {
41 | final ViewHolder holder;
42 | if (null == convertView) {
43 | holder = new ViewHolder();
44 | convertView = View.inflate(mContext, R.layout.layout_item_list, null);
45 | holder.mPlayerWidget = (MxVideoPlayerWidget) convertView.findViewById(R.id.list_video_player);
46 | convertView.setTag(holder);
47 | } else {
48 | holder = (ViewHolder) convertView.getTag();
49 | }
50 | String url = playUtils.videoUrls[position];
51 | holder.mPlayerWidget.startPlay(url, MxVideoPlayer.SCREEN_LAYOUT_LIST,
52 | playUtils.videoTitles[position]);
53 |
54 | return convertView;
55 | }
56 |
57 | private class ViewHolder {
58 | MxVideoPlayerWidget mPlayerWidget;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/app/mxvideoplayer/util/playUtils.java:
--------------------------------------------------------------------------------
1 | package com.app.mxvideoplayer.util;
2 |
3 |
4 | public class playUtils {
5 | public static String[] videoUrls = {
6 | "http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/7cfe01a45285890811342490244/v.f30.mp4",
7 | "http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/b0d244d75285890811387532689/v.f30.mp4",
8 | "http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/7ab8e5845285890811383453600/v.f30.mp4",
9 | "http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/75c622485285890811383213286/v.f30.mp4",
10 | "http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/3774ce4b5285890811127255962/v.f30.mp4",
11 | "http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/5eeb3f4e5285890811345246477/v.f30.mp4",
12 | "http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/7419460d5285890811311829836/v.f30.mp4",
13 | "http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/7cfe01a45285890811342490244/v.f30.mp4",
14 | "http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/b0d244d75285890811387532689/v.f30.mp4",
15 | "http://1400299523.vod2.myqcloud.com/d457202dvodtranscq1400299523/7ab8e5845285890811383453600/v.f30.mp4"};
16 |
17 | public static String[] videoThumbs = {
18 | "http://img3.yytcdn.com/video/mv/140108/850708/D81901436FF172396A44128BAC8C3707_240x135.jpeg",
19 | "http://img2.yytcdn.com/video/mv/131209/782817/E52D0142D6983499B7E60C5AA0F9B29B_240x135.jpeg",
20 | "http://img4.yytcdn.com/video/mv/161107/2718302/-M-607b772f1dae744f9bf680335c1d5bf4_240x135.jpg",
21 | "http://img3.yytcdn.com/video/mv/161128/2734805/-M-6092e56586b6c11de7587c9da429ec3c_240x135.png",
22 | "http://img0.yytcdn.com/video/mv/160316/2523189/-M-113da0b3347fe56a44cca544042ff8f4_240x135.jpg",
23 | "http://img3.yytcdn.com/video/mv/160620/2601440/-M-6d8b9b48bfed57274671373d45cf5357_240x135.jpg",
24 | "http://img0.yytcdn.com/video/mv/160925/2687649/-M-645ae93b17f72e7fe516ddc2b788b149_240x135.jpg",
25 | "http://img2.yytcdn.com/video/mv/140702/2085252/F6870146F50FBE2E0448557D420795A7_240x135.jpeg",
26 | "http://img3.yytcdn.com/video/mv/131204/825740/C29F0142BBA15341C1F337611F8165E5_240x135.jpeg",
27 | "http://img2.yytcdn.com/video/mv/150803/2343277/-M-1d82f75d9955016a3463b59b05445855_240x135.png"};
28 |
29 | public static String[] videoTitles = {
30 | "汽车",
31 | "明天你是否依然爱我",
32 | "你好李焕英",
33 | "紧急救援",
34 | "维密天使",
35 | "开箱倒车",
36 | "西双版纳",
37 | "汽车",
38 | "明天你是否依然爱我",
39 | "你好李焕英"};
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_auto_tiny.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_mobile.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
23 |
24 |
33 |
34 |
43 |
44 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_mobile_section.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_tv.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/head_normal_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_item_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/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 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MxVideoPlayer
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/app/mxvideoplayer/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.app.mxvideoplayer;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/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 | jcenter(){
6 | google()
7 | }
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.6.1'
11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
15 | classpath 'com.github.dcendents:android-maven-plugin:1.2'
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Dec 15 14:06:38 CST 2020
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.2.2-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 |
--------------------------------------------------------------------------------
/screenshot1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/screenshot1.jpg
--------------------------------------------------------------------------------
/screenshot2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/screenshot2.jpg
--------------------------------------------------------------------------------
/screenshot3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/screenshot3.jpg
--------------------------------------------------------------------------------
/screenshot4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/screenshot4.jpg
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':xvideoplayer'
2 |
--------------------------------------------------------------------------------
/xvideoplayer/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/xvideoplayer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 | bintrayRepo = 'maven'
5 | bintrayName = 'MxVideoPlayer'
6 |
7 | publishedGroupId = 'com.henryblue.mxvideoplayer'
8 | libraryName = 'xvideoplayer'
9 | artifact = 'xvideoplayer'
10 |
11 | libraryDescription = 'widget for support to play video'
12 |
13 | siteUrl = 'https://github.com/henry-blue/MxVideoPlayer'
14 | gitUrl = 'https://github.com/henry-blue/MxVideoPlayer.git'
15 |
16 | libraryVersion = '1.2.1'
17 |
18 | developerId = 'henry'
19 | developerName = 'henry-blue'
20 | developerEmail = '18363002785@163.com'
21 |
22 | licenseName = 'The Apache Software License, Version 2.0'
23 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
24 | allLicenses = ["Apache-2.0"]
25 | }
26 |
27 | android {
28 | compileSdkVersion 24
29 | buildToolsVersion "24.0.3"
30 |
31 | defaultConfig {
32 | minSdkVersion 16
33 | targetSdkVersion 24
34 | versionCode 1
35 | versionName "1.2.1"
36 | }
37 | buildTypes {
38 | release {
39 | minifyEnabled false
40 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
41 | }
42 | }
43 | lintOptions {
44 | abortOnError false
45 | }
46 | }
47 |
48 | dependencies {
49 | implementation fileTree(dir: 'libs', include: ['*.jar'])
50 | testImplementation 'junit:junit:4.12'
51 | implementation 'com.android.support:appcompat-v7:24.2.1'
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/xvideoplayer/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 D:\android-studio-sdk-windows/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 |
--------------------------------------------------------------------------------
/xvideoplayer/src/androidTest/java/mxvideoplayer/app/com/xvideoplayer/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package mxvideoplayer.app.com.xvideoplayer;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/xvideoplayer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/java/hb/xvideoplayer/MxDragLayout.java:
--------------------------------------------------------------------------------
1 | package hb.xvideoplayer;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.view.MotionEventCompat;
8 | import android.support.v4.widget.ViewDragHelper;
9 | import android.util.AttributeSet;
10 | import android.util.Log;
11 | import android.view.MotionEvent;
12 | import android.view.View;
13 | import android.widget.FrameLayout;
14 |
15 | public class MxDragLayout extends FrameLayout {
16 | private ViewDragHelper mDragHelper;
17 |
18 | private int finalLeft = -1;
19 | private int finalTop = -1;
20 |
21 | private ViewDragHelper.Callback mDragHelperCallback = new ViewDragHelper.Callback() {
22 |
23 | @Override
24 | public boolean tryCaptureView(View child, int pointerId) {
25 | return child instanceof MxVideoPlayer;
26 | }
27 |
28 | @Override
29 | public int getViewHorizontalDragRange(View child) {
30 | return getWidth() - child.getWidth();
31 | }
32 |
33 | @Override
34 | public int getViewVerticalDragRange(View child) {
35 | return getHeight() - child.getHeight();
36 | }
37 |
38 | @Override
39 | public int clampViewPositionHorizontal(View child, int left, int dx) {
40 | final int leftBound = getPaddingLeft();
41 | final int rightBound = getWidth() - child.getWidth() - leftBound;
42 | return Math.min(Math.max(left, leftBound), rightBound);
43 | }
44 |
45 | @Override
46 | public int clampViewPositionVertical(View child, int top, int dy) {
47 | final int topBound = getPaddingTop();
48 | final int bottomBound = getHeight() - child.getHeight() - topBound;
49 | return Math.min(Math.max(top, topBound), bottomBound);
50 | }
51 |
52 | @Override
53 | public void onViewReleased(View releasedChild, float xvel, float yvel) {
54 | super.onViewReleased(releasedChild, xvel, yvel);
55 | int viewWidth = releasedChild.getWidth();
56 | int viewHeight = releasedChild.getHeight();
57 | int curLeft = releasedChild.getLeft();
58 | int curTop = releasedChild.getTop();
59 |
60 | finalTop = curTop;
61 | finalLeft = curLeft;
62 | if (finalTop + viewHeight > getHeight()) {
63 | finalTop = getHeight() - viewHeight;
64 | }
65 |
66 | if (finalLeft + viewWidth > getWidth()) {
67 | finalLeft = getWidth() - viewWidth;
68 | }
69 |
70 | mDragHelper.settleCapturedViewAt(finalLeft, finalTop);
71 | invalidate();
72 | }
73 | };
74 |
75 |
76 | public MxDragLayout(@NonNull Context context) {
77 | super(context);
78 | init();
79 | }
80 |
81 | public MxDragLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
82 | super(context, attrs);
83 | init();
84 | }
85 |
86 | public MxDragLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
87 | super(context, attrs, defStyleAttr);
88 | init();
89 | }
90 |
91 | private void init() {
92 | mDragHelper = ViewDragHelper.create(this, mDragHelperCallback);
93 | setBackgroundColor(Color.TRANSPARENT);
94 | }
95 |
96 | @Override
97 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
98 | if (finalLeft == -1 && finalTop == -1) {
99 | super.onLayout(changed, left, top, right, bottom);
100 | }
101 | }
102 |
103 | @Override
104 | public boolean onInterceptTouchEvent(MotionEvent ev) {
105 | final int action = MotionEventCompat.getActionMasked(ev);
106 | if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
107 | mDragHelper.cancel();
108 | return false;
109 | }
110 | return mDragHelper.shouldInterceptTouchEvent(ev);
111 | }
112 |
113 | @Override
114 | public boolean onTouchEvent(MotionEvent event) {
115 | mDragHelper.processTouchEvent(event);
116 | return false;
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/java/hb/xvideoplayer/MxImageView.java:
--------------------------------------------------------------------------------
1 | package hb.xvideoplayer;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.graphics.Point;
6 | import android.util.AttributeSet;
7 | import android.util.Log;
8 | import android.widget.ImageView;
9 |
10 | /**
11 | * NOTE! Can not fullscreen RelativeLayout, need to nest a LinearLayout
12 | * onMeasure与MxTextureView里的相同, 参考VideoView中的onMeasure
13 | */
14 | @SuppressLint("AppCompatCustomView")
15 | public class MxImageView extends ImageView {
16 | protected static final String TAG = "MxImageView";
17 | protected static final boolean DEBUG = false;
18 |
19 | protected Point mVideoSize;
20 |
21 | public MxImageView(Context context) {
22 | this(context, null);
23 | }
24 |
25 | public MxImageView(Context context, AttributeSet attrs) {
26 | super(context, attrs);
27 | init();
28 | }
29 |
30 | protected void init() {
31 | mVideoSize = new Point(0, 0);
32 | }
33 |
34 | public void setVideoSize(Point videoSize) {
35 | if (videoSize != null && !mVideoSize.equals(videoSize)) {
36 | this.mVideoSize = videoSize;
37 | requestLayout();
38 | }
39 | }
40 |
41 | @Override
42 | public void setRotation(float rotation) {
43 | if (rotation != getRotation()) {
44 | super.setRotation(rotation);
45 | requestLayout();
46 | }
47 | }
48 |
49 | @Override
50 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
51 | int viewRotation = (int) getRotation();
52 | // If rotate, swap the width and height parameters
53 | if (viewRotation == 90 || viewRotation == 270) {
54 | int tempMeasureSpec = widthMeasureSpec;
55 | widthMeasureSpec = heightMeasureSpec;
56 | heightMeasureSpec = tempMeasureSpec;
57 | }
58 |
59 | if (DEBUG) {
60 | Log.i(TAG, "onMeasure " + " [" + this.hashCode() + "] ");
61 | Log.i(TAG, "viewRotation = " + viewRotation);
62 | }
63 |
64 | int videoWidth = mVideoSize.x;
65 | int videoHeight = mVideoSize.y;
66 |
67 | if (DEBUG) {
68 | Log.i(TAG, "videoWidth = " + videoWidth + ", " + "videoHeight = " + videoHeight);
69 | if (videoWidth > 0 && videoHeight > 0) {
70 | Log.i(TAG, "videoWidth / videoHeight = " + videoWidth / videoHeight);
71 | }
72 | }
73 |
74 | int width = getDefaultSize(videoWidth, widthMeasureSpec);
75 | int height = getDefaultSize(videoHeight, heightMeasureSpec);
76 | if (videoWidth > 0 && videoHeight > 0) {
77 |
78 | int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
79 | int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
80 | int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
81 | int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
82 |
83 | if (DEBUG) {
84 | Log.i(TAG, "widthMeasureSpec [" + MeasureSpec.toString(widthMeasureSpec) + "]");
85 | Log.i(TAG, "heightMeasureSpec [" + MeasureSpec.toString(heightMeasureSpec) + "]");
86 | }
87 |
88 | if (widthSpecMode == MeasureSpec.EXACTLY && heightSpecMode == MeasureSpec.EXACTLY) {
89 | // the size is fixed
90 | width = widthSpecSize;
91 | height = heightSpecSize;
92 |
93 | // for compatibility, we adjust size based on aspect ratio
94 | if (videoWidth * height < width * videoHeight) {
95 | width = height * videoWidth / videoHeight;
96 | } else if (videoWidth * height > width * videoHeight) {
97 | height = width * videoHeight / videoWidth;
98 | }
99 | } else if (widthSpecMode == MeasureSpec.EXACTLY) {
100 | // only the width is fixed, adjust the height to match aspect ratio if possible
101 | width = widthSpecSize;
102 | height = width * videoHeight / videoWidth;
103 | if (heightSpecMode == MeasureSpec.AT_MOST && height > heightSpecSize) {
104 | // couldn't match aspect ratio within the constraints
105 | height = heightSpecSize;
106 | width = height * videoWidth / videoHeight;
107 | }
108 | } else if (heightSpecMode == MeasureSpec.EXACTLY) {
109 | // only the height is fixed, adjust the width to match aspect ratio if possible
110 | height = heightSpecSize;
111 | width = height * videoWidth / videoHeight;
112 | if (widthSpecMode == MeasureSpec.AT_MOST && width > widthSpecSize) {
113 | // couldn't match aspect ratio within the constraints
114 | width = widthSpecSize;
115 | height = width * videoHeight / videoWidth;
116 | }
117 | } else {
118 | // neither the width nor the height are fixed, try to use actual video size
119 | width = videoWidth;
120 | height = videoHeight;
121 | if (heightSpecMode == MeasureSpec.AT_MOST && height > heightSpecSize) {
122 | // too tall, decrease both width and height
123 | height = heightSpecSize;
124 | width = height * videoWidth / videoHeight;
125 | }
126 | if (widthSpecMode == MeasureSpec.AT_MOST && width > widthSpecSize) {
127 | // too wide, decrease both width and height
128 | width = widthSpecSize;
129 | height = width * videoHeight / videoWidth;
130 | }
131 | }
132 | } else {
133 | // no size yet, just adopt the given spec sizes
134 | }
135 | if (DEBUG) {
136 | Log.i(TAG, "viewWidth = " + width + ", " + "viewHeight = " + height);
137 | Log.i(TAG, "viewWidth / viewHeight = " + width / height);
138 | }
139 | setMeasuredDimension(width, height);
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/java/hb/xvideoplayer/MxMediaManager.java:
--------------------------------------------------------------------------------
1 | package hb.xvideoplayer;
2 |
3 |
4 | import android.graphics.Point;
5 | import android.graphics.SurfaceTexture;
6 | import android.media.AudioManager;
7 | import android.media.MediaPlayer;
8 | import android.os.Handler;
9 | import android.os.HandlerThread;
10 | import android.text.TextUtils;
11 | import android.util.Log;
12 | import android.view.Surface;
13 |
14 | import java.lang.reflect.Method;
15 | import java.util.Map;
16 |
17 |
18 | public class MxMediaManager implements MediaPlayer.OnPreparedListener, MediaPlayer.OnCompletionListener,
19 | MediaPlayer.OnBufferingUpdateListener, MediaPlayer.OnSeekCompleteListener, MediaPlayer.OnErrorListener,
20 | MediaPlayer.OnVideoSizeChangedListener, MediaPlayer.OnInfoListener {
21 |
22 | private static String TAG = "MxVideoPlayer";
23 |
24 | private static MxMediaManager mxMediaManager;
25 | private MediaPlayer mMediaPlayer;
26 | private Handler mMediaHandler;
27 | private Handler mainThreadHandler;
28 | public static MxTextureView mTextureView;
29 | public static SurfaceTexture mSurface;
30 |
31 | public int mLastState;
32 | public boolean mIsShowBottomProgressBar = true;
33 | public int mCurVideoWidth = 0;
34 | public int mCurVideoHeight = 0;
35 | public int bufferPercent = 0;
36 | public int mBackUpBufferState = -1;
37 | public String mCurrentUrl = "";
38 |
39 | private MxMediaManager() {
40 | mMediaPlayer = new MediaPlayer();
41 | HandlerThread mMediaHandlerThread = new HandlerThread(TAG);
42 | mMediaHandlerThread.start();
43 | mMediaHandler = new Handler(mMediaHandlerThread.getLooper());
44 | mainThreadHandler = new Handler();
45 | }
46 |
47 | public static MxMediaManager getInstance() {
48 | if (mxMediaManager == null) {
49 | synchronized (MxMediaManager.class) {
50 | if (mxMediaManager == null) {
51 | mxMediaManager = new MxMediaManager();
52 | }
53 | }
54 | }
55 | return mxMediaManager;
56 | }
57 |
58 | public void setDisPlay(final Surface surface) {
59 | mMediaHandler.post(new Runnable() {
60 | @Override
61 | public void run() {
62 | if (mMediaPlayer != null) {
63 | mMediaPlayer.setSurface(surface);
64 | }
65 | }
66 | });
67 | }
68 |
69 | public MediaPlayer getPlayer() {
70 | return mMediaPlayer;
71 | }
72 |
73 | public void prepare(final String url, final Map mapHeapData, final boolean loop) {
74 | if (!TextUtils.isEmpty(url)) {
75 | mMediaHandler.post(new Runnable() {
76 | @Override
77 | public void run() {
78 | try {
79 | mCurVideoWidth = 0;
80 | mCurVideoHeight = 0;
81 | if (mMediaPlayer != null) {
82 | mMediaPlayer.release();
83 | mMediaPlayer = null;
84 | }
85 | mMediaPlayer = new MediaPlayer();
86 | mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
87 | mMediaPlayer.setScreenOnWhilePlaying(true);
88 | mMediaPlayer.setLooping(loop);
89 | mMediaPlayer.setOnPreparedListener(MxMediaManager.this);
90 | mMediaPlayer.setOnCompletionListener(MxMediaManager.this);
91 | mMediaPlayer.setOnBufferingUpdateListener(MxMediaManager.this);
92 | mMediaPlayer.setOnSeekCompleteListener(MxMediaManager.this);
93 | mMediaPlayer.setOnErrorListener(MxMediaManager.this);
94 | mMediaPlayer.setOnInfoListener(MxMediaManager.this);
95 | mMediaPlayer.setOnVideoSizeChangedListener(MxMediaManager.this);
96 | Class clazz = MediaPlayer.class;
97 | mCurrentUrl = url;
98 | Method method = clazz.getDeclaredMethod("setDataSource", String.class, Map.class);
99 | method.invoke(mMediaPlayer, url, mapHeapData);
100 | mMediaPlayer.prepareAsync();
101 | } catch (Exception e) {
102 | e.printStackTrace();
103 | Log.e(TAG, "handleMessage: prepare video error: " + e.getMessage());
104 | }
105 | }
106 | });
107 | }
108 | }
109 |
110 | public void releaseMediaPlayer() {
111 | mMediaHandler.post(new Runnable() {
112 | @Override
113 | public void run() {
114 | if (mMediaPlayer != null) {
115 | mMediaPlayer.release();
116 | mMediaPlayer = null;
117 | }
118 | }
119 | });
120 | }
121 |
122 | public void seekTo(final int msec) {
123 | mMediaHandler.post(new Runnable() {
124 | @Override
125 | public void run() {
126 | if (mMediaPlayer != null) {
127 | mMediaPlayer.seekTo(msec);
128 | }
129 | }
130 | });
131 | }
132 |
133 | @Override
134 | public void onPrepared(MediaPlayer MediaPlayer) {
135 | mainThreadHandler.post(new Runnable() {
136 | @Override
137 | public void run() {
138 | MxMediaPlayerListener listener = MxVideoPlayerManager.getCurrentListener();
139 | if (listener != null) {
140 | listener.onPrepared();
141 | }
142 | }
143 | });
144 | }
145 |
146 | @Override
147 | public void onBufferingUpdate(MediaPlayer MediaPlayer, final int percent) {
148 | mainThreadHandler.post(new Runnable() {
149 | @Override
150 | public void run() {
151 | MxMediaPlayerListener listener = MxVideoPlayerManager.getCurrentListener();
152 | if (listener != null) {
153 | listener.onBufferingUpdate(percent);
154 | }
155 | }
156 | });
157 | }
158 |
159 | @Override
160 | public void onCompletion(MediaPlayer MediaPlayer) {
161 | mainThreadHandler.post(new Runnable() {
162 | @Override
163 | public void run() {
164 | MxMediaPlayerListener listener = MxVideoPlayerManager.getCurrentListener();
165 | if (listener != null) {
166 | listener.onAutoCompletion();
167 | }
168 | }
169 | });
170 | }
171 |
172 | @Override
173 | public boolean onError(MediaPlayer MediaPlayer, final int what, final int extra) {
174 | mainThreadHandler.post(new Runnable() {
175 | @Override
176 | public void run() {
177 | MxMediaPlayerListener listener = MxVideoPlayerManager.getCurrentListener();
178 | if (listener != null) {
179 | listener.onError(what, extra);
180 | }
181 | }
182 | });
183 | return true;
184 | }
185 |
186 | @Override
187 | public boolean onInfo(MediaPlayer MediaPlayer, final int what, final int extra) {
188 | mainThreadHandler.post(new Runnable() {
189 | @Override
190 | public void run() {
191 | MxMediaPlayerListener listener = MxVideoPlayerManager.getCurrentListener();
192 | if (listener != null) {
193 | listener.onInfo(what, extra);
194 | }
195 | }
196 | });
197 | return false;
198 | }
199 |
200 | @Override
201 | public void onSeekComplete(MediaPlayer MediaPlayer) {
202 | mainThreadHandler.post(new Runnable() {
203 | @Override
204 | public void run() {
205 | MxMediaPlayerListener listener = MxVideoPlayerManager.getCurrentListener();
206 | if (listener != null) {
207 | listener.onSeekComplete();
208 | }
209 | }
210 | });
211 | }
212 |
213 | @Override
214 | public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
215 | mCurVideoWidth = mp.getVideoWidth();
216 | mCurVideoHeight = mp.getVideoHeight();
217 | mainThreadHandler.post(new Runnable() {
218 | @Override
219 | public void run() {
220 | MxMediaPlayerListener listener = MxVideoPlayerManager.getCurrentListener();
221 | if (listener != null) {
222 | listener.onVideoSizeChanged();
223 | }
224 | }
225 | });
226 | }
227 |
228 | public Point getVideoSize() {
229 | if (mCurVideoWidth != 0 && mCurVideoHeight != 0) {
230 | return new Point(mCurVideoWidth, mCurVideoHeight);
231 | } else {
232 | return null;
233 | }
234 | }
235 | }
236 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/java/hb/xvideoplayer/MxMediaPlayerListener.java:
--------------------------------------------------------------------------------
1 | package hb.xvideoplayer;
2 |
3 | public interface MxMediaPlayerListener {
4 | void onPrepared();
5 |
6 | void onCompletion();
7 |
8 | void onBufferingUpdate(int percent);
9 |
10 | void onSeekComplete();
11 |
12 | void onError(int what, int extra);
13 |
14 | void onInfo(int what, int extra);
15 |
16 | void onVideoSizeChanged();
17 |
18 | void goBackNormalListener();
19 |
20 | boolean quitFullscreenOrTinyListener();
21 |
22 | int getScreenType();
23 |
24 | String getUrl();
25 |
26 | int getState();
27 |
28 | void onAutoCompletion();
29 |
30 | void autoFullscreen(float x);
31 |
32 | void autoQuitFullscreen();
33 | }
34 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/java/hb/xvideoplayer/MxTextureView.java:
--------------------------------------------------------------------------------
1 | package hb.xvideoplayer;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Point;
6 | import android.util.AttributeSet;
7 | import android.util.Log;
8 | import android.view.TextureView;
9 |
10 | /**
11 | * NOTE: Can not fullscreen RelativeLayout, need to nest a LinearLayout
12 | */
13 | public class MxTextureView extends TextureView {
14 | protected static final String TAG = "MxTextureView";
15 | protected static final boolean DEBUG = false;
16 |
17 | protected Point mVideoSize;
18 | protected boolean mHasUpdated;
19 |
20 | public MxTextureView(Context context) {
21 | this(context, null);
22 | }
23 |
24 | public MxTextureView(Context context, AttributeSet attrs) {
25 | super(context, attrs);
26 | init();
27 | }
28 |
29 | private void init() {
30 | mVideoSize = new Point(0, 0);
31 | }
32 |
33 | @Override
34 | public Bitmap getBitmap() {
35 | if (mHasUpdated) {
36 | return super.getBitmap();
37 | } else {
38 | return null;
39 | }
40 | }
41 |
42 | @Override
43 | public Bitmap getBitmap(int width, int height) {
44 | if (mHasUpdated) {
45 | return super.getBitmap(width, height);
46 | } else {
47 | return null;
48 | }
49 | }
50 |
51 | @Override
52 | public Bitmap getBitmap(Bitmap bitmap) {
53 | if (mHasUpdated) {
54 | return super.getBitmap(bitmap);
55 | } else {
56 | return null;
57 | }
58 | }
59 |
60 | public void setVideoSize(Point videoSize) {
61 | if (videoSize != null && !mVideoSize.equals(videoSize)) {
62 | mVideoSize = videoSize;
63 | requestLayout();
64 | }
65 | }
66 |
67 | public void setHasUpdated() {
68 | mHasUpdated = true;
69 | }
70 |
71 | @Override
72 | public void setRotation(float rotation) {
73 | if (rotation != getRotation()) {
74 | super.setRotation(rotation);
75 | requestLayout();
76 | }
77 | }
78 |
79 | @Override
80 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
81 | int viewRotation = (int) getRotation();
82 | // If rotate, swap the width and height parameters
83 | if (viewRotation == 90 || viewRotation == 270) {
84 | int tmpMeasureSpec = widthMeasureSpec;
85 | widthMeasureSpec = heightMeasureSpec;
86 | heightMeasureSpec = tmpMeasureSpec;
87 | }
88 |
89 | if (DEBUG) {
90 | Log.i(TAG, "onMeasure " + " [" + this.hashCode() + "] ");
91 | Log.i(TAG, "viewRotation = " + viewRotation);
92 | }
93 |
94 | int videoWidth = mVideoSize.x;
95 | int videoHeight = mVideoSize.y;
96 |
97 | if (DEBUG) {
98 | Log.i(TAG, "videoWidth = " + videoWidth + ", " + "videoHeight = " + videoHeight);
99 | if (videoWidth > 0 && videoHeight > 0) {
100 | Log.i(TAG, "videoWidth / videoHeight = " + videoWidth / videoHeight);
101 | }
102 | }
103 |
104 | int width = getDefaultSize(videoWidth, widthMeasureSpec);
105 | int height = getDefaultSize(videoHeight, heightMeasureSpec);
106 | if (videoWidth > 0 && videoHeight > 0) {
107 |
108 | int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
109 | int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
110 | int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
111 | int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
112 |
113 | if (DEBUG) {
114 | Log.i(TAG, "widthMeasureSpec [" + MeasureSpec.toString(widthMeasureSpec) + "]");
115 | Log.i(TAG, "heightMeasureSpec [" + MeasureSpec.toString(heightMeasureSpec) + "]");
116 | }
117 |
118 | if (widthSpecMode == MeasureSpec.EXACTLY && heightSpecMode == MeasureSpec.EXACTLY) {
119 | // the size is fixed
120 | width = widthSpecSize;
121 | height = heightSpecSize;
122 |
123 | // for compatibility, we adjust size based on aspect ratio
124 | if ( videoWidth * height < width * videoHeight ) {
125 | width = height * videoWidth / videoHeight;
126 | } else if ( videoWidth * height > width * videoHeight ) {
127 | height = width * videoHeight / videoWidth;
128 | }
129 | } else if (widthSpecMode == MeasureSpec.EXACTLY) {
130 | // only the width is fixed, adjust the height to match aspect ratio if possible
131 | width = widthSpecSize;
132 | height = width * videoHeight / videoWidth;
133 | if (heightSpecMode == MeasureSpec.AT_MOST && height > heightSpecSize) {
134 | // couldn't match aspect ratio within the constraints
135 | height = heightSpecSize;
136 | width = height * videoHeight / videoWidth;
137 | }
138 | } else if (heightSpecMode == MeasureSpec.EXACTLY) {
139 | // only the height is fixed, adjust the width to match aspect ratio if possible
140 | height = heightSpecSize;
141 | width = height * videoWidth / videoHeight;
142 | if (widthSpecMode == MeasureSpec.AT_MOST && width > widthSpecSize) {
143 | // couldn't match aspect ratio within the constraints
144 | width = widthSpecSize;
145 | height = height * videoHeight / videoWidth;
146 | }
147 | } else {
148 | // neither the width nor the height are fixed, try to use actual video size
149 | width = videoWidth;
150 | height = videoHeight;
151 | if (heightSpecMode == MeasureSpec.AT_MOST && height > heightSpecSize) {
152 | // too tall, decrease both width and height
153 | height = heightSpecSize;
154 | width = height * videoWidth / videoHeight;
155 | }
156 | if (widthSpecMode == MeasureSpec.AT_MOST && width > widthSpecSize) {
157 | // too wide, decrease both width and height
158 | width = widthSpecSize;
159 | height = width * videoHeight / videoWidth;
160 | }
161 | }
162 | } else {
163 | // no size yet, just adopt the given spec sizes
164 | }
165 | if (DEBUG) {
166 | Log.i(TAG, "viewWidth = " + width + ", " + "viewHeight = " + height);
167 | Log.i(TAG, "viewWidth / viewHeight = " + width / height);
168 | }
169 | setMeasuredDimension(width, height);
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/java/hb/xvideoplayer/MxTvPlayerWidget.java:
--------------------------------------------------------------------------------
1 | package hb.xvideoplayer;
2 |
3 |
4 | import android.app.Activity;
5 | import android.app.AlertDialog;
6 | import android.app.Dialog;
7 | import android.content.Context;
8 | import android.content.DialogInterface;
9 | import android.content.res.TypedArray;
10 | import android.graphics.drawable.Drawable;
11 | import android.media.AudioManager;
12 | import android.util.AttributeSet;
13 | import android.util.TypedValue;
14 | import android.view.KeyEvent;
15 | import android.view.View;
16 | import android.view.Window;
17 | import android.view.WindowManager;
18 | import android.widget.ImageView;
19 | import android.widget.ProgressBar;
20 | import android.widget.TextView;
21 |
22 | import java.util.Timer;
23 | import java.util.TimerTask;
24 |
25 | import mxvideoplayer.app.com.xvideoplayer.R;
26 |
27 | public class MxTvPlayerWidget extends MxVideoPlayer {
28 |
29 | private static final int VOLUME_ITEM = 2;
30 | private static final int PROGRESS_ITEM = 15;
31 |
32 | protected static Timer DISMISS_CONTROL_VIEW_TIMER;
33 |
34 | public ProgressBar mBottomProgressBar, mLoadingProgressBar;
35 | public TextView mTitleTextView;
36 | public ImageView mThumbImageView;
37 |
38 | protected Dialog mProgressDialog;
39 | protected Dialog mVolumeDialog;
40 | protected ProgressBar mDialogVolumeProgressBar;
41 | protected ProgressBar mDialogProgressBar;
42 |
43 | protected TextView mDialogSeekTime;
44 | protected TextView mDialogTotalTime;
45 | protected ImageView mDialogIcon;
46 | protected ImageView mDialogVolumeIcon;
47 |
48 | private int mTvDownPosition = 0;
49 | private int mTvSeekPosition;
50 |
51 | private OnPlayStateListener mListener;
52 | private IOnKeyListener mKeyListener;
53 | private boolean mIsShowBottomProgressBar;
54 |
55 | protected DismissControlViewTimerTask mDismissControlViewTimerTask;
56 |
57 | private Runnable mDismissVolumeCallback = new Runnable() {
58 | @Override
59 | public void run() {
60 | dismissVolumeDialog();
61 | }
62 | };
63 |
64 | public MxTvPlayerWidget(Context context) {
65 | super(context);
66 | }
67 |
68 | public MxTvPlayerWidget(Context context, AttributeSet attrs) {
69 | super(context, attrs);
70 | }
71 |
72 | @Override
73 | public void initView(Context context) {
74 | super.initView(context);
75 | mBottomProgressBar = (ProgressBar) findViewById(R.id.mx_bottom_progress);
76 | mTitleTextView = (TextView) findViewById(R.id.mx_title);
77 | mThumbImageView = (ImageView) findViewById(R.id.mx_thumb);
78 | mLoadingProgressBar = (ProgressBar) findViewById(R.id.mx_loading);
79 | }
80 |
81 | public boolean startPlay(String url, Object... objects) {
82 | if (objects.length == 0) {
83 | return false;
84 | }
85 | if (super.startPlay(url, SCREEN_LAYOUT_NORMAL, objects)) {
86 | mTitleTextView.setText(objects[0].toString());
87 | return true;
88 | }
89 | return false;
90 | }
91 |
92 | public boolean autoStartPlay(String url, Object... objects) {
93 | if (startPlay(url, objects)) {
94 | mPlayControllerButton.performClick();
95 | return true;
96 | } else {
97 | return false;
98 | }
99 | }
100 |
101 | public void setOnPlayStateListener(OnPlayStateListener listener) {
102 | mListener = listener;
103 | }
104 |
105 | public void addOnKeyListener(IOnKeyListener listener) {
106 | mKeyListener = listener;
107 | }
108 |
109 | public boolean requestKeyDown(int keyCode, KeyEvent event) {
110 | boolean result = false;
111 | switch (keyCode) {
112 | case KeyEvent.KEYCODE_DPAD_DOWN:
113 | case KeyEvent.KEYCODE_VOLUME_DOWN:
114 | downVolume();
115 | result = true;
116 | break;
117 | case KeyEvent.KEYCODE_DPAD_UP:
118 | case KeyEvent.KEYCODE_VOLUME_UP:
119 | upVolume();
120 | result = true;
121 | break;
122 | case KeyEvent.KEYCODE_DPAD_RIGHT:
123 | cancelProgressTimer();
124 | if (mTvDownPosition == 0) {
125 | mTvDownPosition = getCurrentPositionWhenPlaying();
126 | }
127 | doReverse(event.getRepeatCount());
128 | result = true;
129 | break;
130 | case KeyEvent.KEYCODE_DPAD_LEFT:
131 | cancelProgressTimer();
132 | if (mTvDownPosition == 0) {
133 | mTvDownPosition = getCurrentPositionWhenPlaying();
134 | }
135 | doForward(event.getRepeatCount());
136 | result = true;
137 | break;
138 | case KeyEvent.KEYCODE_BACK:
139 | result = true;
140 | MxUtils.getAppComptActivity(getContext()).onBackPressed();
141 | break;
142 | default:
143 | break;
144 | }
145 | if (!result && mKeyListener != null) {
146 | return mKeyListener.onKeyDown(keyCode, event);
147 | }
148 | return result;
149 | }
150 |
151 | public boolean requestKeyUp(int keyCode, KeyEvent event) {
152 | switch (keyCode) {
153 | case KeyEvent.KEYCODE_ENTER:
154 | mPlayControllerButton.performClick();
155 | break;
156 | case KeyEvent.KEYCODE_DPAD_RIGHT:
157 | case KeyEvent.KEYCODE_DPAD_LEFT:
158 | startProgressTimer();
159 | setProgress();
160 | dismissProgressDialog();
161 | break;
162 | case KeyEvent.KEYCODE_DPAD_DOWN:
163 | case KeyEvent.KEYCODE_DPAD_UP:
164 | case KeyEvent.KEYCODE_VOLUME_UP:
165 | case KeyEvent.KEYCODE_VOLUME_DOWN:
166 | mHandler.removeCallbacks(mDismissVolumeCallback);
167 | mHandler.postDelayed(mDismissVolumeCallback, 2000);
168 | break;
169 | default:
170 | onClickUiToggle();
171 | startDismissControlViewTimer();
172 | break;
173 | }
174 |
175 | return mKeyListener != null && mKeyListener.onKeyUp(keyCode, event);
176 | }
177 |
178 | public void downVolume() {
179 | int currentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
180 | int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
181 | mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, currentVolume - VOLUME_ITEM, 0);
182 | int volumePercent = (currentVolume - VOLUME_ITEM) * 100 / maxVolume;
183 | showVolumeDialog(VOLUME_ITEM, volumePercent);
184 | }
185 |
186 | public void upVolume() {
187 | int currentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
188 | int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
189 | mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, currentVolume + VOLUME_ITEM, 0);
190 | int volumePercent = (currentVolume + VOLUME_ITEM) * 100 / maxVolume;
191 | showVolumeDialog(VOLUME_ITEM, volumePercent);
192 | }
193 |
194 | public void doReverse(int count) {
195 | if (count <= 0) {
196 | count = 1;
197 | }
198 | int totalTimeDuration = getDuration();
199 | int seekTimePosition = mTvDownPosition + PROGRESS_ITEM * count * (totalTimeDuration / mScreenWidth);
200 | if (seekTimePosition > totalTimeDuration) {
201 | seekTimePosition = totalTimeDuration;
202 | }
203 | String seekTime = MxUtils.stringForTime(seekTimePosition);
204 | String totalTime = MxUtils.stringForTime(totalTimeDuration);
205 | showProgressDialog(PROGRESS_ITEM, seekTime, seekTimePosition, totalTime, totalTimeDuration);
206 | }
207 |
208 | public void doForward(int count) {
209 | if (count <= 0) {
210 | count = 1;
211 | }
212 | int totalTimeDuration = getDuration();
213 | int seekTimePosition = mTvDownPosition - PROGRESS_ITEM * count * (totalTimeDuration / mScreenWidth);
214 | if (seekTimePosition < 0) {
215 | seekTimePosition = 0;
216 | }
217 | String seekTime = MxUtils.stringForTime(seekTimePosition);
218 | String totalTime = MxUtils.stringForTime(totalTimeDuration);
219 | showProgressDialog(-PROGRESS_ITEM, seekTime, seekTimePosition, totalTime, totalTimeDuration);
220 | }
221 |
222 | private void setProgress() {
223 | MxMediaManager.getInstance().seekTo(mTvSeekPosition);
224 | mProgressBar.setProgress(mDialogProgressBar.getProgress());
225 | mTvDownPosition = 0;
226 | }
227 |
228 | @Override
229 | public void setUiPlayState(int state) {
230 | super.setUiPlayState(state);
231 | switch (mCurrentState) {
232 | case CURRENT_STATE_NORMAL:
233 | setAllControlsVisible(View.VISIBLE, View.INVISIBLE, View.VISIBLE,
234 | View.INVISIBLE, View.VISIBLE, View.INVISIBLE);
235 | updateStartImage();
236 | break;
237 | case CURRENT_STATE_PREPARING:
238 | setAllControlsVisible(View.VISIBLE, View.INVISIBLE, View.INVISIBLE,
239 | View.VISIBLE, View.VISIBLE, View.INVISIBLE);
240 | startDismissControlViewTimer();
241 | mBottomProgressBar.setProgress(0);
242 | break;
243 | case CURRENT_STATE_PLAYING:
244 | setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE,
245 | View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
246 | updateStartImage();
247 | startDismissControlViewTimer();
248 | break;
249 | case CURRENT_STATE_PAUSE:
250 | setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE,
251 | View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
252 | updateStartImage();
253 | cancelDismissControlViewTimer();
254 | break;
255 | case CURRENT_STATE_ERROR:
256 | setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.VISIBLE,
257 | View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
258 | updateStartImage();
259 | break;
260 | case CURRENT_STATE_AUTO_COMPLETE:
261 | setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE,
262 | View.INVISIBLE, View.VISIBLE, View.INVISIBLE);
263 | updateStartImage();
264 | cancelDismissControlViewTimer();
265 | mBottomProgressBar.setProgress(100);
266 | break;
267 | case CURRENT_STATE_PLAYING_BUFFERING_START:
268 | setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.INVISIBLE,
269 | View.VISIBLE, View.INVISIBLE, View.INVISIBLE);
270 | break;
271 | default:
272 | break;
273 | }
274 | }
275 |
276 | private void onClickUiToggle() {
277 | if (mCurrentState == CURRENT_STATE_PREPARING) {
278 | if (mBottomContainer.getVisibility() == View.VISIBLE) {
279 | setAllControlsVisible(View.VISIBLE, View.INVISIBLE, View.INVISIBLE,
280 | View.VISIBLE, View.VISIBLE, View.INVISIBLE);
281 | } else {
282 | setAllControlsVisible(View.VISIBLE, View.INVISIBLE, View.INVISIBLE,
283 | View.VISIBLE, View.VISIBLE, View.INVISIBLE);
284 | }
285 | } else if (mCurrentState == CURRENT_STATE_PLAYING) {
286 | if (mBottomContainer.getVisibility() == View.VISIBLE) {
287 | setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE,
288 | View.INVISIBLE, View.INVISIBLE, View.VISIBLE);
289 | } else {
290 | setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE,
291 | View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
292 | updateStartImage();
293 | }
294 | } else if (mCurrentState == CURRENT_STATE_PAUSE) {
295 | if (mBottomProgressBar.getVisibility() == View.VISIBLE) {
296 | setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE,
297 | View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
298 | } else {
299 | setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE,
300 | View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
301 | updateStartImage();
302 | }
303 | } else if (mCurrentState == CURRENT_STATE_AUTO_COMPLETE) {
304 | if (mBottomContainer.getVisibility() == View.VISIBLE) {
305 | setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.VISIBLE,
306 | View.INVISIBLE, View.VISIBLE, View.VISIBLE);
307 | updateStartImage();
308 | } else {
309 | setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE,
310 | View.INVISIBLE, View.VISIBLE, View.INVISIBLE);
311 | updateStartImage();
312 | }
313 | } else if (mCurrentState == CURRENT_STATE_PLAYING_BUFFERING_START) {
314 | if (mBottomContainer.getVisibility() == View.VISIBLE) {
315 | setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE,
316 | View.VISIBLE, View.INVISIBLE, View.VISIBLE);
317 | updateStartImage();
318 | } else {
319 | setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.INVISIBLE,
320 | View.VISIBLE, View.INVISIBLE, View.INVISIBLE);
321 | }
322 | }
323 | }
324 |
325 | private void cancelDismissControlViewTimer() {
326 | if (DISMISS_CONTROL_VIEW_TIMER != null) {
327 | DISMISS_CONTROL_VIEW_TIMER.cancel();
328 | }
329 | if (mDismissControlViewTimerTask != null) {
330 | mDismissControlViewTimerTask.cancel();
331 | }
332 | }
333 |
334 | private void startDismissControlViewTimer() {
335 | cancelDismissControlViewTimer();
336 | DISMISS_CONTROL_VIEW_TIMER = new Timer();
337 | mDismissControlViewTimerTask = new DismissControlViewTimerTask();
338 | DISMISS_CONTROL_VIEW_TIMER.schedule(mDismissControlViewTimerTask, 2500);
339 | }
340 |
341 | private void updateStartImage() {
342 | if (mCurrentState == CURRENT_STATE_PLAYING) {
343 | mPlayControllerButton.setImageResource(R.drawable.mx_click_pause_selector);
344 | } else if (mCurrentState == CURRENT_STATE_ERROR) {
345 | mPlayControllerButton.setImageResource(R.drawable.mx_click_error_selector);
346 | } else {
347 | mPlayControllerButton.setImageResource(R.drawable.mx_click_play_selector);
348 | }
349 | }
350 |
351 | public void setAllControlsVisible(int topCon, int bottomCon, int startBtn, int loadingPro,
352 | int thumbImg, int bottomPro) {
353 | mTopContainer.setVisibility(topCon);
354 | mBottomContainer.setVisibility(bottomCon);
355 | mPlayControllerButton.setVisibility(startBtn);
356 | mLoadingProgressBar.setVisibility(loadingPro);
357 | if (thumbImg == View.VISIBLE) {
358 | mThumbImageView.setVisibility(thumbImg);
359 | } else {
360 | mThumbImageView.setVisibility(View.GONE);
361 | }
362 | if (mIsShowBottomProgressBar) {
363 | mBottomProgressBar.setVisibility(bottomPro);
364 | } else {
365 | mBottomProgressBar.setVisibility(View.GONE);
366 | }
367 | }
368 |
369 | @Override
370 | public void setProgressAndTime(int progress, int secProgress, int currentTime, int totalTime) {
371 | super.setProgressAndTime(progress, secProgress, currentTime, totalTime);
372 | if (progress != 0) {
373 | mBottomProgressBar.setProgress(progress);
374 | }
375 | if (secProgress != 0) {
376 | mBottomProgressBar.setSecondaryProgress(secProgress);
377 | }
378 | }
379 |
380 | @Override
381 | protected void showBrightnessDialog(float v, int brightnessPercent) {
382 |
383 | }
384 |
385 | @Override
386 | protected int getLayoutId() {
387 | return R.layout.mx_video_layout_tv;
388 | }
389 |
390 | @Override
391 | protected void initAttributeSet(Context context, AttributeSet attrs) {
392 | if (attrs == null) {
393 | return;
394 | }
395 | TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.MxVideoPlayer);
396 | Drawable drawable = attr.getDrawable(R.styleable.MxVideoPlayer_progress_drawable);
397 | setProgressDrawable(drawable);
398 | int defaultTextSize = context.getResources().getDimensionPixelSize(R.dimen.mx_title_textSize);
399 | int size = attr.getDimensionPixelSize(R.styleable.MxVideoPlayer_title_size, defaultTextSize);
400 | setTitleSize(size);
401 | boolean isShowBottomProgressBar = attr.getBoolean(R.styleable.MxVideoPlayer_showBottomProgress, true);
402 | setBottomProgressBarVisibility(isShowBottomProgressBar);
403 | attr.recycle();
404 | }
405 |
406 | private void setProgressDrawable(Drawable drawable) {
407 | if (drawable != null) {
408 | mProgressBar.setProgressDrawable(drawable);
409 | }
410 | }
411 |
412 | private void setTitleSize(int size) {
413 | mTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
414 | }
415 |
416 | public void setBottomProgressBarVisibility(boolean visibility) {
417 | mIsShowBottomProgressBar = visibility;
418 | }
419 |
420 | @Override
421 | protected boolean isShowNetworkStateDialog() {
422 | if (!mPlayUrl.startsWith("file") && !MxUtils.isNetworkConnected(getContext())) {
423 | showNetworkTipDialog();
424 | return true;
425 | }
426 | return false;
427 | }
428 |
429 | private void showNetworkTipDialog() {
430 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
431 | builder.setMessage(getResources().getString(R.string.tips_not_net));
432 | builder.setPositiveButton(getResources().getString(R.string.tips_not_network_ok),
433 | new DialogInterface.OnClickListener() {
434 | @Override
435 | public void onClick(DialogInterface dialog, int which) {
436 | dialog.dismiss();
437 | }
438 | });
439 | builder.create().show();
440 | }
441 |
442 | @Override
443 | protected void showProgressDialog(float deltaX, String seekTime,
444 | int seekTimePosition, String totalTime, int totalTimeDuration) {
445 | if (mProgressDialog == null) {
446 | View localView = View.inflate(getContext(), R.layout.mx_tv_progress_dialog, null);
447 | mDialogProgressBar = ((ProgressBar) localView.findViewById(R.id.duration_progressbar));
448 | mDialogSeekTime = ((TextView) localView.findViewById(R.id.tv_current));
449 | mDialogTotalTime = ((TextView) localView.findViewById(R.id.tv_duration));
450 | mDialogIcon = ((ImageView) localView.findViewById(R.id.duration_image_tip));
451 | mProgressDialog = new Dialog(getContext(), R.style.mx_style_dialog_progress);
452 | mProgressDialog.setContentView(localView);
453 | if (mProgressDialog.getWindow() != null) {
454 | mProgressDialog.getWindow().addFlags(Window.FEATURE_ACTION_BAR);
455 | mProgressDialog.getWindow().addFlags(32);
456 | mProgressDialog.getWindow().addFlags(16);
457 | mProgressDialog.getWindow().setLayout(-2, -2);
458 | }
459 | WindowManager.LayoutParams localLayoutParams = mProgressDialog.getWindow().getAttributes();
460 | localLayoutParams.gravity = 49;
461 | localLayoutParams.y = getResources().getDimensionPixelOffset(R.dimen.mx_tv_progress_dialog_margin_top);
462 | localLayoutParams.width = getContext().getResources()
463 | .getDimensionPixelOffset(R.dimen.tv_progress_dialog_width);
464 | mProgressDialog.getWindow().setAttributes(localLayoutParams);
465 | }
466 | if (!mProgressDialog.isShowing()) {
467 | mProgressDialog.show();
468 | }
469 |
470 | mDialogSeekTime.setText(seekTime);
471 | mDialogTotalTime.setText(String.format(" / %s", totalTime));
472 | mTvSeekPosition = seekTimePosition;
473 | int curProgress = seekTimePosition * 100 / totalTimeDuration;
474 | mDialogProgressBar.setProgress(totalTimeDuration <= 0 ? 0 : curProgress);
475 | if (deltaX > 0) {
476 | mDialogIcon.setBackgroundResource(R.drawable.mx_forward_icon);
477 | } else {
478 | mDialogIcon.setBackgroundResource(R.drawable.mx_backward_icon);
479 | }
480 | }
481 |
482 | @Override
483 | protected void showVolumeDialog(float v, int volumePercent) {
484 | if (mVolumeDialog == null) {
485 | View localView = View.inflate(getContext(), R.layout.mx_tv_volume_dialog, null);
486 | mDialogVolumeProgressBar = ((ProgressBar) localView.findViewById(R.id.volume_progressbar));
487 | mDialogVolumeIcon = (ImageView) localView.findViewById(R.id.mx_volume_icon);
488 | mVolumeDialog = new Dialog(getContext(), R.style.mx_style_dialog_progress);
489 | mVolumeDialog.setContentView(localView);
490 | if (mVolumeDialog.getWindow() != null) {
491 | mVolumeDialog.getWindow().addFlags(8);
492 | mVolumeDialog.getWindow().addFlags(32);
493 | mVolumeDialog.getWindow().addFlags(16);
494 | mVolumeDialog.getWindow().setLayout(-2, -2);
495 | }
496 | WindowManager.LayoutParams localLayoutParams = mVolumeDialog.getWindow().getAttributes();
497 | localLayoutParams.gravity = 49;
498 | localLayoutParams.y = getContext().getResources()
499 | .getDimensionPixelOffset(R.dimen.mx_tv_progress_dialog_margin_top);
500 | localLayoutParams.width = getContext().getResources()
501 | .getDimensionPixelOffset(R.dimen.tv_volume_dialog_ll_width);
502 | mVolumeDialog.getWindow().setAttributes(localLayoutParams);
503 | }
504 | if (!mVolumeDialog.isShowing()) {
505 | mVolumeDialog.show();
506 | }
507 | if (volumePercent <= 0) {
508 | mDialogVolumeIcon.setImageResource(R.drawable.mx_volume_no);
509 | } else {
510 | mDialogVolumeIcon.setImageResource(R.drawable.mx_volume_icon);
511 | }
512 | mDialogVolumeProgressBar.setProgress(volumePercent);
513 | }
514 |
515 | @Override
516 | protected void dismissVolumeDialog() {
517 | if (mVolumeDialog != null) {
518 | mVolumeDialog.dismiss();
519 | }
520 | }
521 |
522 | @Override
523 | protected void dismissBrightnessDialog() {
524 |
525 | }
526 |
527 | @Override
528 | protected void dismissProgressDialog() {
529 | if (mProgressDialog != null) {
530 | mProgressDialog.dismiss();
531 | }
532 | }
533 |
534 | @Override
535 | public void onPrepared() {
536 | super.onPrepared();
537 | if (mListener != null) {
538 | mListener.onPlayPrepared();
539 | }
540 | }
541 |
542 | @Override
543 | public void onBufferingUpdate(int percent) {
544 | super.onBufferingUpdate(percent);
545 | if (mListener != null) {
546 | mListener.onPlayBufferingUpdate(percent);
547 | }
548 | }
549 |
550 | @Override
551 | public void onAutoCompletion() {
552 | super.onAutoCompletion();
553 | if (mListener != null) {
554 | mListener.OnPlayCompletion();
555 | }
556 | }
557 |
558 | private class DismissControlViewTimerTask extends TimerTask {
559 |
560 | @Override
561 | public void run() {
562 | if (mCurrentState != CURRENT_STATE_NORMAL
563 | && mCurrentState != CURRENT_STATE_ERROR
564 | && mCurrentState != CURRENT_STATE_AUTO_COMPLETE) {
565 | if (getContext() != null && getContext() instanceof Activity) {
566 | ((Activity) getContext()).runOnUiThread(new Runnable() {
567 | @Override
568 | public void run() {
569 | mBottomContainer.setVisibility(View.INVISIBLE);
570 | mTopContainer.setVisibility(View.INVISIBLE);
571 | mPlayControllerButton.setVisibility(View.INVISIBLE);
572 | if (mIsShowBottomProgressBar) {
573 | mBottomProgressBar.setVisibility(View.VISIBLE);
574 | }
575 | }
576 | });
577 | }
578 | }
579 | }
580 | }
581 |
582 | public interface OnPlayStateListener {
583 | void onPlayPrepared();
584 | void onPlayBufferingUpdate(int percent);
585 | void OnPlayCompletion();
586 | }
587 |
588 | public interface IOnKeyListener {
589 | boolean onKeyDown(int keyCode, KeyEvent event);
590 | boolean onKeyUp(int keyCode, KeyEvent event);
591 | }
592 | }
593 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/java/hb/xvideoplayer/MxUserAction.java:
--------------------------------------------------------------------------------
1 | package hb.xvideoplayer;
2 |
3 |
4 | public interface MxUserAction {
5 | int ON_CLICK_START_ICON = 0;
6 | int ON_CLICK_START_ERROR = 1;
7 | int ON_CLICK_START_AUTO_COMPLETE = 2;
8 |
9 | int ON_CLICK_PAUSE = 3;
10 | int ON_CLICK_RESUME = 4;
11 | int ON_SEEK_POSITION = 5;
12 | int ON_AUTO_COMPLETE = 6;
13 |
14 | int ON_ENTER_FULLSCREEN = 7;
15 | int ON_QUIT_FULLSCREEN = 8;
16 | int ON_ENTER_TINY_SCREEN = 9;
17 | int ON_QUIT_TINY_SCREEN = 10;
18 |
19 | int ON_TOUCH_SCREEN_SEEK_VOLUME = 11;
20 | int ON_TOUCH_SCREEN_SEEK_BRIGHTNESS = 12;
21 | int ON_TOUCH_SCREEN_SEEK_POSITION = 13;
22 |
23 | void onActionEvent(int type, String url, int screen, Object... objects);
24 | }
25 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/java/hb/xvideoplayer/MxUtils.java:
--------------------------------------------------------------------------------
1 | package hb.xvideoplayer;
2 |
3 |
4 | import android.annotation.SuppressLint;
5 | import android.app.Activity;
6 | import android.content.ContentResolver;
7 | import android.content.Context;
8 | import android.content.ContextWrapper;
9 | import android.net.ConnectivityManager;
10 | import android.net.NetworkInfo;
11 | import android.provider.Settings;
12 | import android.support.v7.app.AppCompatActivity;
13 | import android.support.v7.view.ContextThemeWrapper;
14 | import android.view.Display;
15 | import android.view.View;
16 | import android.view.Window;
17 | import android.view.WindowManager;
18 |
19 | import java.util.Formatter;
20 | import java.util.Locale;
21 |
22 | class MxUtils {
23 |
24 | public static int SYSTEM_UI = 0;
25 |
26 | static String stringForTime(long milliseconds) {
27 | if (milliseconds < 0 || milliseconds >= 24 * 60 * 60 * 1000) {
28 | return "00:00";
29 | }
30 | milliseconds /= 1000;
31 | int minute = (int) (milliseconds / 60);
32 | int hour = minute / 60;
33 | int second = (int) (milliseconds % 60);
34 | minute %= 60;
35 | StringBuilder stringBuilder = new StringBuilder();
36 | Formatter mFormatter = new Formatter(stringBuilder, Locale.getDefault());
37 | if (hour > 0) {
38 | return mFormatter.format("%02d:%02d:%02d", hour, minute, second).toString();
39 | } else {
40 | return mFormatter.format("%02d:%02d", minute, second).toString();
41 | }
42 | }
43 |
44 | static boolean isWifiConnected(Context context) {
45 | ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
46 | NetworkInfo networkInfo = manager.getActiveNetworkInfo();
47 | return (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI);
48 | }
49 |
50 | static AppCompatActivity getAppComptActivity(Context context) {
51 | if (context == null) {
52 | return null;
53 | }
54 | if (context instanceof AppCompatActivity) {
55 | return (AppCompatActivity) context;
56 | } else if (context instanceof ContextThemeWrapper) {
57 | return getAppComptActivity(((ContextThemeWrapper)context).getBaseContext());
58 | }
59 | return null;
60 | }
61 |
62 | static Activity scanForActivity(Context context) {
63 | if (context == null) {
64 | return null;
65 | }
66 | if (context instanceof Activity) {
67 | return (Activity) context;
68 | } else if (context instanceof ContextWrapper) {
69 | return scanForActivity(((ContextWrapper) context).getBaseContext());
70 | }
71 | return null;
72 | }
73 |
74 | static boolean isNetworkConnected(Context context) {
75 | ConnectivityManager connectivityManager = (ConnectivityManager) context.
76 | getSystemService(Context.CONNECTIVITY_SERVICE);
77 |
78 | if (connectivityManager == null) {
79 | return false;
80 | } else {
81 | NetworkInfo[] networkInfo = connectivityManager.getAllNetworkInfo();
82 |
83 | if (networkInfo != null && networkInfo.length > 0) {
84 | for (NetworkInfo aNetworkInfo : networkInfo) {
85 | if (aNetworkInfo.getState() == NetworkInfo.State.CONNECTED) {
86 | return true;
87 | }
88 | }
89 | }
90 | }
91 | return false;
92 | }
93 |
94 | static void setScreenManualMode(Context context) {
95 | ContentResolver contentResolver = context.getContentResolver();
96 | try {
97 | int mode = Settings.System.getInt(contentResolver,
98 | Settings.System.SCREEN_BRIGHTNESS_MODE);
99 | if (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
100 | Settings.System.putInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS_MODE,
101 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
102 | }
103 | } catch (Settings.SettingNotFoundException e) {
104 | e.printStackTrace();
105 | }
106 | }
107 |
108 | static int getScreenBrightness(Activity activity) {
109 | int nowBrightnessValue = 0;
110 | ContentResolver resolver = activity.getContentResolver();
111 | try {
112 | nowBrightnessValue = Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS);
113 | } catch (Exception e) {
114 | e.printStackTrace();
115 | }
116 | return nowBrightnessValue;
117 | }
118 |
119 | static void setWindowBrightness(Activity activity, float brightness) {
120 | WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
121 | lp.screenBrightness = brightness / 255.0f;
122 | if (lp.screenBrightness > 1) {
123 | lp.screenBrightness = 1;
124 | } else if (lp.screenBrightness < 0.1) {
125 | lp.screenBrightness = (float) 0.1;
126 | }
127 | activity.getWindow().setAttributes(lp);
128 | }
129 |
130 |
131 | @SuppressLint("NewApi")
132 | public static void hideSystemUI(Context context) {
133 | int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
134 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
135 | | View.SYSTEM_UI_FLAG_FULLSCREEN
136 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
137 | ;
138 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
139 | uiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
140 | }
141 | SYSTEM_UI = getWindow(context).getDecorView().getSystemUiVisibility();
142 | getWindow(context).getDecorView().setSystemUiVisibility(uiOptions);
143 |
144 | }
145 |
146 | @SuppressLint("NewApi")
147 | public static void showSystemUI(Context context) {
148 | getWindow(context).getDecorView().setSystemUiVisibility(SYSTEM_UI);
149 | }
150 |
151 | public static Window getWindow(Context context) {
152 | if (scanForActivity(context) != null) {
153 | return scanForActivity(context).getWindow();
154 | } else {
155 | return scanForActivity(context).getWindow();
156 | }
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/java/hb/xvideoplayer/MxVideoPlayerManager.java:
--------------------------------------------------------------------------------
1 | package hb.xvideoplayer;
2 |
3 | import android.text.TextUtils;
4 | import android.util.Log;
5 |
6 | import java.lang.ref.WeakReference;
7 | import java.util.LinkedList;
8 |
9 |
10 | /**
11 | * Manager all VideoPlayerListener
12 | * put MxVideoPlayer into Layout
13 | */
14 | public class MxVideoPlayerManager {
15 | public static WeakReference mCurScrollListener;
16 | public static LinkedList> mListenerList = new LinkedList<>();
17 |
18 | public static void putScrollListener(MxMediaPlayerListener listener) {
19 | if (listener.getScreenType() == MxVideoPlayer.SCREEN_WINDOW_TINY ||
20 | listener.getScreenType() == MxVideoPlayer.SCREEN_WINDOW_FULLSCREEN) {
21 | return;
22 | }
23 | mCurScrollListener = new WeakReference<>(listener);
24 | }
25 |
26 | public static void putListener(MxMediaPlayerListener listener) {
27 | if (listener == null) {
28 | return;
29 | }
30 | mListenerList.push(new WeakReference<>(listener));
31 | }
32 |
33 | public static void checkAndPutListener(MxMediaPlayerListener listener) {
34 | if (listener == null || mListenerList == null) {
35 | return;
36 | }
37 | if (listener.getScreenType() == MxVideoPlayer.SCREEN_WINDOW_TINY ||
38 | listener.getScreenType() == MxVideoPlayer.SCREEN_WINDOW_FULLSCREEN) {
39 | return;
40 | }
41 | int location = -1;
42 | for (int i = 1; i < mListenerList.size(); ++i) {
43 | MxMediaPlayerListener mediaPlayerListener = mListenerList.get(i).get();
44 | String url = listener.getUrl();
45 | String url1 = mediaPlayerListener.getUrl();
46 | if (!TextUtils.isEmpty(url) && !TextUtils.isEmpty(url1) && url.equals(url1)) {
47 | location = i;
48 | }
49 | }
50 |
51 | if (location != -1) {
52 | mListenerList.remove(location);
53 | if (mListenerList.size() <= location) {
54 | mListenerList.addLast(new WeakReference<>(listener));
55 | } else {
56 | mListenerList.set(location, new WeakReference<>(listener));
57 | }
58 | }
59 | }
60 |
61 | public static MxMediaPlayerListener popListener() {
62 | if (mListenerList.size() <= 0) {
63 | return null;
64 | }
65 | return mListenerList.pop().get();
66 | }
67 |
68 | public static MxMediaPlayerListener getCurrentListener() {
69 | if (mListenerList.size() <= 0) {
70 | return null;
71 | }
72 | return mListenerList.getFirst().get();
73 | }
74 |
75 | public static void completeAll() {
76 | MxMediaPlayerListener listener = popListener();
77 | while (listener != null) {
78 | listener.onCompletion();
79 | listener = popListener();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/java/hb/xvideoplayer/MxVideoPlayerWidget.java:
--------------------------------------------------------------------------------
1 | package hb.xvideoplayer;
2 |
3 |
4 | import android.app.Activity;
5 | import android.app.AlertDialog;
6 | import android.app.Dialog;
7 | import android.content.Context;
8 | import android.content.DialogInterface;
9 | import android.content.res.TypedArray;
10 | import android.graphics.drawable.Drawable;
11 | import android.text.TextUtils;
12 | import android.util.AttributeSet;
13 | import android.util.TypedValue;
14 | import android.view.MotionEvent;
15 | import android.view.View;
16 | import android.view.Window;
17 | import android.view.WindowManager;
18 | import android.widget.ImageView;
19 | import android.widget.ProgressBar;
20 | import android.widget.SeekBar;
21 | import android.widget.TextView;
22 | import android.widget.Toast;
23 |
24 | import java.util.Timer;
25 | import java.util.TimerTask;
26 |
27 | import mxvideoplayer.app.com.xvideoplayer.R;
28 |
29 | public class MxVideoPlayerWidget extends MxVideoPlayer {
30 |
31 | protected static Timer DISMISS_CONTROL_VIEW_TIMER;
32 |
33 | public ImageView mBackButton;
34 | public ProgressBar mBottomProgressBar, mLoadingProgressBar;
35 | public TextView mTitleTextView;
36 | public ImageView mThumbImageView;
37 | public ImageView mTinyBackImageView;
38 |
39 | protected Dialog mProgressDialog;
40 | protected Dialog mVolumeDialog;
41 | protected Dialog mBrightnessDialog;
42 | protected ProgressBar mDialogVolumeProgressBar;
43 | protected ProgressBar mDialogBrightnessProgressBar;
44 | protected ProgressBar mDialogProgressBar;
45 | protected TextView mDialogSeekTime;
46 | protected TextView mDialogTotalTime;
47 | protected ImageView mDialogIcon;
48 | protected boolean mIsShowBottomProgressBar;
49 | private boolean mIsAutoPlay = false;
50 | private boolean mIsAutoProcessUI = false;
51 | private UIStatusChangeListener mUIListener;
52 |
53 | protected DismissControlViewTimerTask mDismissControlViewTimerTask;
54 |
55 | public enum Mode {
56 | MODE_NORMAL,
57 | MODE_PREPARING,
58 | MODE_PREPARING_CLEAR,
59 | MODE_AUTO_PLAY,
60 | MODE_PLAYING,
61 | MODE_PLAYING_CLEAR,
62 | MODE_PAUSE,
63 | MODE_PAUSE_CLEAR,
64 | MODE_COMPLETE,
65 | MODE_COMPLETE_CLEAR,
66 | MODE_BUFFERING,
67 | MODE_BUFFERING_CLEAR,
68 | MODE_ERROR
69 | }
70 |
71 | public MxVideoPlayerWidget(Context context) {
72 | super(context);
73 | }
74 |
75 | public MxVideoPlayerWidget(Context context, AttributeSet attrs) {
76 | super(context, attrs);
77 | }
78 |
79 | @Override
80 | public void initView(Context context) {
81 | super.initView(context);
82 | mBottomProgressBar = (ProgressBar) findViewById(R.id.mx_bottom_progress);
83 | mTitleTextView = (TextView) findViewById(R.id.mx_title);
84 | mBackButton = (ImageView) findViewById(R.id.mx_back);
85 | mThumbImageView = (ImageView) findViewById(R.id.mx_thumb);
86 | mLoadingProgressBar = (ProgressBar) findViewById(R.id.mx_loading);
87 | mTinyBackImageView = (ImageView) findViewById(R.id.mx_quit_tiny);
88 |
89 | mThumbImageView.setOnClickListener(this);
90 | mBackButton.setOnClickListener(this);
91 | mTinyBackImageView.setOnClickListener(this);
92 | }
93 |
94 | public boolean autoStartPlay(String url, int screen, Object... objects) {
95 | mIsAutoPlay = true;
96 | boolean result = false;
97 | if (startPlay(url, screen, objects)) {
98 | if (TextUtils.isEmpty(mPlayUrl)) {
99 | Toast.makeText(getContext(), getResources().getString(R.string.no_url),
100 | Toast.LENGTH_SHORT).show();
101 | return false;
102 | }
103 | if (mCurrentState == CURRENT_STATE_NORMAL) {
104 | if (isShowNetworkStateDialog()) {
105 | changeUiShowState(Mode.MODE_NORMAL);
106 | return false;
107 | }
108 | }
109 | preparePlayVideo();
110 | result = true;
111 | }
112 | mIsAutoPlay = false;
113 | return result;
114 | }
115 |
116 | @Override
117 | public boolean startPlay(String url, int screen, Object... objects) {
118 | if (objects.length == 0) {
119 | return false;
120 | }
121 | if (super.startPlay(url, screen, objects)) {
122 | mTitleTextView.setText(objects[0].toString());
123 | if (mCurrentScreen == SCREEN_WINDOW_FULLSCREEN) {
124 | mFullscreenButton.setImageResource(R.drawable.mx_shrink);
125 | mBackButton.setVisibility(View.VISIBLE);
126 | mTinyBackImageView.setVisibility(View.INVISIBLE);
127 | } else if (mCurrentScreen == SCREEN_LAYOUT_LIST ||
128 | mCurrentScreen == SCREEN_LAYOUT_NORMAL) {
129 | mFullscreenButton.setImageResource(R.drawable.mx_enlarge);
130 | mBackButton.setVisibility(View.GONE);
131 | mTinyBackImageView.setVisibility(View.INVISIBLE);
132 | } else if (mCurrentScreen == SCREEN_WINDOW_TINY) {
133 | mTinyBackImageView.setVisibility(View.VISIBLE);
134 | setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE,
135 | View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
136 | }
137 | return true;
138 | }
139 | return false;
140 | }
141 |
142 | public void setUIStatusListener(UIStatusChangeListener listener) {
143 | mUIListener = listener;
144 | }
145 |
146 | public void setAutoProcessUI(boolean autoPrcUI) {
147 | mIsAutoProcessUI = autoPrcUI;
148 | }
149 |
150 | @Override
151 | public void setUiPlayState(int state) {
152 | super.setUiPlayState(state);
153 | switch (mCurrentState) {
154 | case CURRENT_STATE_NORMAL:
155 | if (!mIsAutoPlay) {
156 | changeUiShowState(Mode.MODE_NORMAL);
157 | } else {
158 | changeUiShowState(Mode.MODE_AUTO_PLAY);
159 | }
160 | break;
161 | case CURRENT_STATE_PREPARING:
162 | changeUiShowState(Mode.MODE_PREPARING);
163 | startDismissControlViewTimer();
164 | mBottomProgressBar.setProgress(0);
165 | break;
166 | case CURRENT_STATE_PLAYING:
167 | changeUiShowState(Mode.MODE_PLAYING);
168 | startDismissControlViewTimer();
169 | break;
170 | case CURRENT_STATE_PAUSE:
171 | changeUiShowState(Mode.MODE_PAUSE);
172 | cancelDismissControlViewTimer();
173 | break;
174 | case CURRENT_STATE_ERROR:
175 | changeUiShowState(Mode.MODE_ERROR);
176 | break;
177 | case CURRENT_STATE_AUTO_COMPLETE:
178 | changeUiShowState(Mode.MODE_COMPLETE);
179 | cancelDismissControlViewTimer();
180 | mBottomProgressBar.setProgress(100);
181 | break;
182 | case CURRENT_STATE_PLAYING_BUFFERING_START:
183 | changeUiShowState(Mode.MODE_BUFFERING);
184 | break;
185 | default:
186 | break;
187 | }
188 | }
189 |
190 | @Override
191 | public boolean onTouch(View v, MotionEvent event) {
192 | int id = v.getId();
193 | if (id == R.id.mx_surface_container) {
194 | switch (event.getAction()) {
195 | case MotionEvent.ACTION_UP:
196 | startDismissControlViewTimer();
197 | if (mChangePosition) {
198 | int duration = getDuration();
199 | int progress = mSeekTimePosition * 100 / (duration == 0 ? 1 : duration);
200 | mBottomProgressBar.setProgress(progress);
201 | }
202 | if (!mChangePosition && !mChangeVolume) {
203 | onClickUiToggle();
204 | }
205 | break;
206 | default:
207 | break;
208 | }
209 | } else if (id == R.id.mx_progress) {
210 | switch (event.getAction()) {
211 | case MotionEvent.ACTION_DOWN:
212 | cancelDismissControlViewTimer();
213 | break;
214 | case MotionEvent.ACTION_UP:
215 | startDismissControlViewTimer();
216 | break;
217 | default:
218 | break;
219 | }
220 | }
221 | return super.onTouch(v, event);
222 | }
223 |
224 | private void onClickUiToggle() {
225 | if (mCurrentState == CURRENT_STATE_PREPARING) {
226 | if (mBottomContainer.getVisibility() == View.VISIBLE) {
227 | changeUiShowState(Mode.MODE_PREPARING_CLEAR);
228 | } else {
229 | changeUiShowState(Mode.MODE_PREPARING);
230 | }
231 | } else if (mCurrentState == CURRENT_STATE_PLAYING) {
232 | if (mBottomContainer.getVisibility() == View.VISIBLE) {
233 | changeUiShowState(Mode.MODE_PLAYING_CLEAR);
234 | } else {
235 | changeUiShowState(Mode.MODE_PLAYING);
236 | }
237 | } else if (mCurrentState == CURRENT_STATE_PAUSE) {
238 | if (mBottomProgressBar.getVisibility() == View.VISIBLE) {
239 | changeUiShowState(Mode.MODE_PAUSE_CLEAR);
240 | } else {
241 | changeUiShowState(Mode.MODE_PAUSE);
242 | }
243 | } else if (mCurrentState == CURRENT_STATE_AUTO_COMPLETE) {
244 | if (mBottomContainer.getVisibility() == View.VISIBLE) {
245 | changeUiShowState(Mode.MODE_COMPLETE_CLEAR);
246 | } else {
247 | changeUiShowState(Mode.MODE_COMPLETE);
248 | }
249 | } else if (mCurrentState == CURRENT_STATE_PLAYING_BUFFERING_START) {
250 | if (mBottomContainer.getVisibility() == View.VISIBLE) {
251 | changeUiShowState(Mode.MODE_BUFFERING_CLEAR);
252 | } else {
253 | changeUiShowState(Mode.MODE_BUFFERING);
254 | }
255 | }
256 | }
257 |
258 | private void changeUiShowState(Mode mode) {
259 | if (mCurrentScreen == SCREEN_WINDOW_TINY) {
260 | return;
261 | }
262 |
263 | if (mUIListener != null) {
264 | mUIListener.onUIChange(mode);
265 | }
266 |
267 | if (mIsAutoProcessUI) {
268 | if (mode == Mode.MODE_NORMAL || mode == Mode.MODE_BUFFERING_CLEAR ||
269 | mode == Mode.MODE_PLAYING || mode == Mode.MODE_PAUSE ||
270 | mode == Mode.MODE_COMPLETE || mode == Mode.MODE_COMPLETE_CLEAR
271 | || mode == Mode.MODE_ERROR) {
272 | updateStartImage();
273 | }
274 | return;
275 | }
276 |
277 | switch (mode) {
278 | case MODE_NORMAL:
279 | setAllControlsVisible(View.VISIBLE, View.INVISIBLE, View.VISIBLE,
280 | View.GONE, View.VISIBLE, View.INVISIBLE);
281 | updateStartImage();
282 | break;
283 | case MODE_BUFFERING:
284 | setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.INVISIBLE,
285 | View.VISIBLE, View.INVISIBLE, View.INVISIBLE);
286 | break;
287 | case MODE_BUFFERING_CLEAR:
288 | setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE,
289 | View.VISIBLE, View.INVISIBLE, View.VISIBLE);
290 | updateStartImage();
291 | break;
292 | case MODE_AUTO_PLAY:
293 | setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE,
294 | View.VISIBLE, View.INVISIBLE, View.INVISIBLE);
295 | break;
296 | case MODE_PREPARING:
297 | setAllControlsVisible(View.VISIBLE, View.INVISIBLE, View.INVISIBLE,
298 | View.VISIBLE, View.VISIBLE, View.INVISIBLE);
299 | break;
300 | case MODE_PREPARING_CLEAR:
301 | setAllControlsVisible(View.VISIBLE, View.INVISIBLE, View.INVISIBLE,
302 | View.VISIBLE, View.VISIBLE, View.INVISIBLE);
303 | break;
304 | case MODE_PLAYING:
305 | setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE,
306 | View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
307 | updateStartImage();
308 | break;
309 | case MODE_PLAYING_CLEAR:
310 | setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE,
311 | View.INVISIBLE, View.INVISIBLE, View.VISIBLE);
312 | break;
313 | case MODE_PAUSE:
314 | setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE,
315 | View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
316 | updateStartImage();
317 | break;
318 | case MODE_PAUSE_CLEAR:
319 | setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE,
320 | View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
321 | break;
322 | case MODE_COMPLETE:
323 | setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE,
324 | View.INVISIBLE, View.VISIBLE, View.INVISIBLE);
325 | updateStartImage();
326 | break;
327 | case MODE_COMPLETE_CLEAR:
328 | setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.VISIBLE,
329 | View.INVISIBLE, View.VISIBLE, View.VISIBLE);
330 | updateStartImage();
331 | break;
332 | case MODE_ERROR:
333 | setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.VISIBLE,
334 | View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
335 | updateStartImage();
336 | break;
337 | }
338 | }
339 |
340 | private void cancelDismissControlViewTimer() {
341 | if (DISMISS_CONTROL_VIEW_TIMER != null) {
342 | DISMISS_CONTROL_VIEW_TIMER.cancel();
343 | }
344 | if (mDismissControlViewTimerTask != null) {
345 | mDismissControlViewTimerTask.cancel();
346 | }
347 | }
348 |
349 | private void startDismissControlViewTimer() {
350 | cancelDismissControlViewTimer();
351 | DISMISS_CONTROL_VIEW_TIMER = new Timer();
352 | mDismissControlViewTimerTask = new DismissControlViewTimerTask();
353 | DISMISS_CONTROL_VIEW_TIMER.schedule(mDismissControlViewTimerTask, 2500);
354 | }
355 |
356 | private void updateStartImage() {
357 | if (mCurrentState == CURRENT_STATE_PLAYING) {
358 | mPlayControllerButton.setImageResource(R.drawable.mx_click_pause_selector);
359 | } else if (mCurrentState == CURRENT_STATE_ERROR) {
360 | mPlayControllerButton.setImageResource(R.drawable.mx_click_error_selector);
361 | } else {
362 | mPlayControllerButton.setImageResource(R.drawable.mx_click_play_selector);
363 | }
364 | }
365 |
366 | public void setAllControlsVisible(int topCon, int bottomCon, int startBtn, int loadingPro,
367 | int thumbImg, int bottomPro) {
368 | mTopContainer.setVisibility(topCon);
369 | mBottomContainer.setVisibility(bottomCon);
370 | mPlayControllerButton.setVisibility(startBtn);
371 | mLoadingProgressBar.setVisibility(loadingPro);
372 | if (thumbImg == View.VISIBLE) {
373 | mThumbImageView.setVisibility(thumbImg);
374 | } else {
375 | mThumbImageView.setVisibility(View.GONE);
376 | }
377 | if (mIsShowBottomProgressBar) {
378 | mBottomProgressBar.setVisibility(bottomPro);
379 | } else {
380 | mBottomProgressBar.setVisibility(View.GONE);
381 | }
382 | }
383 |
384 | private void setProgressDrawable(Drawable drawable) {
385 | if (drawable != null) {
386 | mProgressBar.setProgressDrawable(drawable);
387 | }
388 | }
389 |
390 | private void setTitleSize(int size) {
391 | mTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
392 | }
393 |
394 | public void setBottomProgressBarVisibility(boolean visibility) {
395 | mIsShowBottomProgressBar = visibility;
396 | }
397 |
398 | @Override
399 | public void onClick(View v) {
400 | super.onClick(v);
401 | int id = v.getId();
402 | if (id == R.id.mx_thumb) {
403 | if (TextUtils.isEmpty(mPlayUrl)) {
404 | Toast.makeText(getContext(), getResources().getString(R.string.no_url), Toast.LENGTH_SHORT).show();
405 | return;
406 | }
407 | if (mCurrentState == CURRENT_STATE_NORMAL) {
408 | if (!mPlayUrl.startsWith("file") && !MxUtils.isWifiConnected(getContext()) && !WIFI_TIP_DIALOG_SHOWED) {
409 | showWifiDialog();
410 | return;
411 | }
412 | preparePlayVideo();
413 | } else if (mCurrentState == CURRENT_STATE_AUTO_COMPLETE) {
414 | onClickUiToggle();
415 | }
416 | } else if (id == R.id.mx_surface_container) {
417 | startDismissControlViewTimer();
418 | } else if (id == R.id.mx_back) {
419 | backPress();
420 | } else if (id == R.id.mx_quit_tiny) {
421 | if (MxVideoPlayerManager.mCurScrollListener.get() != null) {
422 | if (!MxVideoPlayerManager.mCurScrollListener.get().getUrl().
423 | equals(MxMediaManager.getInstance().mCurrentUrl)) {
424 | releaseAllVideos();
425 | return;
426 | }
427 | }
428 | backPress();
429 | }
430 | }
431 |
432 | @Override
433 | public void startWindowFullscreen() {
434 | MxMediaManager.getInstance().mIsShowBottomProgressBar = mIsShowBottomProgressBar;
435 | super.startWindowFullscreen();
436 | }
437 |
438 | @Override
439 | public void setProgressAndTime(int progress, int secProgress, int currentTime, int totalTime) {
440 | super.setProgressAndTime(progress, secProgress, currentTime, totalTime);
441 | if (progress != 0) {
442 | mBottomProgressBar.setProgress(progress);
443 | }
444 | if (secProgress != 0) {
445 | mBottomProgressBar.setSecondaryProgress(secProgress);
446 | }
447 | }
448 |
449 | @Override
450 | public void resetProgressAndTime() {
451 | super.resetProgressAndTime();
452 | mBottomProgressBar.setProgress(0);
453 | mBottomProgressBar.setSecondaryProgress(0);
454 | }
455 |
456 | @Override
457 | public void onStartTrackingTouch(SeekBar seekBar) {
458 | super.onStartTrackingTouch(seekBar);
459 | cancelDismissControlViewTimer();
460 | }
461 |
462 | @Override
463 | public void onStopTrackingTouch(SeekBar seekBar) {
464 | super.onStopTrackingTouch(seekBar);
465 | startDismissControlViewTimer();
466 | }
467 |
468 | @Override
469 | protected int getLayoutId() {
470 | return R.layout.mx_video_layout_mobile;
471 | }
472 |
473 | @Override
474 | protected void initAttributeSet(Context context, AttributeSet attrs) {
475 | if (attrs == null) {
476 | mIsShowBottomProgressBar = MxMediaManager.getInstance().mIsShowBottomProgressBar;
477 | return;
478 | }
479 | TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.MxVideoPlayer);
480 | Drawable drawable = attr.getDrawable(R.styleable.MxVideoPlayer_progress_drawable);
481 | setProgressDrawable(drawable);
482 | int defaultTextSize = context.getResources().getDimensionPixelSize(R.dimen.mx_title_textSize);
483 | int size = attr.getDimensionPixelSize(R.styleable.MxVideoPlayer_title_size, defaultTextSize);
484 | setTitleSize(size);
485 | boolean isShowBottomProgressBar = attr.getBoolean(R.styleable.MxVideoPlayer_showBottomProgress, true);
486 | setBottomProgressBarVisibility(isShowBottomProgressBar);
487 | attr.recycle();
488 | }
489 |
490 | @Override
491 | protected boolean isShowNetworkStateDialog() {
492 | if (!mPlayUrl.startsWith("file") && !MxUtils.isWifiConnected(getContext()) && !WIFI_TIP_DIALOG_SHOWED) {
493 | showWifiDialog();
494 | return true;
495 | }
496 | return false;
497 | }
498 |
499 | private void showWifiDialog() {
500 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
501 | builder.setMessage(getResources().getString(R.string.tips_not_wifi));
502 | builder.setPositiveButton(getResources().getString(R.string.tips_not_wifi_confirm),
503 | new DialogInterface.OnClickListener() {
504 | @Override
505 | public void onClick(DialogInterface dialog, int which) {
506 | dialog.dismiss();
507 | preparePlayVideo();
508 | WIFI_TIP_DIALOG_SHOWED = true;
509 | }
510 | });
511 | builder.setNegativeButton(getResources().getString(R.string.tips_not_wifi_cancel),
512 | new DialogInterface.OnClickListener() {
513 | @Override
514 | public void onClick(DialogInterface dialog, int which) {
515 | dialog.dismiss();
516 | }
517 | });
518 | builder.create().show();
519 | }
520 |
521 | @Override
522 | protected void showProgressDialog(float deltaX, String seekTime,
523 | int seekTimePosition, String totalTime, int totalTimeDuration) {
524 | if (mProgressDialog == null) {
525 | View localView = View.inflate(getContext(), R.layout.mx_progress_dialog, null);
526 | mDialogProgressBar = ((ProgressBar) localView.findViewById(R.id.duration_progressbar));
527 | mDialogSeekTime = ((TextView) localView.findViewById(R.id.video_current));
528 | mDialogTotalTime = ((TextView) localView.findViewById(R.id.video_duration));
529 | mDialogIcon = ((ImageView) localView.findViewById(R.id.duration_image_tip));
530 | mProgressDialog = new Dialog(getContext(), R.style.mx_style_dialog_progress);
531 | mProgressDialog.setContentView(localView);
532 | if (mProgressDialog.getWindow() != null) {
533 | mProgressDialog.getWindow().addFlags(Window.FEATURE_ACTION_BAR);
534 | mProgressDialog.getWindow().addFlags(32);
535 | mProgressDialog.getWindow().addFlags(16);
536 | mProgressDialog.getWindow().setLayout(-2, -2);
537 | }
538 | WindowManager.LayoutParams params = mProgressDialog.getWindow().getAttributes();
539 | params.gravity = 49;
540 | params.y = getResources().getDimensionPixelOffset(R.dimen.mx_progress_dialog_margin_top);
541 | params.width = getContext().getResources()
542 | .getDimensionPixelOffset(R.dimen.mx_mobile_dialog_width);
543 | mProgressDialog.getWindow().setAttributes(params);
544 | }
545 | if (!mProgressDialog.isShowing()) {
546 | mProgressDialog.show();
547 | }
548 |
549 | mDialogSeekTime.setText(seekTime);
550 | mDialogTotalTime.setText(String.format(" / %s", totalTime));
551 | mDialogProgressBar.setProgress(totalTimeDuration <= 0 ? 0 : (seekTimePosition * 100 / totalTimeDuration));
552 | if (deltaX > 0) {
553 | mDialogIcon.setBackgroundResource(R.drawable.mx_forward_icon);
554 | } else {
555 | mDialogIcon.setBackgroundResource(R.drawable.mx_backward_icon);
556 | }
557 | }
558 |
559 | @Override
560 | protected void showVolumeDialog(float v, int volumePercent) {
561 | if (mVolumeDialog == null) {
562 | View localView = View.inflate(getContext(), R.layout.mx_mobile_volume_dialog, null);
563 | mDialogVolumeProgressBar = ((ProgressBar) localView.findViewById(R.id.volume_progressbar));
564 | mVolumeDialog = new Dialog(getContext(), R.style.mx_style_dialog_progress);
565 | mVolumeDialog.setContentView(localView);
566 | if (mVolumeDialog.getWindow() != null) {
567 | mVolumeDialog.getWindow().addFlags(8);
568 | mVolumeDialog.getWindow().addFlags(32);
569 | mVolumeDialog.getWindow().addFlags(16);
570 | mVolumeDialog.getWindow().setLayout(-2, -2);
571 | }
572 | WindowManager.LayoutParams params = mVolumeDialog.getWindow().getAttributes();
573 | params.gravity = 49;
574 | params.y = getContext().getResources()
575 | .getDimensionPixelOffset(R.dimen.mx_volume_dialog_margin_top);
576 | params.width = getContext().getResources()
577 | .getDimensionPixelOffset(R.dimen.mx_mobile_dialog_width);
578 | mVolumeDialog.getWindow().setAttributes(params);
579 | }
580 | if (!mVolumeDialog.isShowing()) {
581 | mVolumeDialog.show();
582 | }
583 | mDialogVolumeProgressBar.setProgress(volumePercent);
584 | }
585 |
586 | @Override
587 | protected void showBrightnessDialog(float v, int brightnessPercent) {
588 | if (mBrightnessDialog == null) {
589 | View localView = View.inflate(getContext(), R.layout.mx_mobile_brightness_dialog, null);
590 | mDialogBrightnessProgressBar = ((ProgressBar) localView.findViewById(R.id.brightness_progressbar));
591 | mBrightnessDialog = new Dialog(getContext(), R.style.mx_style_dialog_progress);
592 | mBrightnessDialog.setContentView(localView);
593 | if (mBrightnessDialog.getWindow() != null) {
594 | mBrightnessDialog.getWindow().addFlags(8);
595 | mBrightnessDialog.getWindow().addFlags(32);
596 | mBrightnessDialog.getWindow().addFlags(16);
597 | mBrightnessDialog.getWindow().setLayout(-2, -2);
598 | }
599 | WindowManager.LayoutParams params = mBrightnessDialog.getWindow().getAttributes();
600 | params.gravity = 49;
601 | params.y = getContext().getResources()
602 | .getDimensionPixelOffset(R.dimen.mx_volume_dialog_margin_top);
603 | params.width = getContext().getResources()
604 | .getDimensionPixelOffset(R.dimen.mx_mobile_dialog_width);
605 | mBrightnessDialog.getWindow().setAttributes(params);
606 | }
607 | if (!mBrightnessDialog.isShowing()) {
608 | mBrightnessDialog.show();
609 | }
610 | mDialogBrightnessProgressBar.setProgress(brightnessPercent);
611 | }
612 |
613 | @Override
614 | protected void dismissVolumeDialog() {
615 | if (mVolumeDialog != null) {
616 | mVolumeDialog.dismiss();
617 | }
618 | }
619 |
620 | @Override
621 | protected void dismissBrightnessDialog() {
622 | if (mBrightnessDialog != null) {
623 | mBrightnessDialog.dismiss();
624 | }
625 | }
626 |
627 | @Override
628 | protected void dismissProgressDialog() {
629 | if (mProgressDialog != null) {
630 | mProgressDialog.dismiss();
631 | }
632 | }
633 |
634 | private class DismissControlViewTimerTask extends TimerTask {
635 |
636 | @Override
637 | public void run() {
638 | if (mCurrentState != CURRENT_STATE_NORMAL
639 | && mCurrentState != CURRENT_STATE_ERROR
640 | && mCurrentState != CURRENT_STATE_AUTO_COMPLETE) {
641 | if (getContext() != null && getContext() instanceof Activity) {
642 | ((Activity) getContext()).runOnUiThread(new Runnable() {
643 | @Override
644 | public void run() {
645 | mBottomContainer.setVisibility(View.INVISIBLE);
646 | mTopContainer.setVisibility(View.INVISIBLE);
647 | mPlayControllerButton.setVisibility(View.INVISIBLE);
648 | if (mCurrentScreen != SCREEN_WINDOW_TINY && mIsShowBottomProgressBar) {
649 | mBottomProgressBar.setVisibility(View.VISIBLE);
650 | }
651 | }
652 | });
653 | }
654 | }
655 | }
656 | }
657 |
658 | public interface UIStatusChangeListener {
659 | void onUIChange(Mode mode);
660 | }
661 | }
662 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_back.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_backward_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_backward_icon.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_brightness_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_brightness_icon.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_enlarge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_enlarge.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_error_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_error_normal.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_error_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_error_pressed.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_forward_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_forward_icon.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_loading_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_loading_bg.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_pause_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_pause_normal.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_pause_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_pause_pressed.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_play_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_play_normal.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_play_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_play_pressed.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_quit_tiny_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_quit_tiny_normal.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_quit_tiny_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_quit_tiny_pressed.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_shrink.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_shrink.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_volume_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_volume_icon.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable-xhdpi/mx_volume_no.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henryblue/MxVideoPlayer/aedf4d32a988986d15c9516df6282005ff4a0c2f/xvideoplayer/src/main/res/drawable-xhdpi/mx_volume_no.png
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_bottom_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_bottom_progress.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 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_click_error_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_click_pause_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_click_play_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_click_quit_tiny_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_dialog_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_dialog_progress_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_seek_progress.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 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_seek_thumb.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_seek_thumb_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
11 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_seek_thumb_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_title_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/drawable/mx_volume_progress_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/layout/mx_mobile_brightness_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/layout/mx_mobile_volume_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/layout/mx_progress_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
24 |
25 |
31 |
32 |
38 |
39 |
40 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/layout/mx_tv_progress_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
15 |
16 |
25 |
26 |
32 |
33 |
39 |
40 |
41 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/layout/mx_tv_volume_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
18 |
19 |
31 |
32 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/layout/mx_video_layout_mobile.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
19 |
20 |
27 |
28 |
36 |
37 |
47 |
48 |
49 |
58 |
59 |
66 |
67 |
81 |
82 |
89 |
90 |
98 |
99 |
100 |
108 |
109 |
119 |
120 |
129 |
130 |
138 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/layout/mx_video_layout_tv.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
19 |
20 |
27 |
28 |
35 |
36 |
37 |
45 |
46 |
54 |
55 |
71 |
72 |
80 |
81 |
82 |
83 |
91 |
92 |
101 |
102 |
110 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/values-zh/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 您当前正在使用移动网络,继续播放将消耗流量
4 | 当前没有可用网络, 请检查网络重试
5 | 确定
6 | 继续播放
7 | 停止播放
8 | 播放地址无效
9 |
10 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ef6c00
4 | #ffe0e0e0
5 | #44000000
6 | #cc999999
7 |
8 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 80dp
3 | 80dp
4 | 40dp
5 | 16dp
6 | 16dp
7 | 2dp
8 | 8dp
9 | 16dp
10 | 23dp
11 | 23dp
12 | 6dp
13 | 6dp
14 | 48dp
15 | 48dp
16 | 48dp
17 | 10dp
18 | 18sp
19 | 60dp
20 | 60dp
21 | 60dp
22 | 60dp
23 |
24 | 175dp
25 | 36dp
26 | 25dp
27 | 16dp
28 | 10dp
29 | 14sp
30 | 4dp
31 | 16dp
32 | 16dp
33 | 16dp
34 | 8dp
35 |
36 | 24dp
37 | 24dp
38 | 16dp
39 | 16dp
40 |
41 | 220dp
42 | 100dp
43 |
44 | 65dp
45 | 18dp
46 | 22sp
47 | 90dp
48 | 90dp
49 | 90dp
50 | 90dp
51 | 235dp
52 | 140dp
53 | 22sp
54 | 35dp
55 | 35dp
56 | 18sp
57 | 4dp
58 |
59 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | You are currently using the mobile network, the player will continue to consume traffic
4 | There are currently no available network, check the network retry
5 | OK
6 | Resume
7 | Stop play
8 | No Play Url
9 | 00:00
10 | mx_img_content_dec
11 |
12 |
--------------------------------------------------------------------------------
/xvideoplayer/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
14 |
15 |
26 |
27 |
--------------------------------------------------------------------------------
/xvideoplayer/src/test/java/mxvideoplayer/app/com/xvideoplayer/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package mxvideoplayer.app.com.xvideoplayer;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------