├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── libraries
│ ├── appcompat_v7_23_1_1.xml
│ ├── exoplayer_r1_5_3.xml
│ ├── support_annotations_23_1_1.xml
│ └── support_v4_23_1_1.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
├── vcs.xml
└── workspace.xml
├── 01_basic_video_player
├── .gitignore
├── 01_basic_video_player.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── quan404
│ │ └── basic_video_player
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── quan404
│ │ │ └── basic_video_player
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── quan404
│ └── basic_video_player
│ └── ExampleUnitTest.java
├── 02_split_video_player
├── .gitignore
├── 02_split_video_player.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── quan404
│ │ └── split_video_player
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── quan404
│ │ │ └── split_video_player
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── quan404
│ └── split_video_player
│ └── ExampleUnitTest.java
├── 03_split_translation_video_player
├── .gitignore
├── 03_split_translation_video_player.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── quan404
│ │ └── split_translation_video_player
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── quan404
│ │ │ └── split_translation_video_player
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── quan404
│ └── split_translation_video_player
│ └── ExampleUnitTest.java
├── 04_basic_custom_exo_player
├── .gitignore
├── 04_basic_custom_exo_player.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── quan404
│ │ └── basic_custom_exo_player
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── quan404
│ │ │ └── basic_custom_exo_player
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── quan404
│ └── basic_custom_exo_player
│ └── ExampleUnitTest.java
├── 05_split_custom_exo_player
├── .gitignore
├── 05_split_custom_exo_player.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── quan404
│ │ └── split_custom_exo_player
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── quan404
│ │ │ └── split_custom_exo_player
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── quan404
│ └── split_custom_exo_player
│ └── ExampleUnitTest.java
├── GLMediaPlayer.iml
├── LICENSE
├── README.md
├── build.gradle
├── glmediaplayer
├── .gitignore
├── build.gradle
├── glmediaplayer.iml
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── quan404
│ │ └── glmediaplayer
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── quan404
│ │ │ └── glmediaplayer
│ │ │ ├── GLMediaPlayer.java
│ │ │ ├── config
│ │ │ └── LogConfig.java
│ │ │ ├── players
│ │ │ ├── AndroidPlayer.java
│ │ │ ├── BasePlayer.java
│ │ │ ├── CustomExoPlayer.java
│ │ │ └── exorenderers
│ │ │ │ └── TextureVideoTrackRenderer.java
│ │ │ ├── renderers
│ │ │ ├── BaseVideoRenderer.java
│ │ │ ├── DefaultVideoRenderer.java
│ │ │ ├── SplitSquareVideoRenderer.java
│ │ │ └── SplitVideoRenderer.java
│ │ │ └── views
│ │ │ └── VideoSurfaceView.java
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── quan404
│ └── glmediaplayer
│ └── ExampleUnitTest.java
├── gltoolkit
├── .gitignore
├── build.gradle
├── gltoolkit.iml
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── quan404
│ │ └── gltoolkit
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── quan404
│ │ │ └── gltoolkit
│ │ │ ├── Constants.java
│ │ │ ├── GLToolkit.java
│ │ │ ├── LoggerConfig.java
│ │ │ ├── ShaderHelper.java
│ │ │ ├── TextResourceReader.java
│ │ │ ├── TextureHelper.java
│ │ │ ├── data
│ │ │ └── VertexArray.java
│ │ │ ├── objects
│ │ │ └── Video.java
│ │ │ └── programs
│ │ │ ├── ColorShaderProgram.java
│ │ │ ├── ShaderProgram.java
│ │ │ ├── TextureShaderProgram.java
│ │ │ └── VideoShaderProgram.java
│ └── res
│ │ ├── raw
│ │ ├── default_fragment_shader.glsl
│ │ └── default_vertex_shader.glsl
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── quan404
│ └── gltoolkit
│ └── ExampleUnitTest.java
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
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 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | GLMediaPlayer
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/.idea/libraries/appcompat_v7_23_1_1.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 |
--------------------------------------------------------------------------------
/.idea/libraries/exoplayer_r1_5_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_annotations_23_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/support_v4_23_1_1.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 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 1.7
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/01_basic_video_player/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/01_basic_video_player/01_basic_video_player.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/01_basic_video_player/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.quan404.basic_video_player"
9 | minSdkVersion 16
10 | targetSdkVersion 23
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 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.1.1'
26 |
27 | compile project(":glmediaplayer")
28 | }
29 |
--------------------------------------------------------------------------------
/01_basic_video_player/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 /home/robotbase/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/01_basic_video_player/src/androidTest/java/com/quan404/basic_video_player/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.basic_video_player;
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 | }
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/java/com/quan404/basic_video_player/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.quan404.basic_video_player;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.WindowManager;
6 |
7 | import com.quan404.glmediaplayer.GLMediaPlayer;
8 | import com.quan404.glmediaplayer.views.VideoSurfaceView;
9 |
10 | public class MainActivity extends AppCompatActivity {
11 |
12 | private GLMediaPlayer glMediaPlayer = null;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 |
18 | glMediaPlayer = new GLMediaPlayer(this);
19 | try{
20 | glMediaPlayer.setDataSource("http://html5demos.com/assets/dizzy.mp4");
21 | // glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/teleport_22-11-2015_13-11-40__8kX6dwsyML.mp4");
22 | // glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/teleport_22-11-2015_14-00-08__8kX6dwsyML.mp4");
23 | }catch (Exception e){
24 | e.printStackTrace();
25 | }
26 |
27 | setContentView(glMediaPlayer.getVideoSurfaceView());
28 |
29 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
30 | }
31 |
32 | @Override
33 | protected void onResume() {
34 | super.onResume();
35 | if(glMediaPlayer != null){
36 | glMediaPlayer.resume();
37 | }
38 | }
39 |
40 | @Override
41 | protected void onPause() {
42 | super.onPause();
43 | if(glMediaPlayer != null){
44 | glMediaPlayer.pause();
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/01_basic_video_player/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/01_basic_video_player/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/01_basic_video_player/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/01_basic_video_player/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/01_basic_video_player/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 01_Basic_Video_Player
3 |
4 |
--------------------------------------------------------------------------------
/01_basic_video_player/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/01_basic_video_player/src/test/java/com/quan404/basic_video_player/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.basic_video_player;
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 | }
--------------------------------------------------------------------------------
/02_split_video_player/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/02_split_video_player/02_split_video_player.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/02_split_video_player/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.quan404.split_video_player"
9 | minSdkVersion 16
10 | targetSdkVersion 23
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 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.1.1'
26 |
27 | compile project(":glmediaplayer")
28 | }
29 |
--------------------------------------------------------------------------------
/02_split_video_player/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 /home/robotbase/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/02_split_video_player/src/androidTest/java/com/quan404/split_video_player/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.split_video_player;
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 | }
--------------------------------------------------------------------------------
/02_split_video_player/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/02_split_video_player/src/main/java/com/quan404/split_video_player/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.quan404.split_video_player;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | import com.quan404.glmediaplayer.GLMediaPlayer;
7 | import com.quan404.glmediaplayer.renderers.SplitVideoRenderer;
8 |
9 | public class MainActivity extends AppCompatActivity {
10 |
11 | private GLMediaPlayer glMediaPlayer = null;
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 |
17 | glMediaPlayer = new GLMediaPlayer(this, new SplitVideoRenderer(this), false);
18 | try{
19 | // glMediaPlayer.setDataSource("http://html5demos.com/assets/dizzy.mp4");
20 | // glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/teleport_22-11-2015_13-11-40__8kX6dwsyML.mp4");
21 | // glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/teleport_22-11-2015_13-22-00__8kX6dwsyML.mp4");
22 | glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/teleport_22-11-2015_14-00-08__8kX6dwsyML.mp4");
23 | // glMediaPlayer.setDataSource("http://storage.googleapis.com/exoplayer-test-media-1/mkv/android-screens-lavf-56.36.100-aac-avc-main-1280x720.mkv");
24 |
25 | // Emulator can only play 3GP files.
26 | // More files: http://download.wavetlan.com/SVV/Media/HTTP/http-3gp.htm
27 | // glMediaPlayer.setDataSource("http://download.wavetlan.com/SVV/Media/HTTP/3GP/QuickTime/Quicktime_test1_3GP2_H263_xbit_176x144_AR1.22_25fps_KF1in15_256kbps_AAC_Mono_48000Hz_96kbps.3g2");
28 | }catch (Exception e){
29 | e.printStackTrace();
30 | }
31 |
32 | setContentView(glMediaPlayer.getVideoSurfaceView());
33 | }
34 |
35 | @Override
36 | protected void onResume() {
37 | super.onResume();
38 | if(glMediaPlayer != null){
39 | glMediaPlayer.resume();
40 | }
41 | }
42 |
43 | @Override
44 | protected void onPause() {
45 | super.onPause();
46 | if(glMediaPlayer != null){
47 | glMediaPlayer.pause();
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/02_split_video_player/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/02_split_video_player/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/02_split_video_player/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/02_split_video_player/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/02_split_video_player/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/02_split_video_player/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/02_split_video_player/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/02_split_video_player/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/02_split_video_player/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/02_split_video_player/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/02_split_video_player/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/02_split_video_player/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/02_split_video_player/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/02_split_video_player/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/02_split_video_player/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 02_split_video_player
3 |
4 |
--------------------------------------------------------------------------------
/02_split_video_player/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/02_split_video_player/src/test/java/com/quan404/split_video_player/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.split_video_player;
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 | }
--------------------------------------------------------------------------------
/03_split_translation_video_player/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/03_split_translation_video_player/03_split_translation_video_player.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/03_split_translation_video_player/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.quan404.split_translation_video_player"
9 | minSdkVersion 16
10 | targetSdkVersion 23
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 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.1.1'
26 |
27 | compile project(":glmediaplayer")
28 | }
29 |
--------------------------------------------------------------------------------
/03_split_translation_video_player/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 /home/robotbase/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/androidTest/java/com/quan404/split_translation_video_player/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.split_translation_video_player;
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 | }
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/java/com/quan404/split_translation_video_player/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.quan404.split_translation_video_player;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.MotionEvent;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.view.WindowManager;
10 | import android.widget.Button;
11 |
12 | import com.google.android.exoplayer.ExoPlaybackException;
13 | import com.google.android.exoplayer.ExoPlayer;
14 | import com.quan404.glmediaplayer.GLMediaPlayer;
15 | import com.quan404.glmediaplayer.players.CustomExoPlayer;
16 | import com.quan404.glmediaplayer.renderers.SplitSquareVideoRenderer;
17 | import com.quan404.glmediaplayer.renderers.SplitVideoRenderer;
18 |
19 | public class MainActivity extends Activity {
20 |
21 | private ViewGroup videoLayout;
22 | private GLMediaPlayer glMediaPlayer = null;
23 |
24 | private SplitSquareVideoRenderer renderer;
25 | private CustomExoPlayer mediaPlayer;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_main);
31 | makeImmersive();
32 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
33 | videoLayout = (ViewGroup) findViewById(R.id.video);
34 |
35 | renderer = new SplitSquareVideoRenderer(this);
36 | glMediaPlayer = new GLMediaPlayer(this, renderer, true);
37 | mediaPlayer = (CustomExoPlayer) glMediaPlayer.getMediaPlayer();
38 | mediaPlayer.addListener(new ExoPlayer.Listener() {
39 | @Override
40 | public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
41 | Log.d("Test", "playWhenReady: " + playWhenReady + "/playbackState: " + playbackState);
42 | }
43 |
44 | @Override
45 | public void onPlayWhenReadyCommitted() {
46 | Log.d("Test", "onPlayWhenReadyCommitted");
47 | }
48 |
49 | @Override
50 | public void onPlayerError(ExoPlaybackException error) {
51 | Log.d("Test", "onPlayerError");
52 |
53 | }
54 | });
55 | try{
56 | // glMediaPlayer.setDataSource("http://html5demos.com/assets/dizzy.mp4");
57 | // glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/teleport_22-11-2015_13-11-40__8kX6dwsyML.mp4");
58 | // glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/teleport_22-11-2015_13-22-00__8kX6dwsyML.mp4");
59 | glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/dinosaur-and-drone_8kX6dwsyML.mp4");
60 | // glMediaPlayer.setDataSource("http://storage.googleapis.com/exoplayer-test-media-1/mkv/android-screens-lavf-56.36.100-aac-avc-main-1280x720.mkv");
61 |
62 | // Emulator can only play 3GP files.
63 | // More files: http://download.wavetlan.com/SVV/Media/HTTP/http-3gp.htm
64 | // glMediaPlayer.setDataSource("http://download.wavetlan.com/SVV/Media/HTTP/3GP/QuickTime/Quicktime_test1_3GP2_H263_xbit_176x144_AR1.22_25fps_KF1in15_256kbps_AAC_Mono_48000Hz_96kbps.3g2");
65 | }catch (Exception e){
66 | e.printStackTrace();
67 | }
68 |
69 | videoLayout.addView(glMediaPlayer.getVideoSurfaceView());
70 |
71 | findViewById(R.id.left).setOnClickListener(leftButtonOnClick);
72 | findViewById(R.id.right).setOnClickListener(rightButtonOnClick);
73 | findViewById(R.id.btnResume).setOnClickListener(new View.OnClickListener() {
74 | @Override
75 | public void onClick(View view) {
76 | mediaPlayer.resume();
77 | }
78 | });
79 | findViewById(R.id.btnPause).setOnClickListener(new View.OnClickListener() {
80 | @Override
81 | public void onClick(View view) {
82 | mediaPlayer.pause();
83 | }
84 | });
85 |
86 | }
87 |
88 | View.OnClickListener leftButtonOnClick = new View.OnClickListener() {
89 | @Override
90 | public void onClick(View view) {
91 | renderer.adjustLeftPosition(-0.01f);
92 | }
93 | };
94 | View.OnClickListener rightButtonOnClick = new View.OnClickListener() {
95 | @Override
96 | public void onClick(View view) {
97 | renderer.adjustLeftPosition(0.01f);
98 | }
99 | };
100 | private void makeImmersive() {
101 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
102 | getWindow().getDecorView().setSystemUiVisibility(
103 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
104 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
105 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
106 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
107 | | View.SYSTEM_UI_FLAG_FULLSCREEN
108 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
109 | }
110 | }
111 |
112 | @Override
113 | protected void onResume() {
114 | super.onResume();
115 | if(glMediaPlayer != null){
116 | glMediaPlayer.resume();
117 | }
118 | }
119 |
120 | @Override
121 | protected void onPause() {
122 | super.onPause();
123 | if(glMediaPlayer != null){
124 | glMediaPlayer.pause();
125 | }
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
21 |
26 |
27 |
32 |
33 |
38 |
39 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/03_split_translation_video_player/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/03_split_translation_video_player/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/03_split_translation_video_player/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/03_split_translation_video_player/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/03_split_translation_video_player/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 03_Split_Translation_Video_Player
3 |
4 |
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/03_split_translation_video_player/src/test/java/com/quan404/split_translation_video_player/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.split_translation_video_player;
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 | }
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/04_basic_custom_exo_player.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.quan404.basic_custom_exo_player"
9 | minSdkVersion 16
10 | targetSdkVersion 23
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 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.1.1'
26 |
27 | compile project(":glmediaplayer")
28 | }
29 |
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/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 /home/robotbase/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/androidTest/java/com/quan404/basic_custom_exo_player/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.basic_custom_exo_player;
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 | }
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/java/com/quan404/basic_custom_exo_player/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.quan404.basic_custom_exo_player;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.WindowManager;
6 |
7 | import com.quan404.glmediaplayer.GLMediaPlayer;
8 |
9 | public class MainActivity extends AppCompatActivity {
10 |
11 | private GLMediaPlayer glMediaPlayer = null;
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 |
17 | glMediaPlayer = new GLMediaPlayer(this, true);
18 | try{
19 | // glMediaPlayer.setDataSource("http://html5demos.com/assets/dizzy.mp4");
20 | glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/teleport_22-11-2015_13-11-40__8kX6dwsyML.mp4");
21 | // glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/teleport_22-11-2015_14-00-08__8kX6dwsyML.mp4");
22 | // glMediaPlayer.setDataSource("http://storage.googleapis.com/exoplayer-test-media-1/mkv/android-screens-lavf-56.36.100-aac-avc-main-1280x720.mkv");
23 | }catch (Exception e){
24 | e.printStackTrace();
25 | }
26 |
27 | setContentView(glMediaPlayer.getVideoSurfaceView());
28 |
29 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
30 | }
31 |
32 | @Override
33 | protected void onResume() {
34 | super.onResume();
35 | if(glMediaPlayer != null){
36 | glMediaPlayer.resume();
37 | }
38 | }
39 |
40 | @Override
41 | protected void onPause() {
42 | super.onPause();
43 | if(glMediaPlayer != null){
44 | glMediaPlayer.pause();
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/04_basic_custom_exo_player/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/04_basic_custom_exo_player/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/04_basic_custom_exo_player/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/04_basic_custom_exo_player/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/04_basic_custom_exo_player/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 04_basic_custom_exo_player
3 |
4 |
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/04_basic_custom_exo_player/src/test/java/com/quan404/basic_custom_exo_player/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.basic_custom_exo_player;
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 | }
--------------------------------------------------------------------------------
/05_split_custom_exo_player/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/05_split_custom_exo_player/05_split_custom_exo_player.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/05_split_custom_exo_player/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.quan404.split_custom_exo_player"
9 | minSdkVersion 16
10 | targetSdkVersion 23
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 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.1.1'
26 |
27 | compile project(":glmediaplayer")
28 | }
29 |
--------------------------------------------------------------------------------
/05_split_custom_exo_player/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 /home/robotbase/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/androidTest/java/com/quan404/split_custom_exo_player/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.split_custom_exo_player;
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 | }
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/java/com/quan404/split_custom_exo_player/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.quan404.split_custom_exo_player;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | import com.quan404.glmediaplayer.GLMediaPlayer;
7 | import com.quan404.glmediaplayer.renderers.SplitSquareVideoRenderer;
8 | import com.quan404.glmediaplayer.renderers.SplitVideoRenderer;
9 |
10 | public class MainActivity extends AppCompatActivity {
11 |
12 | private GLMediaPlayer glMediaPlayer = null;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 |
18 | glMediaPlayer = new GLMediaPlayer(this, new SplitVideoRenderer(this), true);
19 | try{
20 | // glMediaPlayer.setDataSource("http://html5demos.com/assets/dizzy.mp4");
21 | // glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/teleport_22-11-2015_13-11-40__8kX6dwsyML.mp4");
22 | // glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/teleport_22-11-2015_13-22-00__8kX6dwsyML.mp4");
23 | glMediaPlayer.setDataSource("http://d2kzl73ve6fjh6.cloudfront.net/videos/teleport_22-11-2015_14-00-08__8kX6dwsyML.mp4");
24 | // glMediaPlayer.setDataSource("http://storage.googleapis.com/exoplayer-test-media-1/mkv/android-screens-lavf-56.36.100-aac-avc-main-1280x720.mkv");
25 |
26 | // Emulator can only play 3GP files.
27 | // More files: http://download.wavetlan.com/SVV/Media/HTTP/http-3gp.htm
28 | // glMediaPlayer.setDataSource("http://download.wavetlan.com/SVV/Media/HTTP/3GP/QuickTime/Quicktime_test1_3GP2_H263_xbit_176x144_AR1.22_25fps_KF1in15_256kbps_AAC_Mono_48000Hz_96kbps.3g2");
29 | }catch (Exception e){
30 | e.printStackTrace();
31 | }
32 |
33 | setContentView(glMediaPlayer.getVideoSurfaceView());
34 | }
35 |
36 | @Override
37 | protected void onResume() {
38 | super.onResume();
39 | if(glMediaPlayer != null){
40 | glMediaPlayer.resume();
41 | }
42 | }
43 |
44 | @Override
45 | protected void onPause() {
46 | super.onPause();
47 | if(glMediaPlayer != null){
48 | glMediaPlayer.pause();
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/05_split_custom_exo_player/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/05_split_custom_exo_player/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/05_split_custom_exo_player/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/05_split_custom_exo_player/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/05_split_custom_exo_player/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 05_split_custom_exo_player
3 |
4 |
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/05_split_custom_exo_player/src/test/java/com/quan404/split_custom_exo_player/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.split_custom_exo_player;
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 | }
--------------------------------------------------------------------------------
/GLMediaPlayer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/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 |
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GLMediaPlayer
2 | Android media player using GLSurfaceView
3 |
--------------------------------------------------------------------------------
/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 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.5.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/glmediaplayer/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/glmediaplayer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 16
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | testCompile 'junit:junit:4.12'
24 | compile 'com.android.support:appcompat-v7:23.1.1'
25 |
26 | compile project(":gltoolkit")
27 | compile 'com.google.android.exoplayer:exoplayer:r1.5.3'
28 | }
--------------------------------------------------------------------------------
/glmediaplayer/glmediaplayer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/glmediaplayer/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 /home/robotbase/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/glmediaplayer/src/androidTest/java/com/quan404/glmediaplayer/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.glmediaplayer;
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 | }
--------------------------------------------------------------------------------
/glmediaplayer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/glmediaplayer/src/main/java/com/quan404/glmediaplayer/GLMediaPlayer.java:
--------------------------------------------------------------------------------
1 | package com.quan404.glmediaplayer;
2 |
3 | import android.content.Context;
4 | import android.media.MediaPlayer;
5 | import android.util.Log;
6 | import android.view.Surface;
7 |
8 | import com.google.android.exoplayer.ExoPlayer;
9 | import com.quan404.glmediaplayer.config.LogConfig;
10 | import com.quan404.glmediaplayer.players.AndroidPlayer;
11 | import com.quan404.glmediaplayer.players.BasePlayer;
12 | import com.quan404.glmediaplayer.players.CustomExoPlayer;
13 | import com.quan404.glmediaplayer.renderers.BaseVideoRenderer;
14 | import com.quan404.glmediaplayer.renderers.DefaultVideoRenderer;
15 | import com.quan404.glmediaplayer.views.VideoSurfaceView;
16 |
17 | import java.io.IOException;
18 |
19 | /**
20 | * Created by quanhua on 06/01/2016.
21 | */
22 | public class GLMediaPlayer {
23 | private final static String TAG = "GLMediaPlayer";
24 | private BasePlayer mediaPlayer = null;
25 | private Context context = null;
26 | private VideoSurfaceView mVideoView;
27 |
28 | //=================== + Constructors + ===================
29 | public GLMediaPlayer(Context context) {
30 | this(context, false);
31 | }
32 | public GLMediaPlayer(Context context, boolean useExoPlayer) {
33 | this(context, new DefaultVideoRenderer(context), useExoPlayer);
34 | }
35 |
36 | public GLMediaPlayer(Context context, BaseVideoRenderer renderer, boolean useExoPlayer) {
37 | if(renderer == null) {
38 | if(LogConfig.ON){
39 | Log.e(TAG, "Renderer is null");
40 | }
41 | return;
42 | }
43 | if(useExoPlayer){
44 | this.mediaPlayer = new CustomExoPlayer(context);
45 | }else{
46 | this.mediaPlayer = new AndroidPlayer();
47 | }
48 |
49 | this.context = context;
50 | this.mVideoView = new VideoSurfaceView(context, renderer);
51 | renderer.setGlMediaPlayer(this);
52 | }
53 |
54 | //=================== + Getter + ===================
55 |
56 | public VideoSurfaceView getVideoSurfaceView(){
57 | return mVideoView;
58 | }
59 |
60 | //=================== + Setter + ===================
61 | public void setDataSource(String dataSource) {
62 | if (mediaPlayer != null){
63 | try {
64 | mediaPlayer.setDataSource(dataSource);
65 | } catch (IOException e) {
66 | e.printStackTrace();
67 | }
68 | }else {
69 | if(LogConfig.ON){
70 | Log.e(TAG, "setDataSource: mediaPlayer == null");
71 | }
72 | }
73 | }
74 |
75 | public void pause(){
76 | if(LogConfig.ON){
77 | Log.d(TAG, "pause()");
78 | }
79 |
80 | if(mediaPlayer.isPlaying()){
81 | mediaPlayer.pause();
82 | }
83 | }
84 |
85 | public void resume(){
86 | if(LogConfig.ON){
87 | Log.d(TAG, "resume()");
88 | }
89 | // TODO: Resume player
90 |
91 | if(mVideoView != null){
92 | if( mVideoView.getRenderer().isReady()){
93 | if(mediaPlayer instanceof CustomExoPlayer) {
94 | CustomExoPlayer exoPlayer = (CustomExoPlayer) this.mediaPlayer;
95 | exoPlayer.resume();
96 | } else {
97 | this.mediaPlayer.start();
98 | }
99 | }
100 | }
101 | }
102 |
103 | public void setSurface(Surface surface) {
104 | this.mediaPlayer.setSurface(surface);
105 | }
106 |
107 | public void prepare() {
108 | try{
109 | this.mediaPlayer.prepare();
110 | }catch (Exception e){
111 | e.printStackTrace();
112 | }
113 | }
114 |
115 | public void start() {
116 | try{
117 | this.mediaPlayer.start();
118 | }catch (Exception e){
119 | e.printStackTrace();
120 | }
121 | }
122 | public void setOnVideoSizeChangedListener(BasePlayer.OnVideoSizeChangedListener listener){
123 | this.mediaPlayer.setOnVideoSizeChangedListener(listener);
124 | }
125 |
126 | public BasePlayer getMediaPlayer() {
127 | return mediaPlayer;
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/glmediaplayer/src/main/java/com/quan404/glmediaplayer/config/LogConfig.java:
--------------------------------------------------------------------------------
1 | package com.quan404.glmediaplayer.config;
2 |
3 | /**
4 | * Created by quanhua on 06/01/2016.
5 | */
6 | public class LogConfig {
7 | public static final boolean ON = true;
8 | }
9 |
--------------------------------------------------------------------------------
/glmediaplayer/src/main/java/com/quan404/glmediaplayer/players/AndroidPlayer.java:
--------------------------------------------------------------------------------
1 | package com.quan404.glmediaplayer.players;
2 |
3 | import android.media.MediaPlayer;
4 | import android.view.Surface;
5 |
6 | import java.io.IOException;
7 |
8 | /**
9 | * Created by quanhua on 08/01/2016.
10 | */
11 | public class AndroidPlayer implements BasePlayer, MediaPlayer.OnVideoSizeChangedListener {
12 | private MediaPlayer mediaPlayer = new MediaPlayer();
13 | private BasePlayer.OnVideoSizeChangedListener listener;
14 | @Override
15 | public void setDataSource(String dataSource) throws IOException {
16 | mediaPlayer.setDataSource(dataSource);
17 | }
18 |
19 | @Override
20 | public boolean isPlaying() {
21 | return mediaPlayer.isPlaying();
22 | }
23 |
24 | @Override
25 | public void pause() {
26 | mediaPlayer.pause();
27 | }
28 |
29 | @Override
30 | public void start() {
31 | mediaPlayer.start();
32 | }
33 |
34 | @Override
35 | public void setSurface(Surface surface) {
36 | mediaPlayer.setSurface(surface);
37 | }
38 |
39 | @Override
40 | public void prepare() throws Exception {
41 | mediaPlayer.prepare();
42 | }
43 |
44 | @Override
45 | public void setOnVideoSizeChangedListener(OnVideoSizeChangedListener listener) {
46 | this.listener = listener;
47 | mediaPlayer.setOnVideoSizeChangedListener(this);
48 | }
49 |
50 | @Override
51 | public void onVideoSizeChanged(MediaPlayer mediaPlayer, int width, int height) {
52 | this.listener.onVideoSizeChanged(width, height);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/glmediaplayer/src/main/java/com/quan404/glmediaplayer/players/BasePlayer.java:
--------------------------------------------------------------------------------
1 | package com.quan404.glmediaplayer.players;
2 |
3 | import android.media.MediaPlayer;
4 | import android.view.Surface;
5 |
6 | import java.io.IOException;
7 |
8 | /**
9 | * Created by quanhua on 08/01/2016.
10 | */
11 | public interface BasePlayer {
12 | void setDataSource(String dataSource) throws IOException;
13 |
14 | boolean isPlaying();
15 |
16 | void pause();
17 |
18 | void start();
19 |
20 | void setSurface(Surface surface);
21 |
22 | void prepare() throws Exception;
23 |
24 | void setOnVideoSizeChangedListener(OnVideoSizeChangedListener listener);
25 |
26 | interface OnVideoSizeChangedListener{
27 | void onVideoSizeChanged(int width, int height);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/glmediaplayer/src/main/java/com/quan404/glmediaplayer/players/CustomExoPlayer.java:
--------------------------------------------------------------------------------
1 | package com.quan404.glmediaplayer.players;
2 |
3 | import com.google.android.exoplayer.DummyTrackRenderer;
4 | import com.google.android.exoplayer.ExoPlaybackException;
5 | import com.google.android.exoplayer.ExoPlayer;
6 | import com.google.android.exoplayer.MediaCodecAudioTrackRenderer;
7 | import com.google.android.exoplayer.MediaCodecTrackRenderer;
8 | import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
9 | import com.google.android.exoplayer.TrackRenderer;
10 | import com.google.android.exoplayer.audio.AudioCapabilities;
11 | import com.google.android.exoplayer.audio.AudioTrack;
12 | import com.google.android.exoplayer.extractor.ExtractorSampleSource;
13 | import com.google.android.exoplayer.upstream.Allocator;
14 | import com.google.android.exoplayer.upstream.BandwidthMeter;
15 | import com.google.android.exoplayer.upstream.DataSource;
16 | import com.google.android.exoplayer.upstream.DefaultAllocator;
17 | import com.google.android.exoplayer.upstream.DefaultBandwidthMeter;
18 | import com.google.android.exoplayer.upstream.DefaultUriDataSource;
19 | import com.google.android.exoplayer.util.Util;
20 | import com.quan404.glmediaplayer.config.LogConfig;
21 | import com.quan404.glmediaplayer.players.exorenderers.TextureVideoTrackRenderer;
22 |
23 | import android.content.Context;
24 | import android.media.MediaCodec;
25 | import android.media.MediaPlayer;
26 | import android.media.session.MediaController;
27 | import android.media.session.PlaybackState;
28 | import android.net.Uri;
29 | import android.os.Handler;
30 | import android.os.Looper;
31 | import android.util.Log;
32 | import android.view.Surface;
33 |
34 | import java.io.IOException;
35 |
36 | /**
37 | * Created by quanhua on 08/01/2016.
38 | */
39 | public class CustomExoPlayer implements BasePlayer, TextureVideoTrackRenderer.EventListener, MediaCodecAudioTrackRenderer.EventListener {
40 | private static final String TAG = "CustomExoPlayer";
41 | private ExoPlayer player;
42 | private TrackRenderer videoRenderer;
43 | private Handler mainHandler;
44 | private Context context;
45 | private String userAgent;
46 | private String dataPath;
47 | private Surface surface;
48 | private static final int BUFFER_SEGMENT_SIZE = 64 * 1024;
49 | private static final int BUFFER_SEGMENT_COUNT = 256;
50 | public static final int RENDERER_COUNT = 2;
51 | public static final int TYPE_VIDEO = 0;
52 | public static final int TYPE_AUDIO = 1;
53 |
54 | private BasePlayer.OnVideoSizeChangedListener listener;
55 |
56 | public CustomExoPlayer(Context context) {
57 | this.context = context;
58 | this.mainHandler = new Handler(Looper.getMainLooper());
59 | this.userAgent = Util.getUserAgent(context, "ExoPlayerDemo");
60 |
61 | // 1. Instantiate the player.
62 | player = ExoPlayer.Factory.newInstance(2);
63 | // // 2. Construct renderers.
64 | // MediaCodecVideoTrackRenderer videoRenderer = ...
65 | // MediaCodecAudioTrackRenderer audioRenderer = ...
66 | // // 3. Inject the renderers through prepare.
67 | // player.prepare(videoRenderer, audioRenderer);
68 | // // 4. Pass the surface to the video renderer.
69 | // player.sendMessage(videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface);
70 | // // 5. Start playback.
71 | // player.setPlayWhenReady(true);
72 | }
73 |
74 | @Override
75 | public void setDataSource(String dataPath) throws IOException {
76 | this.dataPath = dataPath;
77 | }
78 |
79 | @Override
80 | public boolean isPlaying() {
81 | return this.player.getPlayWhenReady();
82 | }
83 |
84 | @Override
85 | public void pause() {
86 | this.player.setPlayWhenReady(false);
87 | }
88 |
89 | public void stop() {
90 | this.player.stop();
91 | this.player.release();
92 | }
93 |
94 | @Override
95 | public void start() {
96 | preparePlayer(true);
97 | }
98 |
99 | public void seekTo(long position) {
100 | this.player.seekTo(position);
101 | }
102 |
103 | public long getCurrentPosition() {
104 | return this.player.getCurrentPosition();
105 | }
106 |
107 | public void resume() {
108 | this.player.setPlayWhenReady(true);
109 | }
110 |
111 | @Override
112 | public void setSurface(Surface surface) {
113 | if (LogConfig.ON) {
114 | Log.d(TAG, "setSurface " + surface);
115 | }
116 | this.surface = surface;
117 | }
118 |
119 | @Override
120 | public void prepare() throws Exception {
121 | preparePlayer(true);
122 | }
123 |
124 | private void preparePlayer(boolean playWhenReady) {
125 | Uri uri = Uri.parse(dataPath);
126 | Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
127 | // Build the video and audio renderers.
128 | DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(getMainHandler(), null);
129 | DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
130 | ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
131 | BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, null);
132 |
133 |
134 | TextureVideoTrackRenderer videoRenderer = new TextureVideoTrackRenderer(context, sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000
135 | , null, true, getMainHandler(), this, 50);
136 |
137 | MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
138 | null, true, getMainHandler(), this, AudioCapabilities.getCapabilities(context));
139 |
140 | // Invoke the callback.
141 | TrackRenderer[] renderers = new TrackRenderer[RENDERER_COUNT];
142 | renderers[TYPE_VIDEO] = videoRenderer;
143 | renderers[TYPE_AUDIO] = audioRenderer;
144 |
145 | player.sendMessage(
146 | videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface);
147 | Log.e(TAG, "after send Message");
148 | // onRenderers(renderers, bandwidthMeter);
149 | player.prepare(renderers);
150 | player.setPlayWhenReady(playWhenReady);
151 | }
152 |
153 | @Override
154 | public void setOnVideoSizeChangedListener(BasePlayer.OnVideoSizeChangedListener listener) {
155 | this.listener = listener;
156 | }
157 |
158 | public void addListener(ExoPlayer.Listener listener) {
159 | player.addListener(listener);
160 | }
161 |
162 | public Handler getMainHandler() {
163 | return mainHandler;
164 | }
165 |
166 | @Override
167 | public void onDroppedFrames(int count, long elapsed) {
168 |
169 | }
170 |
171 | @Override
172 | public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
173 | if (LogConfig.ON) {
174 | Log.d(TAG, "onVideoSizeChanged : " + width + " " + height);
175 | }
176 | listener.onVideoSizeChanged(width, height);
177 | }
178 |
179 | @Override
180 | public void onDrawnToSurface(Surface surface) {
181 | if (LogConfig.ON) {
182 | Log.d(TAG, "onDrawnToSurface : " + surface);
183 | }
184 | }
185 |
186 | @Override
187 | public void onDecoderInitializationError(MediaCodecTrackRenderer.DecoderInitializationException e) {
188 |
189 | }
190 |
191 | @Override
192 | public void onCryptoError(MediaCodec.CryptoException e) {
193 |
194 | }
195 |
196 | @Override
197 | public void onDecoderInitialized(String decoderName, long elapsedRealtimeMs, long initializationDurationMs) {
198 |
199 | }
200 |
201 | @Override
202 | public void onAudioTrackInitializationError(AudioTrack.InitializationException e) {
203 |
204 | }
205 |
206 | @Override
207 | public void onAudioTrackWriteError(AudioTrack.WriteException e) {
208 |
209 | }
210 |
211 | @Override
212 | public void onAudioTrackUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {
213 |
214 | }
215 |
216 | public void onRenderers(TrackRenderer[] renderers, BandwidthMeter bandwidthMeter) {
217 | for (int i = 0; i < RENDERER_COUNT; i++) {
218 | if (renderers[i] == null) {
219 | Log.e(TAG, "onRenderers dummy " + i);
220 | // Convert a null renderer to a dummy renderer.
221 | renderers[i] = new DummyTrackRenderer();
222 | }
223 | }
224 | // Complete preparation.
225 | this.videoRenderer = renderers[TYPE_VIDEO];
226 | pushSurface(false);
227 | player.prepare(renderers);
228 | }
229 |
230 | private void pushSurface(boolean blockForSurfacePush) {
231 | Log.e(TAG, "pushSurface " + blockForSurfacePush);
232 | if (videoRenderer == null) {
233 | Log.e(TAG, "pushSurface (videoRenderer == null)");
234 | return;
235 | }
236 | if (surface == null) {
237 | Log.e(TAG, "pushSurface (surface == null)");
238 | return;
239 | }
240 |
241 | Log.e(TAG, "pushSurface " + blockForSurfacePush + " to " + videoRenderer);
242 | if (blockForSurfacePush) {
243 | player.blockingSendMessage(
244 | videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface);
245 | } else {
246 | player.sendMessage(
247 | videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface);
248 | }
249 | }
250 | }
251 |
--------------------------------------------------------------------------------
/glmediaplayer/src/main/java/com/quan404/glmediaplayer/renderers/BaseVideoRenderer.java:
--------------------------------------------------------------------------------
1 | package com.quan404.glmediaplayer.renderers;
2 |
3 | import android.content.Context;
4 | import android.graphics.SurfaceTexture;
5 | import android.media.MediaPlayer;
6 | import android.opengl.GLES20;
7 | import android.opengl.GLSurfaceView;
8 | import android.opengl.Matrix;
9 | import android.util.Log;
10 | import android.view.Surface;
11 |
12 | import com.quan404.glmediaplayer.GLMediaPlayer;
13 | import com.quan404.glmediaplayer.config.LogConfig;
14 | import com.quan404.glmediaplayer.players.BasePlayer;
15 | import com.quan404.gltoolkit.programs.VideoShaderProgram;
16 |
17 | import javax.microedition.khronos.egl.EGLConfig;
18 | import javax.microedition.khronos.opengles.GL10;
19 |
20 | /**
21 | * Created by quanhua on 06/01/2016.
22 | */
23 | public class BaseVideoRenderer implements GLSurfaceView.Renderer, SurfaceTexture.OnFrameAvailableListener, BasePlayer.OnVideoSizeChangedListener {
24 |
25 | private static String TAG = "BaseVideoRenderer";
26 | private GLMediaPlayer glMediaPlayer;
27 | private boolean MEDIA_PLAYER_READY = false;
28 | private static int GL_TEXTURE_EXTERNAL_OES = 0x8D65;
29 |
30 | // Properties
31 | protected Context context;
32 | protected VideoShaderProgram videoShaderProgram;
33 | private int mTextureID;
34 | private SurfaceTexture mSurface;
35 | private boolean updateSurface = false;
36 |
37 | protected float curHeight = 1.0f;
38 | protected int VIDEO_WIDTH = -1;
39 | protected int VIDEO_HEIGHT = -1;
40 | protected int SURFACE_WIDTH = -1;
41 | protected int SURFACE_HEIGHT = -1;
42 |
43 | // Renderer Properties
44 | private float[] mMVPMatrix = new float[16];
45 | private float[] mSTMatrix = new float[16];
46 |
47 | protected float[] VERTEX_DATA = {
48 | // X, Y, Z, U, V
49 | -1.0f, -1.0f, 0, 0.f, 0.f,
50 | 1.0f, -1.0f, 0, 1f, 0.f,
51 | -1.0f, 1.0f, 0, 0.f, 1.f,
52 | 1.0f, 1.0f, 0, 1f, 1.f,
53 | };
54 |
55 | public BaseVideoRenderer(Context context) {
56 | this.context = context;
57 | }
58 | public void setGlMediaPlayer(GLMediaPlayer player){
59 | if (LogConfig.ON) {
60 | Log.d(TAG, "setGlMediaPlayer");
61 | }
62 | this.glMediaPlayer = player;
63 | }
64 |
65 | @Override
66 | synchronized public void onFrameAvailable(SurfaceTexture surfaceTexture) {
67 | updateSurface = true;
68 | }
69 |
70 | @Override
71 | public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) {
72 | if (LogConfig.ON) {
73 | Log.d(TAG, "onSurfaceCreated");
74 | }
75 |
76 | videoShaderProgram = new VideoShaderProgram(
77 | context,
78 | VideoShaderProgram.DEFAULT_VERTEX_SHADER,
79 | VideoShaderProgram.DEFAULT_FRAGMENT_SHADER);
80 |
81 | int[] textures = new int[1];
82 | GLES20.glGenTextures(1, textures, 0);
83 | mTextureID = textures[0];
84 | GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureID);
85 |
86 | GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
87 | GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
88 |
89 | // Create SurfaceTexture that will feed this textureId and pass to MediaPlayer
90 | mSurface = new SurfaceTexture(mTextureID);
91 | mSurface.setOnFrameAvailableListener(this);
92 |
93 | Surface surface = new Surface(mSurface);
94 | glMediaPlayer.setSurface(surface);
95 | // surface.release();
96 | glMediaPlayer.prepare();
97 | glMediaPlayer.setOnVideoSizeChangedListener(this);
98 |
99 | synchronized (this){
100 | updateSurface = false;
101 | }
102 | MEDIA_PLAYER_READY = true;
103 | glMediaPlayer.start();
104 | }
105 |
106 | @Override
107 | public void onSurfaceChanged(GL10 gl10, int width, int height) {
108 | if (LogConfig.ON) {
109 | Log.d(TAG, "onSurfaceChanged : width " + width + " height " + height);
110 | }
111 |
112 | SURFACE_WIDTH = width;
113 | SURFACE_HEIGHT = height;
114 |
115 | // Set the OpenGL viewport to file the entire surface
116 | GLES20.glViewport(0, 0, width, height);
117 | Matrix.setIdentityM(mMVPMatrix, 0);
118 |
119 | updateWidthHeight();
120 | }
121 |
122 | @Override
123 | public void onDrawFrame(GL10 gl10) {
124 | synchronized (this) {
125 | if(updateSurface){
126 | mSurface.updateTexImage();
127 | mSurface.getTransformMatrix(mSTMatrix);
128 | updateSurface = false;
129 | }
130 | }
131 |
132 | GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
133 | GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
134 |
135 | videoShaderProgram.useProgram();
136 | videoShaderProgram.setUniforms(mMVPMatrix, mSTMatrix);
137 | }
138 |
139 | @Override
140 | public void onVideoSizeChanged(int width, int height) {
141 | VIDEO_WIDTH = width;
142 | VIDEO_HEIGHT = height;
143 |
144 | updateWidthHeight();
145 | }
146 |
147 | protected void updateWidthHeight(){
148 | if (SURFACE_HEIGHT > 0 && VIDEO_HEIGHT > 0) {
149 |
150 | float HEIGHT_IN_PX = VIDEO_HEIGHT * SURFACE_WIDTH / VIDEO_WIDTH;
151 | curHeight = HEIGHT_IN_PX * 2.0f / SURFACE_HEIGHT * 1.0f;
152 |
153 | updateVertexArray();
154 | }
155 | }
156 |
157 | protected void updateVertexArray(){
158 | float[] NEW_VERTEX_DATA = {
159 | // X, Y, Z, U, V
160 | -1.0f, -curHeight / 2 , 0, 0.f, 0.f,
161 | 1.0f, -curHeight / 2, 0, 1f, 0.f,
162 | -1.0f, curHeight / 2, 0, 0.f, 1.f,
163 | 1.0f, curHeight / 2, 0, 1f, 1.f,
164 | };
165 | System.arraycopy(NEW_VERTEX_DATA, 0 , VERTEX_DATA, 0, NEW_VERTEX_DATA.length );
166 | }
167 |
168 | public boolean isReady(){
169 | return MEDIA_PLAYER_READY;
170 | }
171 | }
--------------------------------------------------------------------------------
/glmediaplayer/src/main/java/com/quan404/glmediaplayer/renderers/DefaultVideoRenderer.java:
--------------------------------------------------------------------------------
1 | package com.quan404.glmediaplayer.renderers;
2 |
3 | import android.content.Context;
4 | import android.graphics.SurfaceTexture;
5 | import android.opengl.GLES20;
6 | import android.opengl.GLSurfaceView;
7 | import android.opengl.Matrix;
8 | import android.util.Log;
9 | import android.view.Surface;
10 |
11 | import com.quan404.glmediaplayer.GLMediaPlayer;
12 | import com.quan404.glmediaplayer.config.LogConfig;
13 | import com.quan404.gltoolkit.objects.Video;
14 | import com.quan404.gltoolkit.programs.VideoShaderProgram;
15 |
16 | import java.nio.ByteBuffer;
17 | import java.nio.FloatBuffer;
18 |
19 | import javax.microedition.khronos.egl.EGLConfig;
20 | import javax.microedition.khronos.opengles.GL10;
21 |
22 | /**
23 | * Created by quanhua on 06/01/2016.
24 | */
25 | public class DefaultVideoRenderer extends BaseVideoRenderer{
26 |
27 | private static final String TAG = "DefaultVideoRenderer";
28 | private Video video;
29 |
30 | public DefaultVideoRenderer(Context context) {
31 | super(context);
32 | }
33 |
34 | @Override
35 | public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) {
36 | super.onSurfaceCreated(gl10, eglConfig);
37 | video = new Video(VERTEX_DATA);
38 | }
39 |
40 | @Override
41 | public void onDrawFrame(GL10 gl10) {
42 | super.onDrawFrame(gl10);
43 | video.bindData(videoShaderProgram);
44 | video.draw();
45 | }
46 |
47 | @Override
48 | protected void updateVertexArray() {
49 | super.updateVertexArray();
50 | video.setVertexArray(VERTEX_DATA);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/glmediaplayer/src/main/java/com/quan404/glmediaplayer/renderers/SplitSquareVideoRenderer.java:
--------------------------------------------------------------------------------
1 | package com.quan404.glmediaplayer.renderers;
2 |
3 | import android.content.Context;
4 | import android.media.MediaPlayer;
5 | import android.util.Log;
6 |
7 | import com.quan404.gltoolkit.objects.Video;
8 |
9 | import javax.microedition.khronos.egl.EGLConfig;
10 | import javax.microedition.khronos.opengles.GL10;
11 |
12 | /**
13 | * Created by quanhua on 06/01/2016.
14 | */
15 | public class SplitSquareVideoRenderer extends BaseVideoRenderer{
16 |
17 | private static final String TAG = "SplitSquareRenderer";
18 | private Video video_left;
19 | private Video video_right;
20 |
21 | private float curLeft = 0.1f;
22 | private float curWidth = 0.25f;
23 |
24 | public SplitSquareVideoRenderer(Context context) {
25 | super(context);
26 | }
27 |
28 | @Override
29 | public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) {
30 | super.onSurfaceCreated(gl10, eglConfig);
31 |
32 | video_left = new Video(getVideoLeftVertexData());
33 | video_right = new Video(getVideoRightVertexData());
34 | }
35 |
36 | @Override
37 | public void onDrawFrame(GL10 gl10) {
38 | super.onDrawFrame(gl10);
39 |
40 | video_left.bindData(videoShaderProgram);
41 | video_left.draw();
42 |
43 | video_right.bindData(videoShaderProgram);
44 | video_right.draw();
45 | }
46 | public float[] getVideoLeftVertexData(){
47 |
48 | float[] VERTEX_DATA = {
49 | // X, Y, Z, U, V
50 | -1.0f,-curHeight / 2, 0, curLeft, 0.f,
51 | 0.0f, -curHeight / 2, 0, curLeft + curWidth, 0.f,
52 | -1.0f, curHeight / 2, 0, curLeft, 1.f,
53 | 0.0f, curHeight / 2, 0, curLeft + curWidth, 1.f,
54 | };
55 | return VERTEX_DATA;
56 | }
57 | public float[] getVideoRightVertexData(){
58 | float[] VERTEX_DATA = {
59 | // X, Y, Z, U, V
60 | 0.0f, -curHeight / 2, 0, curLeft + 0.5f, 0.f,
61 | 1.0f, -curHeight / 2, 0, curLeft + curWidth + 0.5f, 0.f,
62 | 0.0f, curHeight / 2, 0, curLeft + 0.5f, 1.f,
63 | 1.0f, curHeight / 2, 0, curLeft + curWidth + 0.5f, 1.f,
64 | };
65 | return VERTEX_DATA;
66 | }
67 |
68 | @Override
69 | protected void updateWidthHeight(){
70 | if (SURFACE_HEIGHT > 0 && VIDEO_HEIGHT > 0) {
71 |
72 | float new_width = VIDEO_HEIGHT * 2;
73 | float HEIGHT_IN_PX = VIDEO_HEIGHT * SURFACE_WIDTH / new_width;
74 | curHeight = HEIGHT_IN_PX * 2.0f / SURFACE_HEIGHT * 1.0f;
75 |
76 | if ( VIDEO_WIDTH > 2 * VIDEO_HEIGHT){
77 | // 3D side by side video
78 | curWidth = VIDEO_HEIGHT * 1.0f / (VIDEO_WIDTH * 1.0f);
79 | } else {
80 | // other video
81 | curWidth = 0.1f;
82 | }
83 | updateVertexArray();
84 | }
85 | }
86 |
87 | @Override
88 | protected void updateVertexArray(){
89 | video_left.setVertexArray(getVideoLeftVertexData());
90 | video_right.setVertexArray(getVideoRightVertexData());
91 | }
92 | public float getCurLeft(){
93 | return curLeft;
94 | }
95 |
96 | public void adjustLeftPosition(float delta) {
97 | if(video_left != null && video_right != null) {
98 | float value = getCurLeft();
99 | value += delta;
100 | value = Math.min(Math.max(value, 0.0f), 0.5f - curWidth);
101 |
102 | curLeft = value;
103 |
104 | updateVertexArray();
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/glmediaplayer/src/main/java/com/quan404/glmediaplayer/renderers/SplitVideoRenderer.java:
--------------------------------------------------------------------------------
1 | package com.quan404.glmediaplayer.renderers;
2 |
3 | import android.content.Context;
4 | import android.graphics.SurfaceTexture;
5 | import android.opengl.GLES20;
6 | import android.opengl.GLSurfaceView;
7 | import android.opengl.Matrix;
8 | import android.util.Log;
9 | import android.view.Surface;
10 |
11 | import com.quan404.glmediaplayer.GLMediaPlayer;
12 | import com.quan404.glmediaplayer.config.LogConfig;
13 | import com.quan404.gltoolkit.objects.Video;
14 | import com.quan404.gltoolkit.programs.VideoShaderProgram;
15 |
16 | import javax.microedition.khronos.egl.EGLConfig;
17 | import javax.microedition.khronos.opengles.GL10;
18 |
19 | /**
20 | * Created by quanhua on 06/01/2016.
21 | */
22 | public class SplitVideoRenderer extends BaseVideoRenderer{
23 |
24 | private static final String TAG = "SplitVideoRenderer";
25 | private Video video_top;
26 | private Video video_bottom;
27 |
28 | public SplitVideoRenderer(Context context) {
29 | super(context);
30 | }
31 |
32 | @Override
33 | public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) {
34 | super.onSurfaceCreated(gl10, eglConfig);
35 |
36 | float[] VERTEX_DATA_TOP = {
37 | // X, Y, Z, U, V
38 | -1.0f, 0f, 0, 0.f, 0.f,
39 | 1.0f, 0f, 0, 0.5f, 0.f,
40 | -1.0f, 1.0f, 0, 0.f, 1.f,
41 | 1.0f, 1.0f, 0, 0.5f, 1.f,
42 | };
43 | video_top = new Video(VERTEX_DATA_TOP);
44 | float[] VERTEX_DATA_BOTTOM = {
45 | // X, Y, Z, U, V
46 | -1.0f, -1.0f, 0, 0.5f, 0.f,
47 | 1.0f, -1.0f, 0, 1f, 0.f,
48 | -1.0f, 0f, 0, 0.5f, 1.f,
49 | 1.0f, 0f, 0, 1f, 1.f,
50 | };
51 | video_bottom = new Video(VERTEX_DATA_BOTTOM);
52 | }
53 |
54 | @Override
55 | public void onDrawFrame(GL10 gl10) {
56 | super.onDrawFrame(gl10);
57 |
58 | video_top.bindData(videoShaderProgram);
59 | video_top.draw();
60 |
61 | video_bottom.bindData(videoShaderProgram);
62 | video_bottom.draw();
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/glmediaplayer/src/main/java/com/quan404/glmediaplayer/views/VideoSurfaceView.java:
--------------------------------------------------------------------------------
1 | package com.quan404.glmediaplayer.views;
2 |
3 | import android.content.Context;
4 | import android.opengl.GLSurfaceView;
5 | import android.util.AttributeSet;
6 |
7 | import com.quan404.glmediaplayer.GLMediaPlayer;
8 | import com.quan404.glmediaplayer.renderers.BaseVideoRenderer;
9 | import com.quan404.glmediaplayer.renderers.DefaultVideoRenderer;
10 |
11 | /**
12 | * Created by quanhua on 06/01/2016.
13 | */
14 | public class VideoSurfaceView extends GLSurfaceView{
15 |
16 | private BaseVideoRenderer mRenderer;
17 |
18 | public VideoSurfaceView(Context context, BaseVideoRenderer renderer) {
19 | super(context);
20 |
21 | //TODO: Check if OpenGLES 2.0 is supported
22 | setEGLContextClientVersion(2);
23 | mRenderer = renderer;
24 | setRenderer(mRenderer);
25 | }
26 |
27 | public BaseVideoRenderer getRenderer(){
28 | return mRenderer;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/glmediaplayer/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GLMediaPlayer
3 |
4 |
--------------------------------------------------------------------------------
/glmediaplayer/src/test/java/com/quan404/glmediaplayer/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.glmediaplayer;
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 | }
--------------------------------------------------------------------------------
/gltoolkit/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/gltoolkit/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 16
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | testCompile 'junit:junit:4.12'
24 | compile 'com.android.support:appcompat-v7:23.1.1'
25 | }
26 |
--------------------------------------------------------------------------------
/gltoolkit/gltoolkit.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/gltoolkit/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 /home/robotbase/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/gltoolkit/src/androidTest/java/com/quan404/gltoolkit/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit;
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 | }
--------------------------------------------------------------------------------
/gltoolkit/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/java/com/quan404/gltoolkit/Constants.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit;
2 |
3 | /**
4 | * Created by quanhua on 05/01/2016.
5 | */
6 | public class Constants {
7 | public static final int BYTES_PER_FLOAT = 4;
8 | }
9 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/java/com/quan404/gltoolkit/GLToolkit.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit;
2 |
3 | import android.app.ActivityManager;
4 | import android.content.Context;
5 | import android.content.pm.ConfigurationInfo;
6 | import android.content.res.Resources;
7 | import android.os.Build;
8 |
9 | import java.io.BufferedReader;
10 | import java.io.IOException;
11 | import java.io.InputStream;
12 | import java.io.InputStreamReader;
13 |
14 | /**
15 | * Created by quanhua on 04/01/2016.
16 | */
17 | public class GLToolkit {
18 |
19 | public static boolean checkSupportGLES2(Context context){
20 | final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
21 | final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
22 | // final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000; // works on real devices
23 |
24 | final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000 // modify to work on emulator
25 | || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
26 | && (Build.FINGERPRINT.startsWith("generic")
27 | || Build.FINGERPRINT.startsWith("unknown")
28 | || Build.MODEL.contains("google_sdk")
29 | || Build.MODEL.contains("Emulator")
30 | || Build.MODEL.contains("Android SDK built for x86")));
31 |
32 | return supportsEs2;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/java/com/quan404/gltoolkit/LoggerConfig.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit;
2 |
3 | /**
4 | * Created by quanhua on 04/01/2016.
5 | */
6 | public class LoggerConfig {
7 | public static final boolean ON = true;
8 | }
9 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/java/com/quan404/gltoolkit/ShaderHelper.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit;
2 |
3 | import android.opengl.GLES20;
4 | import android.util.Log;
5 |
6 | /**
7 | * Created by quanhua on 04/01/2016.
8 | */
9 | public class ShaderHelper {
10 | private static final String TAG = "ShaderHelper";
11 |
12 | public static int compileVertexShader(String code){
13 | return compileShader(GLES20.GL_VERTEX_SHADER, code);
14 | }
15 |
16 | public static int compileFragmentShader(String code){
17 | return compileShader(GLES20.GL_FRAGMENT_SHADER, code);
18 | }
19 |
20 | private static int compileShader(int type, String code){
21 | final int shaderObjectId = GLES20.glCreateShader(type);
22 |
23 | if (shaderObjectId == 0){
24 | if (LoggerConfig.ON){
25 | Log.w(TAG, "Could not create new shader");
26 | }
27 | return 0;
28 | }
29 |
30 | GLES20.glShaderSource(shaderObjectId, code);
31 | GLES20.glCompileShader(shaderObjectId);
32 |
33 | final int[] compileStatus = new int[1];
34 | GLES20.glGetShaderiv(shaderObjectId, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
35 |
36 | if (LoggerConfig.ON){
37 | Log.v(TAG, "Results of compiling source: " + "\n" + code + "\n" + GLES20.glGetShaderInfoLog(shaderObjectId));
38 | }
39 |
40 | if (compileStatus[0] == 0){
41 | // if it failed, delete the shader object
42 | GLES20.glDeleteShader(shaderObjectId);
43 |
44 | if (LoggerConfig.ON){
45 | Log.w(TAG, "Compilation of shader failed");
46 | }
47 | return 0;
48 | }
49 | return shaderObjectId;
50 | }
51 |
52 | public static int linkProgram(int vertexShaderId, int fragmentShaderId){
53 | final int programObjectId = GLES20.glCreateProgram();
54 |
55 | if(programObjectId == 0){
56 | if (LoggerConfig.ON){
57 | Log.w(TAG, "Could not create new program");
58 | }
59 | return 0;
60 | }
61 |
62 | GLES20.glAttachShader(programObjectId, vertexShaderId);
63 | GLES20.glAttachShader(programObjectId, fragmentShaderId);
64 |
65 | GLES20.glLinkProgram(programObjectId);
66 |
67 | final int[] linkStatus = new int[1];
68 | GLES20.glGetProgramiv(programObjectId, GLES20.GL_LINK_STATUS, linkStatus, 0);
69 | if (LoggerConfig.ON){
70 | Log.v(TAG, "Results of linking program: " + "\n" + GLES20.glGetProgramInfoLog(programObjectId));
71 | }
72 |
73 | if (linkStatus[0] == 0){
74 | // if it failed, delete the shader object
75 | GLES20.glDeleteProgram(programObjectId);
76 |
77 | if (LoggerConfig.ON){
78 | Log.w(TAG, "Linking of program failed");
79 | }
80 | return 0;
81 | }
82 | return programObjectId;
83 | }
84 |
85 | public static boolean validateProgram(int programObjectId) {
86 | GLES20.glValidateProgram(programObjectId);
87 |
88 | final int[] validateStatus = new int[1];
89 | GLES20.glGetProgramiv(programObjectId, GLES20.GL_VALIDATE_STATUS, validateStatus, 0);
90 | if (LoggerConfig.ON){
91 | Log.v(TAG, "Results of validating program: " + validateStatus[0] + "\nLog: " + GLES20.glGetProgramInfoLog(programObjectId));
92 | }
93 | return validateStatus[0] != 0;
94 | }
95 |
96 | public static int buildProgram(String vertexShaderSource, String fragmentShaderSource){
97 | int program;
98 |
99 | // compile the shaders
100 | int vertexShader = compileVertexShader(vertexShaderSource);
101 | int fragmentShader = compileFragmentShader(fragmentShaderSource);
102 |
103 | // link them into a shader program
104 | program = linkProgram(vertexShader, fragmentShader);
105 |
106 | if (LoggerConfig.ON){
107 | validateProgram(program);
108 | }
109 |
110 | return program;
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/java/com/quan404/gltoolkit/TextResourceReader.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 |
6 | import java.io.BufferedReader;
7 | import java.io.IOException;
8 | import java.io.InputStream;
9 | import java.io.InputStreamReader;
10 |
11 | /**
12 | * Created by quanhua on 04/01/2016.
13 | */
14 | public class TextResourceReader {
15 | public static String readTextFileFromResource(Context context, int resourceId) {
16 | StringBuilder body = new StringBuilder();
17 |
18 | try{
19 | InputStream inputStream = context.getResources().openRawResource(resourceId);
20 | InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
21 |
22 | BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
23 |
24 | String nextLine;
25 |
26 | while ((nextLine = bufferedReader.readLine()) != null){
27 | body.append(nextLine);
28 | body.append("\n");
29 | }
30 | }catch (IOException e){
31 | throw new RuntimeException("Could not open resource: " + resourceId, e);
32 | } catch (Resources.NotFoundException nfe){
33 | throw new RuntimeException("Resource not found: " + resourceId, nfe);
34 | }
35 |
36 | return body.toString();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/java/com/quan404/gltoolkit/TextureHelper.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.opengl.GLES20;
7 | import android.opengl.GLUtils;
8 | import android.util.Log;
9 |
10 | /**
11 | * Created by quanhua on 05/01/2016.
12 | */
13 | public class TextureHelper {
14 | public static final String TAG = "TextureHelper";
15 |
16 | public static int loadTexture(Context context, int resourceId) {
17 | final int[] textureObjectIds = new int[1];
18 | GLES20.glGenTextures(1, textureObjectIds, 0);
19 |
20 | if (textureObjectIds[0] == 0) {
21 | if (LoggerConfig.ON ){
22 | Log.w(TAG, "Could not generate a new OpenGL texture object.");
23 | }
24 | return 0;
25 | }
26 |
27 | // load bitmap
28 | final BitmapFactory.Options options = new BitmapFactory.Options();
29 | options.inScaled = false;
30 |
31 | final Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId, options);
32 |
33 | if (bitmap == null){
34 | if (LoggerConfig.ON){
35 | Log.w(TAG, "Resource ID " + resourceId + " could not be decoded.");
36 | }
37 |
38 | GLES20.glDeleteTextures(1, textureObjectIds, 0);
39 | return 0;
40 | }
41 |
42 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureObjectIds[0]);
43 |
44 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_LINEAR);
45 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
46 |
47 | GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
48 |
49 | bitmap.recycle();
50 |
51 | GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);
52 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
53 |
54 | return textureObjectIds[0];
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/java/com/quan404/gltoolkit/data/VertexArray.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit.data;
2 |
3 | import android.opengl.GLES20;
4 |
5 | import com.quan404.gltoolkit.Constants;
6 | import java.nio.ByteBuffer;
7 | import java.nio.ByteOrder;
8 | import java.nio.FloatBuffer;
9 |
10 | /**
11 | * Created by quanhua on 05/01/2016.
12 | */
13 | public class VertexArray {
14 | private final FloatBuffer floatBuffer;
15 |
16 |
17 | public VertexArray(float[] vertexData){
18 | floatBuffer =ByteBuffer.allocateDirect(vertexData.length * Constants.BYTES_PER_FLOAT)
19 | .order(ByteOrder.nativeOrder())
20 | .asFloatBuffer()
21 | .put(vertexData);
22 | }
23 |
24 | public void setVertexAttribPointer( int dataOffset, int attributeLocation, int componentCount, int stride){
25 | floatBuffer.position(dataOffset);
26 | GLES20.glVertexAttribPointer(attributeLocation, componentCount, GLES20.GL_FLOAT, false, stride, floatBuffer);
27 | GLES20.glEnableVertexAttribArray(attributeLocation);
28 |
29 | floatBuffer.position(0);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/java/com/quan404/gltoolkit/objects/Video.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit.objects;
2 |
3 | import android.opengl.GLES20;
4 |
5 | import com.quan404.gltoolkit.Constants;
6 | import com.quan404.gltoolkit.data.VertexArray;
7 | import com.quan404.gltoolkit.programs.VideoShaderProgram;
8 |
9 | import java.nio.FloatBuffer;
10 |
11 | /**
12 | * Created by quanhua on 06/01/2016.
13 | */
14 | public class Video {
15 | private static final int POSITION_COMPONENT_COUNT = 3;
16 | private static final int TEXTURE_COORDINATES_COMPONENT_COUNT = 2;
17 | private static final int STRIDE = (POSITION_COMPONENT_COUNT + TEXTURE_COORDINATES_COMPONENT_COUNT) * Constants.BYTES_PER_FLOAT;
18 |
19 | private VertexArray vertexArray;
20 |
21 | public Video(float[] vertex){
22 | this.vertexArray = new VertexArray(vertex);
23 | }
24 |
25 | public void bindData(VideoShaderProgram videoShaderProgram){
26 | vertexArray.setVertexAttribPointer(
27 | 0,
28 | videoShaderProgram.getPositionAttributeLocation(),
29 | POSITION_COMPONENT_COUNT,
30 | STRIDE
31 | );
32 |
33 | vertexArray.setVertexAttribPointer(
34 | POSITION_COMPONENT_COUNT,
35 | videoShaderProgram.getTextureCoordinatesAttributeLocation(),
36 | TEXTURE_COORDINATES_COMPONENT_COUNT,
37 | STRIDE
38 | );
39 | }
40 |
41 | public void draw(){
42 | GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
43 | }
44 |
45 | public void setVertexArray(float[] vertex){
46 | this.vertexArray = new VertexArray(vertex);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/java/com/quan404/gltoolkit/programs/ColorShaderProgram.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit.programs;
2 |
3 | import android.content.Context;
4 | import android.opengl.GLES20;
5 |
6 | /**
7 | * Created by quanhua on 05/01/2016.
8 | */
9 | public class ColorShaderProgram extends ShaderProgram {
10 | private final int uMatrixLocation;
11 | private final int aPositionLocation;
12 | private final int aColorLocation;
13 |
14 | public ColorShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) {
15 | super(context, vertexShaderResourceId, fragmentShaderResourceId);
16 |
17 | uMatrixLocation = GLES20.glGetUniformLocation(program, U_MATRIX);
18 |
19 | aPositionLocation = GLES20.glGetAttribLocation(program, A_POSITION);
20 | aColorLocation = GLES20.glGetAttribLocation(program, A_COLOR);
21 | }
22 |
23 | public void setUniforms(float[] matrix){
24 | GLES20.glUniformMatrix4fv(uMatrixLocation, 1, false, matrix, 0);
25 | }
26 |
27 | public int getPositionAttributeLocation(){
28 | return aPositionLocation;
29 | }
30 |
31 | public int getColorAttributeLocation(){
32 | return aColorLocation;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/java/com/quan404/gltoolkit/programs/ShaderProgram.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit.programs;
2 |
3 | import android.content.Context;
4 | import android.opengl.GLES20;
5 | import android.util.Log;
6 |
7 | import com.quan404.gltoolkit.ShaderHelper;
8 | import com.quan404.gltoolkit.TextResourceReader;
9 |
10 | /**
11 | * Created by quanhua on 05/01/2016.
12 | */
13 | abstract class ShaderProgram {
14 | // Uniform constants
15 | protected static final String U_MATRIX = "u_Matrix";
16 | protected static final String U_TEXTURE_UNIT = "u_TextureUnit";
17 | protected static final String U_COLOR = "u_Color";
18 | protected static final String U_MVPMATRIX = "u_MVPMatrix";
19 | protected static final String U_STMATRIX = "u_STMatrix";
20 |
21 | // Attribute constants
22 | protected static final String A_POSITION = "a_Position";
23 | protected static final String A_COLOR = "a_Color";
24 | protected static final String A_TEXTURE_COORDINATES = "a_TextureCoordinates";
25 |
26 | // Shader program
27 | protected final int program;
28 | protected ShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) {
29 | program = ShaderHelper.buildProgram(
30 | TextResourceReader.readTextFileFromResource(context, vertexShaderResourceId),
31 | TextResourceReader.readTextFileFromResource(context, fragmentShaderResourceId));
32 | }
33 |
34 | public void useProgram(){
35 | GLES20.glUseProgram(program);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/java/com/quan404/gltoolkit/programs/TextureShaderProgram.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit.programs;
2 |
3 | import android.content.Context;
4 | import android.opengl.GLES20;
5 |
6 | /**
7 | * Created by quanhua on 05/01/2016.
8 | */
9 | public class TextureShaderProgram extends ShaderProgram{
10 | // Uniform locations
11 | private final int uMatrixLocation;
12 | private final int uTextureUnitLocation;
13 |
14 |
15 | // Attribute locations
16 | private final int aPositionLocation;
17 | private final int aTextureCoordinatesLocation;
18 |
19 | public TextureShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId){
20 | super(context, vertexShaderResourceId, fragmentShaderResourceId);
21 |
22 | // Retrieve uniform locations for the shader program
23 | uMatrixLocation = GLES20.glGetUniformLocation(program, U_MATRIX);
24 | uTextureUnitLocation = GLES20.glGetUniformLocation(program, U_TEXTURE_UNIT);
25 |
26 | // Retrieve attribute locations for the shader program
27 | aPositionLocation = GLES20.glGetAttribLocation(program, A_POSITION);
28 | aTextureCoordinatesLocation = GLES20.glGetAttribLocation(program, A_TEXTURE_COORDINATES);
29 | }
30 |
31 | public void setUniforms(float[] matrix, int textureId){
32 | // Pass the matrix into the shader program
33 | GLES20.glUniformMatrix4fv(uMatrixLocation, 1, false, matrix, 0);
34 |
35 | // Set the active texture unit to texture unit 0
36 | GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
37 |
38 | // Bind the texture to this unit
39 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
40 |
41 | // Tell the texture unifroam sampler to use this texture in the shader by
42 | // telling it to read from texture unit 0
43 | GLES20.glUniform1i(uTextureUnitLocation, 0);
44 | }
45 |
46 | public int getPositionAttributeLocation(){
47 | return aPositionLocation;
48 | }
49 |
50 | public int getTextureCoordinatesAttributeLocation(){
51 | return aTextureCoordinatesLocation;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/java/com/quan404/gltoolkit/programs/VideoShaderProgram.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit.programs;
2 |
3 | import android.content.Context;
4 | import android.graphics.SurfaceTexture;
5 | import android.opengl.GLES20;
6 |
7 | /**
8 | * Created by quanhua on 06/01/2016.
9 | */
10 | public class VideoShaderProgram extends ShaderProgram {
11 |
12 | public static final int DEFAULT_VERTEX_SHADER = com.quan404.gltoolkit.R.raw.default_vertex_shader;
13 | public static final int DEFAULT_FRAGMENT_SHADER = com.quan404.gltoolkit.R.raw.default_fragment_shader;
14 |
15 | // Uniform locations
16 | private int uMVPMatrixLocation;
17 | private int uSTMatrixLocation;
18 |
19 | // Attribute locations
20 | private int aPositionLocation;
21 | private int aTextureCoordinatesLocation;
22 |
23 | public VideoShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) {
24 | super(context, vertexShaderResourceId, fragmentShaderResourceId);
25 |
26 | aPositionLocation = GLES20.glGetAttribLocation(program, A_POSITION);
27 | aTextureCoordinatesLocation = GLES20.glGetAttribLocation(program, A_TEXTURE_COORDINATES);
28 |
29 | uMVPMatrixLocation = GLES20.glGetUniformLocation(program, U_MVPMATRIX);
30 | uSTMatrixLocation = GLES20.glGetUniformLocation(program, U_STMATRIX);
31 | }
32 |
33 | public int getPositionAttributeLocation() {
34 | return aPositionLocation;
35 | }
36 |
37 | public int getTextureCoordinatesAttributeLocation() {
38 | return aTextureCoordinatesLocation;
39 | }
40 | public void setUniforms(float[] mvpMatrix, float[] stMatrix){
41 | GLES20.glUniformMatrix4fv(uMVPMatrixLocation, 1, false, mvpMatrix, 0 );
42 | GLES20.glUniformMatrix4fv(uSTMatrixLocation, 1, false, stMatrix, 0 );
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/gltoolkit/src/main/res/raw/default_fragment_shader.glsl:
--------------------------------------------------------------------------------
1 | #extension GL_OES_EGL_image_external : require
2 | precision mediump float;
3 | varying vec2 v_TextureCoordinates;
4 | uniform samplerExternalOES sTexture;
5 | void main() {
6 | gl_FragColor = texture2D(sTexture, v_TextureCoordinates);
7 | }
--------------------------------------------------------------------------------
/gltoolkit/src/main/res/raw/default_vertex_shader.glsl:
--------------------------------------------------------------------------------
1 | uniform mat4 u_MVPMatrix;
2 | uniform mat4 u_STMatrix;
3 | attribute vec4 a_Position;
4 | attribute vec4 a_TextureCoordinates;
5 | varying vec2 v_TextureCoordinates;
6 | void main() {
7 | gl_Position = u_MVPMatrix * a_Position;
8 | v_TextureCoordinates = (u_STMatrix * a_TextureCoordinates).xy;
9 | }
--------------------------------------------------------------------------------
/gltoolkit/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | gltoolkit
3 |
4 |
--------------------------------------------------------------------------------
/gltoolkit/src/test/java/com/quan404/gltoolkit/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.quan404.gltoolkit;
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 | }
--------------------------------------------------------------------------------
/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/quanhua92/GLMediaPlayer/8d08555e163ee17fc3266ebbca81f99e440aad67/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
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-2.8-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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':glmediaplayer', ':01_basic_video_player', ':gltoolkit', ':02_split_video_player', ':03_split_translation_video_player', ':04_basic_custom_exo_player', ':05_split_custom_exo_player'
2 |
--------------------------------------------------------------------------------