├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── 66.png
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── ijkplayer-example
├── .gitignore
├── build.gradle
├── ijkplayer-example.iml
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── tv
│ │ └── danmaku
│ │ └── ijk
│ │ └── media
│ │ └── example
│ │ └── ApplicationTest.java
│ └── main
│ ├── .classpath
│ ├── .project
│ ├── .settings
│ └── org.eclipse.jdt.core.prefs
│ ├── AndroidManifest.xml
│ ├── java
│ └── tv
│ │ └── danmaku
│ │ └── ijk
│ │ └── media
│ │ └── example
│ │ ├── activities
│ │ ├── FileExplorerActivity.java
│ │ ├── RecentMediaActivity.java
│ │ ├── SampleMediaActivity.java
│ │ ├── SettingsActivity.java
│ │ └── VideoActivity.java
│ │ ├── application
│ │ ├── AppActivity.java
│ │ └── Settings.java
│ │ ├── content
│ │ ├── PathCursor.java
│ │ ├── PathCursorLoader.java
│ │ └── RecentMediaStorage.java
│ │ ├── eventbus
│ │ └── FileExplorerEvents.java
│ │ ├── fragments
│ │ ├── FileListFragment.java
│ │ ├── RecentMediaListFragment.java
│ │ ├── SampleMediaListFragment.java
│ │ ├── SettingsFragment.java
│ │ └── TracksFragment.java
│ │ ├── services
│ │ └── MediaPlayerService.java
│ │ └── widget
│ │ ├── media
│ │ ├── AndroidMediaController.java
│ │ ├── IMediaController.java
│ │ ├── IRenderView.java
│ │ ├── IjkVideoView.java
│ │ ├── InfoHudViewHolder.java
│ │ ├── MeasureHelper.java
│ │ ├── MediaPlayerCompat.java
│ │ ├── SurfaceRenderView.java
│ │ ├── TableLayoutBinder.java
│ │ └── TextureRenderView.java
│ │ └── preference
│ │ └── IjkListPreference.java
│ ├── project.properties
│ └── res
│ ├── drawable-hdpi
│ ├── ic_action_dark_aspect_ratio.png
│ ├── ic_action_dark_filter.png
│ ├── ic_action_dark_settings.png
│ ├── ic_theme_description.png
│ ├── ic_theme_folder.png
│ └── ic_theme_play_arrow.png
│ ├── drawable-mdpi
│ ├── ic_action_dark_aspect_ratio.png
│ ├── ic_action_dark_filter.png
│ ├── ic_action_dark_settings.png
│ ├── ic_theme_description.png
│ ├── ic_theme_folder.png
│ └── ic_theme_play_arrow.png
│ ├── drawable-xhdpi
│ ├── ic_action_dark_aspect_ratio.png
│ ├── ic_action_dark_filter.png
│ ├── ic_action_dark_settings.png
│ ├── ic_theme_description.png
│ ├── ic_theme_folder.png
│ └── ic_theme_play_arrow.png
│ ├── drawable-xxhdpi
│ ├── ic_action_dark_aspect_ratio.png
│ ├── ic_action_dark_filter.png
│ ├── ic_action_dark_settings.png
│ ├── ic_theme_description.png
│ ├── ic_theme_folder.png
│ └── ic_theme_play_arrow.png
│ ├── drawable-xxxhdpi
│ ├── ic_action_dark_aspect_ratio.png
│ ├── ic_action_dark_filter.png
│ ├── ic_action_dark_settings.png
│ ├── ic_theme_description.png
│ ├── ic_theme_folder.png
│ └── ic_theme_play_arrow.png
│ ├── layout
│ ├── activity_app.xml
│ ├── activity_player.xml
│ ├── fragment_file_list.xml
│ ├── fragment_file_list_item.xml
│ ├── fragment_track_list.xml
│ ├── table_media_info.xml
│ ├── table_media_info_row1.xml
│ ├── table_media_info_row2.xml
│ ├── table_media_info_section.xml
│ └── widget_toolbar.xml
│ ├── menu
│ ├── menu_app.xml
│ └── menu_player.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-v11
│ └── styles.xml
│ ├── values-v14
│ └── styles.xml
│ ├── values-w820dp
│ └── dimens.xml
│ ├── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── ids.xml
│ ├── strings.xml
│ ├── strings_pref.xml
│ ├── styles.xml
│ └── themes.xml
│ └── xml
│ └── settings.xml
├── ijkplayer-exo
├── .gitignore
├── build.gradle
├── gradle.properties
├── ijkplayer-exo.iml
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── tv
│ │ └── danmaku
│ │ └── ijk
│ │ └── media
│ │ └── exo
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── tv
│ │ └── danmaku
│ │ └── ijk
│ │ └── media
│ │ └── exo
│ │ ├── IjkExoMediaPlayer.java
│ │ └── demo
│ │ ├── EventLogger.java
│ │ └── player
│ │ ├── DashRendererBuilder.java
│ │ ├── DemoPlayer.java
│ │ ├── ExtractorRendererBuilder.java
│ │ ├── HlsRendererBuilder.java
│ │ └── SmoothStreamingRendererBuilder.java
│ └── res
│ └── values
│ └── strings.xml
├── ijkplayer-java
├── .gitignore
├── build.gradle
├── gradle.properties
├── ijkplayer-java.iml
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── tv
│ │ └── danmaku
│ │ └── ijk
│ │ └── media
│ │ └── player
│ │ └── ApplicationTest.java
│ └── main
│ ├── .classpath
│ ├── .project
│ ├── .settings
│ └── org.eclipse.jdt.core.prefs
│ ├── AndroidManifest.xml
│ ├── java
│ └── tv
│ │ └── danmaku
│ │ └── ijk
│ │ └── media
│ │ └── player
│ │ ├── AbstractMediaPlayer.java
│ │ ├── AndroidMediaPlayer.java
│ │ ├── IMediaPlayer.java
│ │ ├── ISurfaceTextureHolder.java
│ │ ├── ISurfaceTextureHost.java
│ │ ├── IjkLibLoader.java
│ │ ├── IjkMediaCodecInfo.java
│ │ ├── IjkMediaMeta.java
│ │ ├── IjkMediaPlayer.java
│ │ ├── MediaInfo.java
│ │ ├── MediaPlayerProxy.java
│ │ ├── TextureMediaPlayer.java
│ │ ├── annotations
│ │ ├── AccessedByNative.java
│ │ └── CalledByNative.java
│ │ ├── exceptions
│ │ └── IjkMediaException.java
│ │ ├── ffmpeg
│ │ └── FFmpegApi.java
│ │ ├── misc
│ │ ├── AndroidMediaFormat.java
│ │ ├── AndroidTrackInfo.java
│ │ ├── IMediaDataSource.java
│ │ ├── IMediaFormat.java
│ │ ├── ITrackInfo.java
│ │ ├── IjkMediaFormat.java
│ │ └── IjkTrackInfo.java
│ │ └── pragma
│ │ ├── DebugLog.java
│ │ └── Pragma.java
│ ├── libs
│ ├── arm64-v8a
│ │ ├── libijkffmpeg.so
│ │ ├── libijkplayer.so
│ │ └── libijksdl.so
│ ├── armeabi-v7a
│ │ ├── libijkffmpeg.so
│ │ ├── libijkplayer.so
│ │ └── libijksdl.so
│ ├── armeabi
│ │ ├── libijkffmpeg.so
│ │ ├── libijkplayer.so
│ │ └── libijksdl.so
│ ├── x86
│ │ ├── libijkffmpeg.so
│ │ ├── libijkplayer.so
│ │ └── libijksdl.so
│ └── x86_64
│ │ ├── libijkffmpeg.so
│ │ ├── libijkplayer.so
│ │ └── libijksdl.so
│ ├── project.properties
│ └── res
│ └── values
│ └── strings.xml
├── ijkplayer.iml
├── settings.gradle
└── tools
├── gradle-bintray-upload.gradle
└── gradle-mvn-push.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 | android-ndk-prof
9 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | ijkplayer
--------------------------------------------------------------------------------
/.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 |
19 |
20 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/66.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/66.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ijkplayer-demo
2 |
3 | ijkplayer原工程编译教程请看:[http://blog.csdn.net/u010072711/article/details/51438871](http://blog.csdn.net/u010072711/article/details/51438871)
4 |
5 | 基于ijkplayer 0.5.1最新源代码,支持armv5、armv7a、x86架构32位和64位的设备,在ubuntu环境下编译,导入Android Studio,去掉编译时使用到的代码,只保留需要用到的代码,对项目封装,这样更方便集成到我们的开发项目中去。
6 |
7 | 下面是精简封装后的目录结构图:
8 |
9 | 
10 |
11 |
12 |
--------------------------------------------------------------------------------
/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:2.0.0'
9 |
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
11 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | }
21 | }
22 |
23 | ext {
24 | compileSdkVersion = 23
25 | buildToolsVersion = "23.0.3"
26 |
27 | targetSdkVersion = 23
28 |
29 | versionCode = 501000
30 | versionName = "0.5.1"
31 | }
32 |
33 | wrapper {
34 | gradleVersion = '2.10'
35 | }
36 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | VERSION_NAME=0.5.1
21 | VERSION_CODE=501000
22 | GROUP=tv.danmaku.ijk.media
23 |
24 | # http://central.sonatype.org/pages/requirements.html
25 | POM_DESCRIPTION=Video player based on FFmpeg n2.8
26 | POM_URL=https://github.com/Bilibili/ijkplayer
27 | POM_SCM_URL=https://github.com/Bilibili/ijkplayer
28 | POM_SCM_CONNECTION=scm:git:git@github.com:Bilibili/ijkplayer.git
29 | POM_SCM_DEV_CONNECTION=scm:git:git@github.com:Bilibili/ijkplayer.git
30 | POM_LICENSE_NAME=LGPL-2.1
31 | POM_LICENSE_URL=https://www.gnu.org/licenses/lgpl-2.1.html
32 | POM_LICENSE_DIST=repo
33 | POM_DEVELOPER_ID=bbcallen
34 | POM_DEVELOPER_NAME=Zhang Rui
35 | POM_DEVELOPER_EMAIL=bbcallen@gmail.com
36 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
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.10-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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ijkplayer-example/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ijkplayer-example/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | // http://tools.android.com/tech-docs/new-build-system/tips
5 | //noinspection GroovyAssignabilityCheck
6 | compileSdkVersion rootProject.ext.compileSdkVersion
7 | //noinspection GroovyAssignabilityCheck
8 | buildToolsVersion rootProject.ext.buildToolsVersion
9 |
10 | defaultConfig {
11 | applicationId "tv.danmaku.ijk.media.example"
12 | minSdkVersion 9
13 | targetSdkVersion rootProject.ext.targetSdkVersion
14 | versionCode rootProject.ext.versionCode
15 | versionName rootProject.ext.versionName
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | productFlavors {
24 | all32 { minSdkVersion 9 }
25 | all64 { minSdkVersion 21 }
26 | // armv5 {}
27 | // armv7a {}
28 | // arm64 { minSdkVersion 21 }
29 | // x86 {}
30 | }
31 | }
32 |
33 | dependencies {
34 | compile fileTree(dir: 'libs', include: ['*.jar'])
35 | compile 'com.android.support:appcompat-v7:23.0.1'
36 | compile 'com.android.support:preference-v7:23.0.1'
37 | compile 'com.android.support:support-annotations:23.0.1'
38 | compile 'com.squareup:otto:1.3.8'
39 | compile project(':ijkplayer-java')
40 | compile project(':ijkplayer-exo')
41 | // armv5Compile project(':player-armv5')
42 | // armv7aCompile project(':player-armv7a')
43 | // arm64Compile project(':player-arm64')
44 | // x86Compile project(':player-x86')
45 | // x86_64Compile project(':player-x86_64')
46 | }
47 |
--------------------------------------------------------------------------------
/ijkplayer-example/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 /opt/android/ADK/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 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/androidTest/java/tv/danmaku/ijk/media/example/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package tv.danmaku.ijk.media.example;
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 | }
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ijkplayer-sample
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
40 |
41 |
47 |
48 |
54 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/activities/FileExplorerActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.activities;
18 |
19 | import android.os.Bundle;
20 | import android.support.v4.app.Fragment;
21 | import android.support.v4.app.FragmentTransaction;
22 | import android.text.TextUtils;
23 |
24 | import com.squareup.otto.Subscribe;
25 |
26 | import java.io.File;
27 | import java.io.IOException;
28 |
29 | import tv.danmaku.ijk.media.example.R;
30 | import tv.danmaku.ijk.media.example.application.AppActivity;
31 | import tv.danmaku.ijk.media.example.application.Settings;
32 | import tv.danmaku.ijk.media.example.eventbus.FileExplorerEvents;
33 | import tv.danmaku.ijk.media.example.fragments.FileListFragment;
34 |
35 | public class FileExplorerActivity extends AppActivity {
36 | private Settings mSettings;
37 |
38 | @Override
39 | protected void onCreate(Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 |
42 | if (mSettings == null) {
43 | mSettings = new Settings(this);
44 | }
45 |
46 | String lastDirectory = mSettings.getLastDirectory();
47 | if (!TextUtils.isEmpty(lastDirectory) && new File(lastDirectory).isDirectory())
48 | doOpenDirectory(lastDirectory, false);
49 | else
50 | doOpenDirectory("/", false);
51 | }
52 |
53 | @Override
54 | protected void onResume() {
55 | super.onResume();
56 |
57 | FileExplorerEvents.getBus().register(this);
58 | }
59 |
60 | @Override
61 | protected void onPause() {
62 | super.onPause();
63 |
64 | FileExplorerEvents.getBus().unregister(this);
65 | }
66 |
67 | private void doOpenDirectory(String path, boolean addToBackStack) {
68 | Fragment newFragment = FileListFragment.newInstance(path);
69 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
70 |
71 | transaction.replace(R.id.body, newFragment);
72 |
73 | if (addToBackStack)
74 | transaction.addToBackStack(null);
75 | transaction.commit();
76 | }
77 |
78 | @Subscribe
79 | public void onClickFile(FileExplorerEvents.OnClickFile event) {
80 | File f = event.mFile;
81 | try {
82 | f = f.getAbsoluteFile();
83 | f = f.getCanonicalFile();
84 | if (TextUtils.isEmpty(f.toString()))
85 | f = new File("/");
86 | } catch (IOException e) {
87 | e.printStackTrace();
88 | }
89 |
90 | if (f.isDirectory()) {
91 | String path = f.toString();
92 | mSettings.setLastDirectory(path);
93 | doOpenDirectory(path, true);
94 | } else if (f.exists()) {
95 | VideoActivity.intentTo(this, f.getPath(), f.getName());
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/activities/RecentMediaActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.activities;
18 |
19 | import android.content.Context;
20 | import android.content.Intent;
21 | import android.os.Bundle;
22 | import android.support.v4.app.Fragment;
23 | import android.support.v4.app.FragmentTransaction;
24 | import android.view.Menu;
25 | import android.view.MenuItem;
26 |
27 | import tv.danmaku.ijk.media.example.R;
28 | import tv.danmaku.ijk.media.example.application.AppActivity;
29 | import tv.danmaku.ijk.media.example.fragments.RecentMediaListFragment;
30 |
31 | public class RecentMediaActivity extends AppActivity {
32 | public static Intent newIntent(Context context) {
33 | Intent intent = new Intent(context, RecentMediaActivity.class);
34 | return intent;
35 | }
36 |
37 | public static void intentTo(Context context) {
38 | context.startActivity(newIntent(context));
39 | }
40 |
41 | @Override
42 | protected void onCreate(Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 |
45 | Fragment newFragment = RecentMediaListFragment.newInstance();
46 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
47 |
48 | transaction.replace(R.id.body, newFragment);
49 | transaction.commit();
50 | }
51 |
52 | @Override
53 | public boolean onPrepareOptionsMenu(Menu menu) {
54 | boolean show = super.onPrepareOptionsMenu(menu);
55 | if (!show)
56 | return show;
57 |
58 | MenuItem item = menu.findItem(R.id.action_recent);
59 | if (item != null)
60 | item.setVisible(false);
61 |
62 | return true;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/activities/SampleMediaActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.activities;
18 |
19 | import android.content.Context;
20 | import android.content.Intent;
21 | import android.os.Bundle;
22 | import android.support.v4.app.Fragment;
23 | import android.support.v4.app.FragmentTransaction;
24 | import android.view.Menu;
25 | import android.view.MenuItem;
26 |
27 | import tv.danmaku.ijk.media.example.R;
28 | import tv.danmaku.ijk.media.example.application.AppActivity;
29 | import tv.danmaku.ijk.media.example.fragments.SampleMediaListFragment;
30 |
31 | public class SampleMediaActivity extends AppActivity {
32 | public static Intent newIntent(Context context) {
33 | Intent intent = new Intent(context, SampleMediaActivity.class);
34 | return intent;
35 | }
36 |
37 | public static void intentTo(Context context) {
38 | context.startActivity(newIntent(context));
39 | }
40 |
41 | @Override
42 | protected void onCreate(Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 |
45 | Fragment newFragment = SampleMediaListFragment.newInstance();
46 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
47 |
48 | transaction.replace(R.id.body, newFragment);
49 | transaction.commit();
50 | }
51 |
52 | @Override
53 | public boolean onPrepareOptionsMenu(Menu menu) {
54 | boolean show = super.onPrepareOptionsMenu(menu);
55 | if (!show)
56 | return show;
57 |
58 | MenuItem item = menu.findItem(R.id.action_recent);
59 | if (item != null)
60 | item.setVisible(false);
61 |
62 | return true;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/activities/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.activities;
18 |
19 | import android.content.Context;
20 | import android.content.Intent;
21 | import android.os.Bundle;
22 | import android.support.v4.app.Fragment;
23 | import android.support.v4.app.FragmentTransaction;
24 | import android.support.v7.app.AppCompatActivity;
25 | import android.support.v7.widget.Toolbar;
26 |
27 | import tv.danmaku.ijk.media.example.R;
28 | import tv.danmaku.ijk.media.example.fragments.SettingsFragment;
29 |
30 | public class SettingsActivity extends AppCompatActivity {
31 | public static Intent newIntent(Context context) {
32 | Intent intent = new Intent(context, SettingsActivity.class);
33 | return intent;
34 | }
35 |
36 | public static void intentTo(Context context) {
37 | context.startActivity(newIntent(context));
38 | }
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_app);
44 |
45 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
46 | setSupportActionBar(toolbar);
47 |
48 | Fragment newFragment = SettingsFragment.newInstance();
49 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
50 | transaction.replace(R.id.body, newFragment);
51 | transaction.commit();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/application/AppActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.application;
18 |
19 | import android.Manifest;
20 | import android.annotation.SuppressLint;
21 | import android.content.pm.PackageManager;
22 | import android.os.Bundle;
23 | import android.support.v4.app.ActivityCompat;
24 | import android.support.v4.content.ContextCompat;
25 | import android.support.v7.app.AppCompatActivity;
26 | import android.support.v7.widget.Toolbar;
27 | import android.view.Menu;
28 | import android.view.MenuItem;
29 |
30 | import tv.danmaku.ijk.media.example.R;
31 | import tv.danmaku.ijk.media.example.activities.RecentMediaActivity;
32 | import tv.danmaku.ijk.media.example.activities.SampleMediaActivity;
33 | import tv.danmaku.ijk.media.example.activities.SettingsActivity;
34 |
35 | @SuppressLint("Registered")
36 | public class AppActivity extends AppCompatActivity {
37 | private static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1;
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | setContentView(R.layout.activity_app);
43 |
44 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
45 | setSupportActionBar(toolbar);
46 |
47 | if (ContextCompat.checkSelfPermission(this,
48 | Manifest.permission.READ_EXTERNAL_STORAGE)
49 | != PackageManager.PERMISSION_GRANTED) {
50 | if (ActivityCompat.shouldShowRequestPermissionRationale(this,
51 | Manifest.permission.READ_EXTERNAL_STORAGE)) {
52 | // TODO: show explanation
53 | } else {
54 | ActivityCompat.requestPermissions(this,
55 | new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
56 | MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
57 | }
58 | }
59 | }
60 |
61 | @Override
62 | public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
63 | switch (requestCode) {
64 | case MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE: {
65 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
66 | // permission was granted, yay! Do the task you need to do.
67 | } else {
68 | // permission denied, boo! Disable the functionality that depends on this permission.
69 | }
70 | }
71 | }
72 | }
73 |
74 | @Override
75 | public boolean onCreateOptionsMenu(Menu menu) {
76 | getMenuInflater().inflate(R.menu.menu_app, menu);
77 | return true;
78 | }
79 |
80 | @Override
81 | public boolean onOptionsItemSelected(MenuItem item) {
82 | int id = item.getItemId();
83 | if (id == R.id.action_settings) {
84 | SettingsActivity.intentTo(this);
85 | return true;
86 | } else if (id == R.id.action_recent) {
87 | RecentMediaActivity.intentTo(this);
88 | } else if (id == R.id.action_sample) {
89 | SampleMediaActivity.intentTo(this);
90 | }
91 |
92 | return super.onOptionsItemSelected(item);
93 | }
94 |
95 | @Override
96 | public boolean onPrepareOptionsMenu(Menu menu) {
97 | boolean show = super.onPrepareOptionsMenu(menu);
98 | if (!show)
99 | return show;
100 |
101 | return true;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/application/Settings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.application;
18 |
19 | import android.content.Context;
20 | import android.content.SharedPreferences;
21 | import android.preference.PreferenceManager;
22 |
23 | import tv.danmaku.ijk.media.example.R;
24 |
25 | public class Settings {
26 | private Context mAppContext;
27 | private SharedPreferences mSharedPreferences;
28 |
29 | public static final int PV_PLAYER__Auto = 0;
30 | public static final int PV_PLAYER__AndroidMediaPlayer = 1;
31 | public static final int PV_PLAYER__IjkMediaPlayer = 2;
32 | public static final int PV_PLAYER__IjkExoMediaPlayer = 3;
33 |
34 | public Settings(Context context) {
35 | mAppContext = context.getApplicationContext();
36 | mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mAppContext);
37 | }
38 |
39 | public boolean getEnableBackgroundPlay() {
40 | String key = mAppContext.getString(R.string.pref_key_enable_background_play);
41 | return mSharedPreferences.getBoolean(key, false);
42 | }
43 |
44 | public int getPlayer() {
45 | String key = mAppContext.getString(R.string.pref_key_player);
46 | String value = mSharedPreferences.getString(key, "");
47 | try {
48 | return Integer.valueOf(value).intValue();
49 | } catch (NumberFormatException e) {
50 | return 0;
51 | }
52 | }
53 |
54 | public boolean getUsingMediaCodec() {
55 | String key = mAppContext.getString(R.string.pref_key_using_media_codec);
56 | return mSharedPreferences.getBoolean(key, false);
57 | }
58 |
59 | public boolean getUsingMediaCodecAutoRotate() {
60 | String key = mAppContext.getString(R.string.pref_key_using_media_codec_auto_rotate);
61 | return mSharedPreferences.getBoolean(key, false);
62 | }
63 |
64 | public boolean getUsingOpenSLES() {
65 | String key = mAppContext.getString(R.string.pref_key_using_opensl_es);
66 | return mSharedPreferences.getBoolean(key, false);
67 | }
68 |
69 | public String getPixelFormat() {
70 | String key = mAppContext.getString(R.string.pref_key_pixel_format);
71 | return mSharedPreferences.getString(key, "");
72 | }
73 |
74 | public boolean getEnableNoView() {
75 | String key = mAppContext.getString(R.string.pref_key_enable_no_view);
76 | return mSharedPreferences.getBoolean(key, false);
77 | }
78 |
79 | public boolean getEnableSurfaceView() {
80 | String key = mAppContext.getString(R.string.pref_key_enable_surface_view);
81 | return mSharedPreferences.getBoolean(key, false);
82 | }
83 |
84 | public boolean getEnableTextureView() {
85 | String key = mAppContext.getString(R.string.pref_key_enable_texture_view);
86 | return mSharedPreferences.getBoolean(key, false);
87 | }
88 |
89 | public boolean getEnableDetachedSurfaceTextureView() {
90 | String key = mAppContext.getString(R.string.pref_key_enable_detached_surface_texture);
91 | return mSharedPreferences.getBoolean(key, false);
92 | }
93 |
94 | public String getLastDirectory() {
95 | String key = mAppContext.getString(R.string.pref_key_last_directory);
96 | return mSharedPreferences.getString(key, "/");
97 | }
98 |
99 | public void setLastDirectory(String path) {
100 | String key = mAppContext.getString(R.string.pref_key_last_directory);
101 | mSharedPreferences.edit().putString(key, path).apply();
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/content/PathCursor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.content;
18 |
19 | import android.database.AbstractCursor;
20 | import android.provider.BaseColumns;
21 | import android.text.TextUtils;
22 |
23 | import java.io.File;
24 | import java.util.ArrayList;
25 | import java.util.Collections;
26 | import java.util.Comparator;
27 | import java.util.List;
28 | import java.util.Set;
29 | import java.util.TreeSet;
30 |
31 | public class PathCursor extends AbstractCursor {
32 | private List mFileList = new ArrayList<>();
33 |
34 | public static final String CN_ID = BaseColumns._ID;
35 | public static final String CN_FILE_NAME = "file_name";
36 | public static final String CN_FILE_PATH = "file_path";
37 | public static final String CN_IS_DIRECTORY = "is_directory";
38 | public static final String CN_IS_VIDEO = "is_video";
39 | public static final String[] columnNames = new String[]{CN_ID, CN_FILE_NAME, CN_FILE_PATH, CN_IS_DIRECTORY, CN_IS_VIDEO};
40 | public static final int CI_ID = 0;
41 | public static final int CI_FILE_NAME = 1;
42 | public static final int CI_FILE_PATH = 2;
43 | public static final int CI_IS_DIRECTORY = 3;
44 | public static final int CI_IS_VIDEO = 4;
45 |
46 | PathCursor(File parentDirectory, File[] fileList) {
47 | if (parentDirectory.getParent() != null) {
48 | FileItem parentFile = new FileItem(new File(parentDirectory, ".."));
49 | parentFile.isDirectory = true;
50 | mFileList.add(parentFile);
51 | }
52 |
53 | if (fileList != null) {
54 | for (File file : fileList) {
55 | mFileList.add(new FileItem(file));
56 | }
57 | Collections.sort(this.mFileList, sComparator);
58 | }
59 | }
60 |
61 | @Override
62 | public int getCount() {
63 | return mFileList.size();
64 | }
65 |
66 | @Override
67 | public String[] getColumnNames() {
68 | return columnNames;
69 | }
70 |
71 | @Override
72 | public String getString(int column) {
73 | switch (column) {
74 | case CI_FILE_NAME:
75 | return mFileList.get(getPosition()).file.getName();
76 | case CI_FILE_PATH:
77 | return mFileList.get(getPosition()).file.toString();
78 | }
79 | return null;
80 | }
81 |
82 | @Override
83 | public short getShort(int column) {
84 | return (short) getLong(column);
85 | }
86 |
87 | @Override
88 | public int getInt(int column) {
89 | return (int) getLong(column);
90 | }
91 |
92 | @Override
93 | public long getLong(int column) {
94 | switch (column) {
95 | case CI_ID:
96 | return getPosition();
97 | case CI_IS_DIRECTORY:
98 | return mFileList.get(getPosition()).isDirectory ? 1 : 0;
99 | case CI_IS_VIDEO:
100 | return mFileList.get(getPosition()).isVideo ? 1 : 0;
101 | }
102 | return 0;
103 | }
104 |
105 | @Override
106 | public float getFloat(int column) {
107 | return 0;
108 | }
109 |
110 | @Override
111 | public double getDouble(int column) {
112 | return 0;
113 | }
114 |
115 | @Override
116 | public boolean isNull(int column) {
117 | return mFileList == null;
118 | }
119 |
120 | public static Comparator sComparator = new Comparator() {
121 | @Override
122 | public int compare(FileItem lhs, FileItem rhs) {
123 | if (lhs.isDirectory && !rhs.isDirectory)
124 | return -1;
125 | else if (!lhs.isDirectory && rhs.isDirectory)
126 | return 1;
127 | return lhs.file.getName().compareToIgnoreCase(rhs.file.getName());
128 | }
129 | };
130 |
131 | private static Set sMediaExtSet = new TreeSet(String.CASE_INSENSITIVE_ORDER);
132 |
133 | static {
134 | sMediaExtSet.add("flv");
135 | sMediaExtSet.add("mp4");
136 | }
137 |
138 | private class FileItem {
139 | public File file;
140 | public boolean isDirectory;
141 | public boolean isVideo;
142 |
143 | public FileItem(String file) {
144 | this(new File(file));
145 | }
146 |
147 | public FileItem(File file) {
148 | this.file = file;
149 | this.isDirectory = file.isDirectory();
150 |
151 | String fileName = file.getName();
152 | if (!TextUtils.isEmpty(fileName)) {
153 | int extPos = fileName.lastIndexOf('.');
154 | if (extPos >= 0) {
155 | String ext = fileName.substring(extPos + 1);
156 | if (!TextUtils.isEmpty(ext) && sMediaExtSet.contains(ext)) {
157 | this.isVideo = true;
158 | }
159 | }
160 | }
161 | }
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/content/PathCursorLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.content;
18 |
19 | import android.content.Context;
20 | import android.database.Cursor;
21 | import android.os.Environment;
22 | import android.support.v4.content.AsyncTaskLoader;
23 |
24 | import java.io.File;
25 |
26 | public class PathCursorLoader extends AsyncTaskLoader {
27 | private File mPath;
28 |
29 | public PathCursorLoader(Context context) {
30 | this(context, Environment.getExternalStorageDirectory());
31 | }
32 |
33 | public PathCursorLoader(Context context, String path) {
34 | super(context);
35 | mPath = new File(path).getAbsoluteFile();
36 | }
37 |
38 | public PathCursorLoader(Context context, File path) {
39 | super(context);
40 | mPath = path;
41 | }
42 |
43 | @Override
44 | public Cursor loadInBackground() {
45 | File[] file_list = mPath.listFiles();
46 | return new PathCursor(mPath, file_list);
47 | }
48 |
49 | @Override
50 | protected void onStartLoading() {
51 | forceLoad();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/content/RecentMediaStorage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.content;
18 |
19 | import android.content.ContentValues;
20 | import android.content.Context;
21 | import android.database.Cursor;
22 | import android.database.sqlite.SQLiteDatabase;
23 | import android.database.sqlite.SQLiteOpenHelper;
24 | import android.os.AsyncTask;
25 | import android.support.v4.content.AsyncTaskLoader;
26 | import android.text.TextUtils;
27 |
28 | public class RecentMediaStorage {
29 | private Context mAppContext;
30 |
31 | public RecentMediaStorage(Context context) {
32 | mAppContext = context.getApplicationContext();
33 | }
34 |
35 | public void saveUrlAsync(String url) {
36 | new AsyncTask() {
37 | @Override
38 | protected Void doInBackground(String... params) {
39 | saveUrl(params[0]);
40 | return null;
41 | }
42 | }.execute(url);
43 | }
44 |
45 | public void saveUrl(String url) {
46 | ContentValues cv = new ContentValues();
47 | cv.putNull(Entry.COLUMN_NAME_ID);
48 | cv.put(Entry.COLUMN_NAME_URL, url);
49 | cv.put(Entry.COLUMN_NAME_LAST_ACCESS, System.currentTimeMillis());
50 | cv.put(Entry.COLUMN_NAME_NAME, getNameOfUrl(url));
51 | save(cv);
52 | }
53 |
54 | public void save(ContentValues contentValue) {
55 | OpenHelper openHelper = new OpenHelper(mAppContext);
56 | SQLiteDatabase db = openHelper.getWritableDatabase();
57 | db.replace(Entry.TABLE_NAME, null, contentValue);
58 | }
59 |
60 | public static String getNameOfUrl(String url) {
61 | return getNameOfUrl(url, "");
62 | }
63 |
64 | public static String getNameOfUrl(String url, String defaultName) {
65 | String name = null;
66 | int pos = url.lastIndexOf('/');
67 | if (pos >= 0)
68 | name = url.substring(pos + 1);
69 |
70 | if (TextUtils.isEmpty(name))
71 | name = defaultName;
72 |
73 | return name;
74 | }
75 |
76 | public static class Entry {
77 | public static final String TABLE_NAME = "RecentMedia";
78 | public static final String COLUMN_NAME_ID = "id";
79 | public static final String COLUMN_NAME_URL = "url";
80 | public static final String COLUMN_NAME_NAME = "name";
81 | public static final String COLUMN_NAME_LAST_ACCESS = "last_access";
82 | }
83 |
84 | public static final String ALL_COLUMNS[] = new String[]{
85 | Entry.COLUMN_NAME_ID + " as _id",
86 | Entry.COLUMN_NAME_ID,
87 | Entry.COLUMN_NAME_URL,
88 | Entry.COLUMN_NAME_NAME,
89 | Entry.COLUMN_NAME_LAST_ACCESS};
90 |
91 | public static class OpenHelper extends SQLiteOpenHelper {
92 | private static final int DATABASE_VERSION = 1;
93 | private static final String DATABASE_NAME = "RecentMedia.db";
94 | private static final String SQL_CREATE_ENTRIES =
95 | " CREATE TABLE IF NOT EXISTS " + Entry.TABLE_NAME + " (" +
96 | Entry.COLUMN_NAME_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
97 | Entry.COLUMN_NAME_URL + " VARCHAR UNIQUE, " +
98 | Entry.COLUMN_NAME_NAME + " VARCHAR, " +
99 | Entry.COLUMN_NAME_LAST_ACCESS + " INTEGER) ";
100 |
101 | public OpenHelper(Context context) {
102 | super(context, DATABASE_NAME, null, DATABASE_VERSION);
103 | }
104 |
105 | @Override
106 | public void onCreate(SQLiteDatabase db) {
107 | db.execSQL(SQL_CREATE_ENTRIES);
108 | }
109 |
110 | @Override
111 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
112 | }
113 | }
114 |
115 | public static class CursorLoader extends AsyncTaskLoader {
116 | public CursorLoader(Context context) {
117 | super(context);
118 | }
119 |
120 | @Override
121 | public Cursor loadInBackground() {
122 | Context context = getContext();
123 | OpenHelper openHelper = new OpenHelper(context);
124 | SQLiteDatabase db = openHelper.getReadableDatabase();
125 |
126 | return db.query(Entry.TABLE_NAME, ALL_COLUMNS, null, null, null, null,
127 | Entry.COLUMN_NAME_LAST_ACCESS + " DESC",
128 | "100");
129 | }
130 |
131 | @Override
132 | protected void onStartLoading() {
133 | forceLoad();
134 | }
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/eventbus/FileExplorerEvents.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.eventbus;
18 |
19 | import com.squareup.otto.Bus;
20 |
21 | import java.io.File;
22 |
23 | public class FileExplorerEvents {
24 | private static final Bus BUS = new Bus();
25 |
26 | public static Bus getBus() {
27 | return BUS;
28 | }
29 |
30 | private FileExplorerEvents() {
31 | // No instances.
32 | }
33 |
34 | public static class OnClickFile {
35 | public File mFile;
36 |
37 | public OnClickFile(String path) {
38 | this(new File(path));
39 | }
40 |
41 | public OnClickFile(File file) {
42 | mFile = file;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/fragments/RecentMediaListFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.fragments;
18 |
19 | import android.app.Activity;
20 | import android.content.Context;
21 | import android.database.Cursor;
22 | import android.os.Bundle;
23 | import android.support.annotation.Nullable;
24 | import android.support.v4.app.Fragment;
25 | import android.support.v4.app.LoaderManager;
26 | import android.support.v4.content.Loader;
27 | import android.support.v4.widget.SimpleCursorAdapter;
28 | import android.view.LayoutInflater;
29 | import android.view.View;
30 | import android.view.ViewGroup;
31 | import android.widget.AdapterView;
32 | import android.widget.ListView;
33 |
34 | import tv.danmaku.ijk.media.example.R;
35 | import tv.danmaku.ijk.media.example.activities.VideoActivity;
36 | import tv.danmaku.ijk.media.example.content.RecentMediaStorage;
37 |
38 | public class RecentMediaListFragment extends Fragment implements LoaderManager.LoaderCallbacks {
39 | private ListView mFileListView;
40 | private RecentMediaAdapter mAdapter;
41 |
42 | public static RecentMediaListFragment newInstance() {
43 | RecentMediaListFragment f = new RecentMediaListFragment();
44 | return f;
45 | }
46 |
47 | @Nullable
48 | @Override
49 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
50 | ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_file_list, container, false);
51 | mFileListView = (ListView) viewGroup.findViewById(R.id.file_list_view);
52 | return viewGroup;
53 | }
54 |
55 | @Override
56 | public void onActivityCreated(@Nullable Bundle savedInstanceState) {
57 | super.onActivityCreated(savedInstanceState);
58 |
59 | final Activity activity = getActivity();
60 |
61 | mAdapter = new RecentMediaAdapter(activity);
62 | mFileListView.setAdapter(mAdapter);
63 | mFileListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
64 | @Override
65 | public void onItemClick(AdapterView> parent, View view, final int position, final long id) {
66 | String url = mAdapter.getUrl(position);
67 | String name = mAdapter.getName(position);
68 | VideoActivity.intentTo(activity, url, name);
69 | }
70 | });
71 |
72 | getLoaderManager().initLoader(2, null, this);
73 | }
74 |
75 | @Override
76 | public Loader onCreateLoader(int id, Bundle args) {
77 | return new RecentMediaStorage.CursorLoader(getActivity());
78 | }
79 |
80 | @Override
81 | public void onLoadFinished(Loader loader, Cursor data) {
82 | mAdapter.swapCursor(data);
83 | mAdapter.notifyDataSetChanged();
84 | }
85 |
86 | @Override
87 | public void onLoaderReset(Loader loader) {
88 |
89 | }
90 |
91 | final class RecentMediaAdapter extends SimpleCursorAdapter {
92 | private int mIndex_id = -1;
93 | private int mIndex_url = -1;
94 | private int mIndex_name = -1;
95 |
96 | public RecentMediaAdapter(Context context) {
97 | super(context, android.R.layout.simple_list_item_2, null,
98 | new String[]{RecentMediaStorage.Entry.COLUMN_NAME_NAME, RecentMediaStorage.Entry.COLUMN_NAME_URL},
99 | new int[]{android.R.id.text1, android.R.id.text2}, 0);
100 | }
101 |
102 | @Override
103 | public Cursor swapCursor(Cursor c) {
104 | Cursor res = super.swapCursor(c);
105 |
106 | mIndex_id = c.getColumnIndex(RecentMediaStorage.Entry.COLUMN_NAME_ID);
107 | mIndex_url = c.getColumnIndex(RecentMediaStorage.Entry.COLUMN_NAME_URL);
108 | mIndex_name = c.getColumnIndex(RecentMediaStorage.Entry.COLUMN_NAME_NAME);
109 |
110 | return res;
111 | }
112 |
113 | @Override
114 | public long getItemId(int position) {
115 | final Cursor cursor = moveToPosition(position);
116 | if (cursor == null)
117 | return 0;
118 |
119 | return cursor.getLong(mIndex_id);
120 | }
121 |
122 | Cursor moveToPosition(int position) {
123 | final Cursor cursor = getCursor();
124 | if (cursor.getCount() == 0 || position >= cursor.getCount()) {
125 | return null;
126 | }
127 | cursor.moveToPosition(position);
128 | return cursor;
129 | }
130 |
131 | public String getUrl(int position) {
132 | final Cursor cursor = moveToPosition(position);
133 | if (cursor == null)
134 | return "";
135 |
136 | return cursor.getString(mIndex_url);
137 | }
138 |
139 | public String getName(int position) {
140 | final Cursor cursor = moveToPosition(position);
141 | if (cursor == null)
142 | return "";
143 |
144 | return cursor.getString(mIndex_name);
145 | }
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/fragments/SettingsFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.fragments;
18 |
19 | import android.os.Bundle;
20 | import android.support.v7.preference.PreferenceFragmentCompat;
21 |
22 | import tv.danmaku.ijk.media.example.R;
23 |
24 | public class SettingsFragment extends PreferenceFragmentCompat {
25 | public static SettingsFragment newInstance() {
26 | SettingsFragment f = new SettingsFragment();
27 | return f;
28 | }
29 |
30 | @Override
31 | public void onCreatePreferences(Bundle bundle, String s) {
32 | addPreferencesFromResource(R.xml.settings);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/services/MediaPlayerService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.services;
18 |
19 | import android.app.Service;
20 | import android.content.Context;
21 | import android.content.Intent;
22 | import android.os.IBinder;
23 | import android.support.annotation.Nullable;
24 |
25 | import tv.danmaku.ijk.media.player.IMediaPlayer;
26 |
27 | public class MediaPlayerService extends Service {
28 | private static IMediaPlayer sMediaPlayer;
29 |
30 | public static Intent newIntent(Context context) {
31 | Intent intent = new Intent(context, MediaPlayerService.class);
32 | return intent;
33 | }
34 |
35 | public static void intentToStart(Context context) {
36 | context.startService(newIntent(context));
37 | }
38 |
39 | public static void intentToStop(Context context) {
40 | context.stopService(newIntent(context));
41 | }
42 |
43 | @Nullable
44 | @Override
45 | public IBinder onBind(Intent intent) {
46 | return null;
47 | }
48 |
49 | public static void setMediaPlayer(IMediaPlayer mp) {
50 | if (sMediaPlayer != null && sMediaPlayer != mp) {
51 | if (sMediaPlayer.isPlaying())
52 | sMediaPlayer.stop();
53 | sMediaPlayer.release();
54 | sMediaPlayer = null;
55 | }
56 | sMediaPlayer = mp;
57 | }
58 |
59 | public static IMediaPlayer getMediaPlayer() {
60 | return sMediaPlayer;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/media/AndroidMediaController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.widget.media;
18 |
19 | import android.content.Context;
20 | import android.support.annotation.NonNull;
21 | import android.support.annotation.Nullable;
22 | import android.support.v7.app.ActionBar;
23 | import android.util.AttributeSet;
24 | import android.view.View;
25 | import android.widget.MediaController;
26 |
27 | import java.util.ArrayList;
28 |
29 | public class AndroidMediaController extends MediaController implements IMediaController {
30 | private ActionBar mActionBar;
31 |
32 | public AndroidMediaController(Context context, AttributeSet attrs) {
33 | super(context, attrs);
34 | initView(context);
35 | }
36 |
37 | public AndroidMediaController(Context context, boolean useFastForward) {
38 | super(context, useFastForward);
39 | initView(context);
40 | }
41 |
42 | public AndroidMediaController(Context context) {
43 | super(context);
44 | initView(context);
45 | }
46 |
47 | private void initView(Context context) {
48 | }
49 |
50 | public void setSupportActionBar(@Nullable ActionBar actionBar) {
51 | mActionBar = actionBar;
52 | if (isShowing()) {
53 | actionBar.show();
54 | } else {
55 | actionBar.hide();
56 | }
57 | }
58 |
59 | @Override
60 | public void show() {
61 | super.show();
62 | if (mActionBar != null)
63 | mActionBar.show();
64 | }
65 |
66 | @Override
67 | public void hide() {
68 | super.hide();
69 | if (mActionBar != null)
70 | mActionBar.hide();
71 | for (View view : mShowOnceArray)
72 | view.setVisibility(View.GONE);
73 | mShowOnceArray.clear();
74 | }
75 |
76 | //----------
77 | // Extends
78 | //----------
79 | private ArrayList mShowOnceArray = new ArrayList();
80 |
81 | public void showOnce(@NonNull View view) {
82 | mShowOnceArray.add(view);
83 | view.setVisibility(View.VISIBLE);
84 | show();
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/media/IMediaController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.widget.media;
18 |
19 | import android.view.View;
20 | import android.widget.MediaController;
21 |
22 | public interface IMediaController {
23 | void hide();
24 |
25 | boolean isShowing();
26 |
27 | void setAnchorView(View view);
28 |
29 | void setEnabled(boolean enabled);
30 |
31 | void setMediaPlayer(MediaController.MediaPlayerControl player);
32 |
33 | void show(int timeout);
34 |
35 | void show();
36 |
37 | //----------
38 | // Extends
39 | //----------
40 | void showOnce(View view);
41 | }
42 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/media/IRenderView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.widget.media;
18 |
19 | import android.graphics.SurfaceTexture;
20 | import android.support.annotation.NonNull;
21 | import android.support.annotation.Nullable;
22 | import android.view.Surface;
23 | import android.view.SurfaceHolder;
24 | import android.view.View;
25 |
26 | import tv.danmaku.ijk.media.player.IMediaPlayer;
27 |
28 | public interface IRenderView {
29 | int AR_ASPECT_FIT_PARENT = 0; // without clip
30 | int AR_ASPECT_FILL_PARENT = 1; // may clip
31 | int AR_ASPECT_WRAP_CONTENT = 2;
32 | int AR_MATCH_PARENT = 3;
33 | int AR_16_9_FIT_PARENT = 4;
34 | int AR_4_3_FIT_PARENT = 5;
35 |
36 | View getView();
37 |
38 | boolean shouldWaitForResize();
39 |
40 | void setVideoSize(int videoWidth, int videoHeight);
41 |
42 | void setVideoSampleAspectRatio(int videoSarNum, int videoSarDen);
43 |
44 | void setVideoRotation(int degree);
45 |
46 | void setAspectRatio(int aspectRatio);
47 |
48 | void addRenderCallback(@NonNull IRenderCallback callback);
49 |
50 | void removeRenderCallback(@NonNull IRenderCallback callback);
51 |
52 | interface ISurfaceHolder {
53 | void bindToMediaPlayer(IMediaPlayer mp);
54 |
55 | @NonNull
56 | IRenderView getRenderView();
57 |
58 | @Nullable
59 | SurfaceHolder getSurfaceHolder();
60 |
61 | @Nullable
62 | Surface openSurface();
63 |
64 | @Nullable
65 | SurfaceTexture getSurfaceTexture();
66 | }
67 |
68 | interface IRenderCallback {
69 | /**
70 | * @param holder
71 | * @param width could be 0
72 | * @param height could be 0
73 | */
74 | void onSurfaceCreated(@NonNull ISurfaceHolder holder, int width, int height);
75 |
76 | /**
77 | * @param holder
78 | * @param format could be 0
79 | * @param width
80 | * @param height
81 | */
82 | void onSurfaceChanged(@NonNull ISurfaceHolder holder, int format, int width, int height);
83 |
84 | void onSurfaceDestroyed(@NonNull ISurfaceHolder holder);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/media/InfoHudViewHolder.java:
--------------------------------------------------------------------------------
1 | package tv.danmaku.ijk.media.example.widget.media;
2 |
3 | import android.content.Context;
4 | import android.os.Handler;
5 | import android.os.Message;
6 | import android.util.SparseArray;
7 | import android.view.View;
8 | import android.widget.TableLayout;
9 |
10 | import java.util.Locale;
11 |
12 | import tv.danmaku.ijk.media.player.IMediaPlayer;
13 | import tv.danmaku.ijk.media.player.IjkMediaPlayer;
14 | import tv.danmaku.ijk.media.player.MediaPlayerProxy;
15 | import tv.danmaku.ijk.media.example.R;
16 |
17 | public class InfoHudViewHolder {
18 | private TableLayoutBinder mTableLayoutBinder;
19 | private SparseArray mRowMap = new SparseArray();
20 | private IMediaPlayer mMediaPlayer;
21 |
22 | public InfoHudViewHolder(Context context, TableLayout tableLayout) {
23 | mTableLayoutBinder = new TableLayoutBinder(context, tableLayout);
24 | }
25 |
26 | private void appendSection(int nameId) {
27 | mTableLayoutBinder.appendSection(nameId);
28 | }
29 |
30 | private void appendRow(int nameId) {
31 | View rowView = mTableLayoutBinder.appendRow2(nameId, null);
32 | mRowMap.put(nameId, rowView);
33 | }
34 |
35 | private void setRowValue(int id, String value) {
36 | View rowView = mRowMap.get(id);
37 | if (rowView == null) {
38 | rowView = mTableLayoutBinder.appendRow2(id, value);
39 | mRowMap.put(id, rowView);
40 | } else {
41 | mTableLayoutBinder.setValueText(rowView, value);
42 | }
43 | }
44 |
45 | public void setMediaPlayer(IMediaPlayer mp) {
46 | mMediaPlayer = mp;
47 | if (mMediaPlayer != null) {
48 | mHandler.sendEmptyMessageDelayed(MSG_UPDATE_HUD, 500);
49 | } else {
50 | mHandler.removeMessages(MSG_UPDATE_HUD);
51 | }
52 | }
53 |
54 | private static String formatedDurationMilli(long duration) {
55 | if (duration >= 1000) {
56 | return String.format(Locale.US, "%.2f sec", ((float)duration) / 1000);
57 | } else {
58 | return String.format(Locale.US, "%d msec", duration);
59 | }
60 | }
61 |
62 | private static String formatedSize(long bytes) {
63 | if (bytes >= 100 * 1000) {
64 | return String.format(Locale.US, "%.2f MB", ((float)bytes) / 1000 / 1000);
65 | } else if (bytes >= 100) {
66 | return String.format(Locale.US, "%.1f KB", ((float)bytes) / 1000);
67 | } else {
68 | return String.format(Locale.US, "%d B", bytes);
69 | }
70 | }
71 |
72 | private static final int MSG_UPDATE_HUD = 1;
73 | private Handler mHandler = new Handler() {
74 | @Override
75 | public void handleMessage(Message msg) {
76 | switch (msg.what) {
77 | case MSG_UPDATE_HUD: {
78 | InfoHudViewHolder holder = InfoHudViewHolder.this;
79 | IjkMediaPlayer mp = null;
80 | if (mMediaPlayer == null)
81 | break;
82 | if (mMediaPlayer instanceof IjkMediaPlayer) {
83 | mp = (IjkMediaPlayer) mMediaPlayer;
84 | } else if (mMediaPlayer instanceof MediaPlayerProxy) {
85 | MediaPlayerProxy proxy = (MediaPlayerProxy) mMediaPlayer;
86 | IMediaPlayer internal = proxy.getInternalMediaPlayer();
87 | if (internal != null && internal instanceof IjkMediaPlayer)
88 | mp = (IjkMediaPlayer) internal;
89 | }
90 | if (mp == null)
91 | break;
92 |
93 | int vdec = mp.getVideoDecoder();
94 | switch (vdec) {
95 | case IjkMediaPlayer.FFP_PROPV_DECODER_AVCODEC:
96 | setRowValue(R.string.vdec, "avcodec");
97 | break;
98 | case IjkMediaPlayer.FFP_PROPV_DECODER_MEDIACODEC:
99 | setRowValue(R.string.vdec, "MediaCodec");
100 | break;
101 | default:
102 | setRowValue(R.string.vdec, "");
103 | break;
104 | }
105 |
106 | float fpsOutput = mp.getVideoOutputFramesPerSecond();
107 | float fpsDecode = mp.getVideoDecodeFramesPerSecond();
108 | setRowValue(R.string.fps, String.format(Locale.US, "%.2f / %.2f", fpsDecode, fpsOutput));
109 |
110 | long videoCachedDuration = mp.getVideoCachedDuration();
111 | long audioCachedDuration = mp.getAudioCachedDuration();
112 | long videoCachedBytes = mp.getVideoCachedBytes();
113 | long audioCachedBytes = mp.getAudioCachedBytes();
114 |
115 | setRowValue(R.string.v_cache, String.format(Locale.US, "%s, %s", formatedDurationMilli(videoCachedDuration), formatedSize(videoCachedBytes)));
116 | setRowValue(R.string.a_cache, String.format(Locale.US, "%s, %s", formatedDurationMilli(audioCachedDuration), formatedSize(audioCachedBytes)));
117 |
118 | mHandler.removeMessages(MSG_UPDATE_HUD);
119 | mHandler.sendEmptyMessageDelayed(MSG_UPDATE_HUD, 500);
120 | }
121 | }
122 | }
123 | };
124 | }
125 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/media/MediaPlayerCompat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.widget.media;
18 |
19 | import tv.danmaku.ijk.media.player.IMediaPlayer;
20 | import tv.danmaku.ijk.media.player.IjkMediaPlayer;
21 | import tv.danmaku.ijk.media.player.MediaPlayerProxy;
22 | import tv.danmaku.ijk.media.player.TextureMediaPlayer;
23 |
24 | public class MediaPlayerCompat {
25 | public static String getName(IMediaPlayer mp) {
26 | if (mp == null) {
27 | return "null";
28 | } else if (mp instanceof TextureMediaPlayer) {
29 | StringBuilder sb = new StringBuilder("TextureMediaPlayer <");
30 | IMediaPlayer internalMediaPlayer = ((TextureMediaPlayer) mp).getInternalMediaPlayer();
31 | if (internalMediaPlayer == null) {
32 | sb.append("null>");
33 | } else {
34 | sb.append(internalMediaPlayer.getClass().getSimpleName());
35 | sb.append(">");
36 | }
37 | return sb.toString();
38 | } else {
39 | return mp.getClass().getSimpleName();
40 | }
41 | }
42 |
43 | public static IjkMediaPlayer getIjkMediaPlayer(IMediaPlayer mp) {
44 | IjkMediaPlayer ijkMediaPlayer = null;
45 | if (mp == null) {
46 | return null;
47 | } if (mp instanceof IjkMediaPlayer) {
48 | ijkMediaPlayer = (IjkMediaPlayer) mp;
49 | } else if (mp instanceof MediaPlayerProxy && ((MediaPlayerProxy) mp).getInternalMediaPlayer() instanceof IjkMediaPlayer) {
50 | ijkMediaPlayer = (IjkMediaPlayer) ((MediaPlayerProxy) mp).getInternalMediaPlayer();
51 | }
52 | return ijkMediaPlayer;
53 | }
54 |
55 | public static void selectTrack(IMediaPlayer mp, int stream) {
56 | IjkMediaPlayer ijkMediaPlayer = getIjkMediaPlayer(mp);
57 | if (ijkMediaPlayer == null)
58 | return;
59 | ijkMediaPlayer.selectTrack(stream);
60 | }
61 |
62 | public static void deselectTrack(IMediaPlayer mp, int stream) {
63 | IjkMediaPlayer ijkMediaPlayer = getIjkMediaPlayer(mp);
64 | if (ijkMediaPlayer == null)
65 | return;
66 | ijkMediaPlayer.deselectTrack(stream);
67 | }
68 |
69 | public static int getSelectedTrack(IMediaPlayer mp, int trackType) {
70 | IjkMediaPlayer ijkMediaPlayer = getIjkMediaPlayer(mp);
71 | if (ijkMediaPlayer == null)
72 | return -1;
73 | return ijkMediaPlayer.getSelectedTrack(trackType);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/media/TableLayoutBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.widget.media;
18 |
19 | import android.content.Context;
20 | import android.support.v7.app.AlertDialog;
21 | import android.view.LayoutInflater;
22 | import android.view.View;
23 | import android.view.ViewGroup;
24 | import android.widget.TableLayout;
25 | import android.widget.TextView;
26 |
27 | import tv.danmaku.ijk.media.example.R;
28 |
29 | public class TableLayoutBinder {
30 | private Context mContext;
31 | public ViewGroup mTableView;
32 | public TableLayout mTableLayout;
33 |
34 | public TableLayoutBinder(Context context) {
35 | this(context, R.layout.table_media_info);
36 | }
37 |
38 | public TableLayoutBinder(Context context, int layoutResourceId) {
39 | mContext = context;
40 | mTableView = (ViewGroup) LayoutInflater.from(mContext).inflate(layoutResourceId, null);
41 | mTableLayout = (TableLayout) mTableView.findViewById(R.id.table);
42 | }
43 |
44 | public TableLayoutBinder(Context context, TableLayout tableLayout) {
45 | mContext = context;
46 | mTableView = tableLayout;
47 | mTableLayout = tableLayout;
48 | }
49 |
50 | public View appendRow1(String name, String value) {
51 | return appendRow(R.layout.table_media_info_row1, name, value);
52 | }
53 |
54 | public View appendRow1(int nameId, String value) {
55 | return appendRow1(mContext.getString(nameId), value);
56 | }
57 |
58 | public View appendRow2(String name, String value) {
59 | return appendRow(R.layout.table_media_info_row2, name, value);
60 | }
61 |
62 | public View appendRow2(int nameId, String value) {
63 | return appendRow2(mContext.getString(nameId), value);
64 | }
65 |
66 | public View appendSection(String name) {
67 | return appendRow(R.layout.table_media_info_section, name, null);
68 | }
69 |
70 | public View appendSection(int nameId) {
71 | return appendSection(mContext.getString(nameId));
72 | }
73 |
74 | public View appendRow(int layoutId, String name, String value) {
75 | ViewGroup rowView = (ViewGroup) LayoutInflater.from(mContext).inflate(layoutId, mTableLayout, false);
76 | setNameValueText(rowView, name, value);
77 |
78 | mTableLayout.addView(rowView);
79 | return rowView;
80 | }
81 |
82 | public ViewHolder obtainViewHolder(View rowView) {
83 | ViewHolder viewHolder = (ViewHolder) rowView.getTag();
84 | if (viewHolder == null) {
85 | viewHolder = new ViewHolder();
86 | viewHolder.mNameTextView = (TextView) rowView.findViewById(R.id.name);
87 | viewHolder.mValueTextView = (TextView) rowView.findViewById(R.id.value);
88 | rowView.setTag(viewHolder);
89 | }
90 | return viewHolder;
91 | }
92 |
93 | public void setNameValueText(View rowView, String name, String value) {
94 | ViewHolder viewHolder = obtainViewHolder(rowView);
95 | viewHolder.setName(name);
96 | viewHolder.setValue(value);
97 | }
98 |
99 | public void setValueText(View rowView, String value) {
100 | ViewHolder viewHolder = obtainViewHolder(rowView);
101 | viewHolder.setValue(value);
102 | }
103 |
104 | public ViewGroup buildLayout() {
105 | return mTableView;
106 | }
107 |
108 | public AlertDialog.Builder buildAlertDialogBuilder() {
109 | AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(mContext);
110 | dlgBuilder.setView(buildLayout());
111 | return dlgBuilder;
112 | }
113 |
114 | private static class ViewHolder {
115 | public TextView mNameTextView;
116 | public TextView mValueTextView;
117 |
118 | public void setName(String name) {
119 | if (mNameTextView != null) {
120 | mNameTextView.setText(name);
121 | }
122 | }
123 |
124 | public void setValue(String value) {
125 | if (mValueTextView != null) {
126 | mValueTextView.setText(value);
127 | }
128 | }
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/preference/IjkListPreference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.example.widget.preference;
18 |
19 | import android.content.Context;
20 | import android.content.res.TypedArray;
21 | import android.support.v7.preference.ListPreference;
22 | import android.text.TextUtils;
23 | import android.util.AttributeSet;
24 |
25 | import tv.danmaku.ijk.media.example.R;
26 |
27 | public class IjkListPreference extends ListPreference {
28 | private CharSequence[] mEntrySummaries;
29 |
30 | public IjkListPreference(Context context) {
31 | super(context);
32 | initPreference(context, null);
33 | }
34 |
35 | public IjkListPreference(Context context, AttributeSet attrs) {
36 | super(context, attrs);
37 | initPreference(context, attrs);
38 | }
39 |
40 | public IjkListPreference(Context context, AttributeSet attrs, int defStyleAttr) {
41 | super(context, attrs, defStyleAttr);
42 | initPreference(context, attrs);
43 | }
44 |
45 | public IjkListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
46 | super(context, attrs, defStyleAttr, defStyleRes);
47 | initPreference(context, attrs);
48 | }
49 |
50 | private void initPreference(Context context, AttributeSet attrs) {
51 | TypedArray a = context.obtainStyledAttributes(attrs,
52 | R.styleable.IjkListPreference, 0, 0);
53 | if (a == null)
54 | return;
55 |
56 | mEntrySummaries = a
57 | .getTextArray(R.styleable.IjkListPreference_entrySummaries);
58 |
59 | a.recycle();
60 | }
61 |
62 | @Override
63 | protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
64 | super.onSetInitialValue(restoreValue, defaultValue);
65 | syncSummary();
66 | }
67 |
68 | @Override
69 | public void setValue(String value) {
70 | super.setValue(value);
71 | syncSummary();
72 | }
73 |
74 | @Override
75 | public void setValueIndex(int index) {
76 | super.setValueIndex(index);
77 | syncSummary();
78 | }
79 |
80 | public int getEntryIndex() {
81 | CharSequence[] entryValues = getEntryValues();
82 | CharSequence value = getValue();
83 |
84 | if (entryValues == null || value == null) {
85 | return -1;
86 | }
87 |
88 | for (int i = 0; i < entryValues.length; ++i) {
89 | if (TextUtils.equals(value, entryValues[i])) {
90 | return i;
91 | }
92 | }
93 |
94 | return -1;
95 | }
96 |
97 | // ----- summary --------------------
98 | public void setEntrySummaries(Context context, int resId) {
99 | setEntrySummaries(context.getResources().getTextArray(resId));
100 | }
101 |
102 | public void setEntrySummaries(CharSequence[] entrySummaries) {
103 | mEntrySummaries = entrySummaries;
104 | notifyChanged();
105 | }
106 |
107 | public CharSequence[] getEntrySummaries() {
108 | return mEntrySummaries;
109 | }
110 |
111 | private void syncSummary() {
112 | int index = getEntryIndex();
113 | if (index < 0)
114 | return;
115 |
116 | if (mEntrySummaries != null && index < mEntrySummaries.length) {
117 | setSummary(mEntrySummaries[index]);
118 | } else {
119 | setSummary(getEntries()[index]);
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-22
15 | android.library.reference.1=../../../player-arm64/src/main
16 | android.library.reference.2=../../../player-armv5/src/main
17 | android.library.reference.3=../../../player-armv7a/src/main
18 | android.library.reference.4=../../../player-x86/src/main
19 | android.library.reference.5=../../../player-java/src/main
20 | android.library.reference.6=../../../../contrib/appcompat
21 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-hdpi/ic_action_dark_aspect_ratio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-hdpi/ic_action_dark_aspect_ratio.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-hdpi/ic_action_dark_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-hdpi/ic_action_dark_filter.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-hdpi/ic_action_dark_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-hdpi/ic_action_dark_settings.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-hdpi/ic_theme_description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-hdpi/ic_theme_description.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-hdpi/ic_theme_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-hdpi/ic_theme_folder.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-hdpi/ic_theme_play_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-hdpi/ic_theme_play_arrow.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-mdpi/ic_action_dark_aspect_ratio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-mdpi/ic_action_dark_aspect_ratio.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-mdpi/ic_action_dark_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-mdpi/ic_action_dark_filter.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-mdpi/ic_action_dark_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-mdpi/ic_action_dark_settings.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-mdpi/ic_theme_description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-mdpi/ic_theme_description.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-mdpi/ic_theme_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-mdpi/ic_theme_folder.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-mdpi/ic_theme_play_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-mdpi/ic_theme_play_arrow.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xhdpi/ic_action_dark_aspect_ratio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xhdpi/ic_action_dark_aspect_ratio.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xhdpi/ic_action_dark_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xhdpi/ic_action_dark_filter.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xhdpi/ic_action_dark_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xhdpi/ic_action_dark_settings.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xhdpi/ic_theme_description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xhdpi/ic_theme_description.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xhdpi/ic_theme_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xhdpi/ic_theme_folder.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xhdpi/ic_theme_play_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xhdpi/ic_theme_play_arrow.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_action_dark_aspect_ratio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_action_dark_aspect_ratio.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_action_dark_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_action_dark_filter.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_action_dark_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_action_dark_settings.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_theme_description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_theme_description.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_theme_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_theme_folder.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_theme_play_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_theme_play_arrow.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_action_dark_aspect_ratio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_action_dark_aspect_ratio.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_action_dark_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_action_dark_filter.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_action_dark_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_action_dark_settings.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_theme_description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_theme_description.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_theme_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_theme_folder.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_theme_play_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_theme_play_arrow.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/activity_app.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/activity_player.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
15 |
16 |
21 |
22 |
31 |
32 |
39 |
40 |
49 |
50 |
51 |
52 |
57 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/fragment_file_list.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
19 |
20 |
26 |
27 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/fragment_file_list_item.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
13 |
14 |
21 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/fragment_track_list.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
17 |
18 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/table_media_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/table_media_info_row1.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/table_media_info_row2.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
23 |
24 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/table_media_info_section.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/widget_toolbar.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
14 |
15 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/menu/menu_app.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/menu/menu_player.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-example/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #66000000
4 |
5 | @color/ijk_color_blue_500
6 | #E3F2FD
7 | #BBDEFB
8 | #90CAF9
9 | #64B5F6
10 | #42A5F5
11 | #2196F3
12 | #1E88E5
13 | #1976D2
14 | #1565C0
15 | #0D47A1
16 |
17 | #77000000
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | @dimen/activity_horizontal_margin
7 | @dimen/activity_vertical_margin
8 |
9 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ijkmediademo
5 |
6 | N/A
7 | Close
8 | Exit
9 | Sample
10 | Recent
11 | Settings
12 | Tracks
13 | Player
14 | Render
15 | Scale
16 | Info
17 | vdec
18 | fps
19 | v-cache
20 | a-cache
21 |
22 | Media Information
23 | Player
24 | Media
25 | Profile level
26 | Pixel format
27 | Resolution
28 | Length
29 | Stream #%d
30 | Type
31 | Language
32 | Codec
33 | Frame rate
34 | Bit rate
35 | Sample rate
36 | Channels
37 | *
38 | *
39 |
40 | Video
41 | Audio
42 | Subtitle
43 | Timed text
44 | Meta data
45 | Unknown
46 |
47 | Invalid progressive playback
48 | Unknown
49 | OK
50 |
51 | Aspect / Fit parent
52 | Aspect / Fill parent
53 | Aspect / Wrap content
54 | Free / Fill parent
55 | 16:9 / Fit parent
56 | 4:3 / Fit parent
57 |
58 | Render: None
59 | Render: SurfaceView
60 | Render: TextureView
61 |
62 | Player: None
63 | Player: AndroidMediaPlayer
64 | Player: IjkMediaPlayer
65 | Player: IjkExoMediaPlayer
66 |
67 |
68 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values/strings_pref.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | General
5 |
6 | pref.enable_background_play
7 | Enable background play
8 | need Android 4.0+
9 |
10 | pref.using_android_player
11 | Using system player
12 |
13 |
14 | pref.player
15 | Choose Player
16 |
17 | - Auto Select
18 | - AndroidMediaPlayer
19 | - IjkMediaPlayer
20 | - IjkExoMediaPlayer
21 |
22 |
23 | - 0
24 | - 1
25 | - 2
26 | - 3
27 |
28 |
29 | - Auto Select
30 | - AndroidMediaPlayer
31 | - IjkMediaPlayer
32 | - IjkExoMediaPlayer
33 |
34 |
35 |
36 | Video: ijkplayer
37 |
38 | pref.using_media_codec
39 | Using MediaCodec
40 |
41 |
42 | pref.using_media_codec_auto_rotate
43 | Using MediaCodec auto rotate
44 |
45 |
46 | pref.pixel_format
47 | Pixel Format
48 |
49 | - Auto Select
50 | - RGB 565
51 | - RGB 888
52 | - RGBX 8888
53 | - YV12
54 | - OpenGL ES2
55 |
56 |
57 |
58 | - fcc-rv16
59 | - fcc-rv24
60 | - fcc-rv32
61 | - fcc-yv12
62 | - fcc-_es2
63 |
64 |
65 | - Auto Select
66 | - RGB 565
67 | - RGB 888
68 | - RGBX 8888
69 | - YV12
70 | - OpenGL ES2
71 |
72 |
73 |
74 | Audio: ijkplayer
75 |
76 | pref.using_opensl_es
77 | Using OpenSL ES
78 |
79 |
80 |
81 | RenderView
82 |
83 | pref.enable_no_view
84 | Enable NoView
85 |
86 |
87 | pref.enable_surface_view
88 | Enable SurfaceView
89 |
90 |
91 | pref.enable_texture_view
92 | Enable TextureView
93 |
94 |
95 | pref.enable_detached_surface_texture
96 | Enable detached SurfaceTexture
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
12 |
13 |
19 |
20 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
8 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/xml/settings.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
11 |
19 |
20 |
21 |
27 |
33 |
41 |
42 |
43 |
49 |
50 |
51 |
57 |
63 |
69 |
75 |
76 |
--------------------------------------------------------------------------------
/ijkplayer-exo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ijkplayer-exo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | // http://tools.android.com/tech-docs/new-build-system/tips
5 | //noinspection GroovyAssignabilityCheck
6 | compileSdkVersion rootProject.ext.compileSdkVersion
7 | //noinspection GroovyAssignabilityCheck
8 | buildToolsVersion rootProject.ext.buildToolsVersion
9 |
10 | defaultConfig {
11 | minSdkVersion 9
12 | targetSdkVersion rootProject.ext.targetSdkVersion
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 |
25 | compile 'com.google.android.exoplayer:exoplayer:r1.5.7'
26 |
27 | compile project(':ijkplayer-java')
28 | // compile 'tv.danmaku.ijk.media:ijkplayer-java:0.5.1'
29 | }
30 |
31 | ext {
32 | optionalPlugins = null;
33 | // optionalPlugins = ['tools/gradle-mvn-push.gradle', 'tools/gradle-bintray-upload.gradle'];
34 | }
35 |
36 | ext.optionalPlugins.each{ value ->
37 | def plugin_file = new File(rootProject.projectDir, value);
38 | if (plugin_file.exists()) {
39 | apply from: plugin_file
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ijkplayer-exo/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=ijkplayer-exo
2 | POM_ARTIFACT_ID=ijkplayer-exo
3 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/ijkplayer-exo/ijkplayer-exo.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 |
--------------------------------------------------------------------------------
/ijkplayer-exo/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 /opt/android/ADK/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 |
--------------------------------------------------------------------------------
/ijkplayer-exo/src/androidTest/java/tv/danmaku/ijk/media/exo/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package tv.danmaku.ijk.media.exo;
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 | }
--------------------------------------------------------------------------------
/ijkplayer-exo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ijkplayer-exo/src/main/java/tv/danmaku/ijk/media/exo/demo/player/ExtractorRendererBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package tv.danmaku.ijk.media.exo.demo.player;
17 |
18 | import com.google.android.exoplayer.MediaCodecAudioTrackRenderer;
19 | import com.google.android.exoplayer.MediaCodecSelector;
20 | import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
21 | import com.google.android.exoplayer.TrackRenderer;
22 | import com.google.android.exoplayer.audio.AudioCapabilities;
23 | import tv.danmaku.ijk.media.exo.demo.player.DemoPlayer.RendererBuilder;
24 | import com.google.android.exoplayer.extractor.Extractor;
25 | import com.google.android.exoplayer.extractor.ExtractorSampleSource;
26 | import com.google.android.exoplayer.text.TextTrackRenderer;
27 | import com.google.android.exoplayer.upstream.Allocator;
28 | import com.google.android.exoplayer.upstream.DataSource;
29 | import com.google.android.exoplayer.upstream.DefaultAllocator;
30 | import com.google.android.exoplayer.upstream.DefaultBandwidthMeter;
31 | import com.google.android.exoplayer.upstream.DefaultUriDataSource;
32 |
33 | import android.content.Context;
34 | import android.media.AudioManager;
35 | import android.media.MediaCodec;
36 | import android.net.Uri;
37 | import android.os.Handler;
38 |
39 | /**
40 | * A {link RendererBuilder} for streams that can be read using an {link Extractor}.
41 | */
42 | public class ExtractorRendererBuilder implements RendererBuilder {
43 |
44 | private static final int BUFFER_SEGMENT_SIZE = 64 * 1024;
45 | private static final int BUFFER_SEGMENT_COUNT = 256;
46 |
47 | private final Context context;
48 | private final String userAgent;
49 | private final Uri uri;
50 |
51 | public ExtractorRendererBuilder(Context context, String userAgent, Uri uri) {
52 | this.context = context;
53 | this.userAgent = userAgent;
54 | this.uri = uri;
55 | }
56 |
57 | @Override
58 | public void buildRenderers(DemoPlayer player) {
59 | Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
60 | Handler mainHandler = player.getMainHandler();
61 |
62 | // Build the video and audio renderers.
63 | DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, null);
64 | DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
65 | ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
66 | BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, mainHandler, player, 0);
67 | MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
68 | sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
69 | mainHandler, player, 50);
70 | MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
71 | MediaCodecSelector.DEFAULT, null, true, mainHandler, player,
72 | AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
73 | TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
74 | mainHandler.getLooper());
75 |
76 | // Invoke the callback.
77 | TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
78 | renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
79 | renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
80 | renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
81 | player.onRenderers(renderers, bandwidthMeter);
82 | }
83 |
84 | @Override
85 | public void cancel() {
86 | // Do nothing.
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/ijkplayer-exo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ijkplayer-exo
3 |
4 |
--------------------------------------------------------------------------------
/ijkplayer-java/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ijkplayer-java/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | // http://tools.android.com/tech-docs/new-build-system/tips
5 | //noinspection GroovyAssignabilityCheck
6 | compileSdkVersion rootProject.ext.compileSdkVersion
7 | //noinspection GroovyAssignabilityCheck
8 | buildToolsVersion rootProject.ext.buildToolsVersion
9 |
10 | defaultConfig {
11 | minSdkVersion 9
12 | targetSdkVersion rootProject.ext.targetSdkVersion
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | sourceSets.main {
21 | jniLibs.srcDirs 'src/main/libs'
22 | jni.srcDirs = [] // This prevents the auto generation of Android.mk
23 | }
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | }
29 |
30 | ext {
31 | optionalPlugins = ['tools/gradle-mvn-push.gradle', 'tools/gradle-bintray-upload.gradle'];
32 | }
33 |
34 | ext.optionalPlugins.each{ value ->
35 | def plugin_file = new File(rootProject.projectDir, value);
36 | if (plugin_file.exists()) {
37 | apply from: plugin_file
38 | }
39 | }
--------------------------------------------------------------------------------
/ijkplayer-java/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=ijkplayer-java
2 | POM_ARTIFACT_ID=ijkplayer-java
3 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/ijkplayer-java/ijkplayer-java.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 |
--------------------------------------------------------------------------------
/ijkplayer-java/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 /opt/android/ADK/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 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/androidTest/java/tv/danmaku/ijk/media/player/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package tv.danmaku.ijk.media.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 | }
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ijkplayer-java
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/AbstractMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import tv.danmaku.ijk.media.player.misc.IMediaDataSource;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public abstract class AbstractMediaPlayer implements IMediaPlayer {
23 | private OnPreparedListener mOnPreparedListener;
24 | private OnCompletionListener mOnCompletionListener;
25 | private OnBufferingUpdateListener mOnBufferingUpdateListener;
26 | private OnSeekCompleteListener mOnSeekCompleteListener;
27 | private OnVideoSizeChangedListener mOnVideoSizeChangedListener;
28 | private OnErrorListener mOnErrorListener;
29 | private OnInfoListener mOnInfoListener;
30 |
31 | public final void setOnPreparedListener(OnPreparedListener listener) {
32 | mOnPreparedListener = listener;
33 | }
34 |
35 | public final void setOnCompletionListener(OnCompletionListener listener) {
36 | mOnCompletionListener = listener;
37 | }
38 |
39 | public final void setOnBufferingUpdateListener(
40 | OnBufferingUpdateListener listener) {
41 | mOnBufferingUpdateListener = listener;
42 | }
43 |
44 | public final void setOnSeekCompleteListener(OnSeekCompleteListener listener) {
45 | mOnSeekCompleteListener = listener;
46 | }
47 |
48 | public final void setOnVideoSizeChangedListener(
49 | OnVideoSizeChangedListener listener) {
50 | mOnVideoSizeChangedListener = listener;
51 | }
52 |
53 | public final void setOnErrorListener(OnErrorListener listener) {
54 | mOnErrorListener = listener;
55 | }
56 |
57 | public final void setOnInfoListener(OnInfoListener listener) {
58 | mOnInfoListener = listener;
59 | }
60 |
61 | public void resetListeners() {
62 | mOnPreparedListener = null;
63 | mOnBufferingUpdateListener = null;
64 | mOnCompletionListener = null;
65 | mOnSeekCompleteListener = null;
66 | mOnVideoSizeChangedListener = null;
67 | mOnErrorListener = null;
68 | mOnInfoListener = null;
69 | }
70 |
71 | protected final void notifyOnPrepared() {
72 | if (mOnPreparedListener != null)
73 | mOnPreparedListener.onPrepared(this);
74 | }
75 |
76 | protected final void notifyOnCompletion() {
77 | if (mOnCompletionListener != null)
78 | mOnCompletionListener.onCompletion(this);
79 | }
80 |
81 | protected final void notifyOnBufferingUpdate(int percent) {
82 | if (mOnBufferingUpdateListener != null)
83 | mOnBufferingUpdateListener.onBufferingUpdate(this, percent);
84 | }
85 |
86 | protected final void notifyOnSeekComplete() {
87 | if (mOnSeekCompleteListener != null)
88 | mOnSeekCompleteListener.onSeekComplete(this);
89 | }
90 |
91 | protected final void notifyOnVideoSizeChanged(int width, int height,
92 | int sarNum, int sarDen) {
93 | if (mOnVideoSizeChangedListener != null)
94 | mOnVideoSizeChangedListener.onVideoSizeChanged(this, width, height,
95 | sarNum, sarDen);
96 | }
97 |
98 | protected final boolean notifyOnError(int what, int extra) {
99 | return mOnErrorListener != null && mOnErrorListener.onError(this, what, extra);
100 | }
101 |
102 | protected final boolean notifyOnInfo(int what, int extra) {
103 | return mOnInfoListener != null && mOnInfoListener.onInfo(this, what, extra);
104 | }
105 |
106 | public void setDataSource(IMediaDataSource mediaDataSource) {
107 | throw new UnsupportedOperationException();
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/IMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.annotation.TargetApi;
20 | import android.content.Context;
21 | import android.net.Uri;
22 | import android.os.Build;
23 | import android.view.Surface;
24 | import android.view.SurfaceHolder;
25 |
26 | import java.io.FileDescriptor;
27 | import java.io.IOException;
28 | import java.util.Map;
29 |
30 | import tv.danmaku.ijk.media.player.misc.IMediaDataSource;
31 | import tv.danmaku.ijk.media.player.misc.ITrackInfo;
32 |
33 | public interface IMediaPlayer {
34 | /*
35 | * Do not change these values without updating their counterparts in native
36 | */
37 | int MEDIA_INFO_UNKNOWN = 1;
38 | int MEDIA_INFO_STARTED_AS_NEXT = 2;
39 | int MEDIA_INFO_VIDEO_RENDERING_START = 3;
40 | int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700;
41 | int MEDIA_INFO_BUFFERING_START = 701;
42 | int MEDIA_INFO_BUFFERING_END = 702;
43 | int MEDIA_INFO_NETWORK_BANDWIDTH = 703;
44 | int MEDIA_INFO_BAD_INTERLEAVING = 800;
45 | int MEDIA_INFO_NOT_SEEKABLE = 801;
46 | int MEDIA_INFO_METADATA_UPDATE = 802;
47 | int MEDIA_INFO_TIMED_TEXT_ERROR = 900;
48 | int MEDIA_INFO_UNSUPPORTED_SUBTITLE = 901;
49 | int MEDIA_INFO_SUBTITLE_TIMED_OUT = 902;
50 |
51 | int MEDIA_INFO_VIDEO_ROTATION_CHANGED = 10001;
52 | int MEDIA_INFO_AUDIO_RENDERING_START = 10002;
53 |
54 | int MEDIA_ERROR_UNKNOWN = 1;
55 | int MEDIA_ERROR_SERVER_DIED = 100;
56 | int MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200;
57 | int MEDIA_ERROR_IO = -1004;
58 | int MEDIA_ERROR_MALFORMED = -1007;
59 | int MEDIA_ERROR_UNSUPPORTED = -1010;
60 | int MEDIA_ERROR_TIMED_OUT = -110;
61 |
62 | void setDisplay(SurfaceHolder sh);
63 |
64 | void setDataSource(Context context, Uri uri)
65 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
66 |
67 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
68 | void setDataSource(Context context, Uri uri, Map headers)
69 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
70 |
71 | void setDataSource(FileDescriptor fd)
72 | throws IOException, IllegalArgumentException, IllegalStateException;
73 |
74 | void setDataSource(String path)
75 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
76 |
77 | String getDataSource();
78 |
79 | void prepareAsync() throws IllegalStateException;
80 |
81 | void start() throws IllegalStateException;
82 |
83 | void stop() throws IllegalStateException;
84 |
85 | void pause() throws IllegalStateException;
86 |
87 | void setScreenOnWhilePlaying(boolean screenOn);
88 |
89 | int getVideoWidth();
90 |
91 | int getVideoHeight();
92 |
93 | boolean isPlaying();
94 |
95 | void seekTo(long msec) throws IllegalStateException;
96 |
97 | long getCurrentPosition();
98 |
99 | long getDuration();
100 |
101 | void release();
102 |
103 | void reset();
104 |
105 | void setVolume(float leftVolume, float rightVolume);
106 |
107 | int getAudioSessionId();
108 |
109 | MediaInfo getMediaInfo();
110 |
111 | @SuppressWarnings("EmptyMethod")
112 | @Deprecated
113 | void setLogEnabled(boolean enable);
114 |
115 | @Deprecated
116 | boolean isPlayable();
117 |
118 | void setOnPreparedListener(OnPreparedListener listener);
119 |
120 | void setOnCompletionListener(OnCompletionListener listener);
121 |
122 | void setOnBufferingUpdateListener(
123 | OnBufferingUpdateListener listener);
124 |
125 | void setOnSeekCompleteListener(
126 | OnSeekCompleteListener listener);
127 |
128 | void setOnVideoSizeChangedListener(
129 | OnVideoSizeChangedListener listener);
130 |
131 | void setOnErrorListener(OnErrorListener listener);
132 |
133 | void setOnInfoListener(OnInfoListener listener);
134 |
135 | /*--------------------
136 | * Listeners
137 | */
138 | interface OnPreparedListener {
139 | void onPrepared(IMediaPlayer mp);
140 | }
141 |
142 | interface OnCompletionListener {
143 | void onCompletion(IMediaPlayer mp);
144 | }
145 |
146 | interface OnBufferingUpdateListener {
147 | void onBufferingUpdate(IMediaPlayer mp, int percent);
148 | }
149 |
150 | interface OnSeekCompleteListener {
151 | void onSeekComplete(IMediaPlayer mp);
152 | }
153 |
154 | interface OnVideoSizeChangedListener {
155 | void onVideoSizeChanged(IMediaPlayer mp, int width, int height,
156 | int sar_num, int sar_den);
157 | }
158 |
159 | interface OnErrorListener {
160 | boolean onError(IMediaPlayer mp, int what, int extra);
161 | }
162 |
163 | interface OnInfoListener {
164 | boolean onInfo(IMediaPlayer mp, int what, int extra);
165 | }
166 |
167 | /*--------------------
168 | * Optional
169 | */
170 | void setAudioStreamType(int streamtype);
171 |
172 | @Deprecated
173 | void setKeepInBackground(boolean keepInBackground);
174 |
175 | int getVideoSarNum();
176 |
177 | int getVideoSarDen();
178 |
179 | @Deprecated
180 | void setWakeMode(Context context, int mode);
181 |
182 | void setLooping(boolean looping);
183 |
184 | boolean isLooping();
185 |
186 | /*--------------------
187 | * AndroidMediaPlayer: JELLY_BEAN
188 | */
189 | ITrackInfo[] getTrackInfo();
190 |
191 | /*--------------------
192 | * AndroidMediaPlayer: ICE_CREAM_SANDWICH:
193 | */
194 | void setSurface(Surface surface);
195 |
196 | /*--------------------
197 | * AndroidMediaPlayer: M:
198 | */
199 | void setDataSource(IMediaDataSource mediaDataSource);
200 | }
201 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/ISurfaceTextureHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.graphics.SurfaceTexture;
20 |
21 | public interface ISurfaceTextureHolder {
22 | void setSurfaceTexture(SurfaceTexture surfaceTexture);
23 |
24 | SurfaceTexture getSurfaceTexture();
25 |
26 | void setSurfaceTextureHost(ISurfaceTextureHost surfaceTextureHost);
27 | }
28 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/ISurfaceTextureHost.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.graphics.SurfaceTexture;
20 |
21 | public interface ISurfaceTextureHost {
22 | void releaseSurfaceTexture(SurfaceTexture surfaceTexture);
23 | }
24 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/IjkLibLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | public interface IjkLibLoader {
20 | void loadLibrary(String libName) throws UnsatisfiedLinkError,
21 | SecurityException;
22 | }
23 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/MediaInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | public class MediaInfo {
20 | public String mMediaPlayerName;
21 |
22 | public String mVideoDecoder;
23 | public String mVideoDecoderImpl;
24 |
25 | public String mAudioDecoder;
26 | public String mAudioDecoderImpl;
27 |
28 | public IjkMediaMeta mMeta;
29 | }
30 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/TextureMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.annotation.TargetApi;
20 | import android.graphics.SurfaceTexture;
21 | import android.os.Build;
22 | import android.view.Surface;
23 | import android.view.SurfaceHolder;
24 |
25 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
26 | public class TextureMediaPlayer extends MediaPlayerProxy implements IMediaPlayer, ISurfaceTextureHolder {
27 | private SurfaceTexture mSurfaceTexture;
28 | private ISurfaceTextureHost mSurfaceTextureHost;
29 |
30 | public TextureMediaPlayer(IMediaPlayer backEndMediaPlayer) {
31 | super(backEndMediaPlayer);
32 | }
33 |
34 | public void releaseSurfaceTexture() {
35 | if (mSurfaceTexture != null) {
36 | if (mSurfaceTextureHost != null) {
37 | mSurfaceTextureHost.releaseSurfaceTexture(mSurfaceTexture);
38 | } else {
39 | mSurfaceTexture.release();
40 | }
41 | mSurfaceTexture = null;
42 | }
43 | }
44 |
45 | //--------------------
46 | // IMediaPlayer
47 | //--------------------
48 | @Override
49 | public void reset() {
50 | super.reset();
51 | releaseSurfaceTexture();
52 | }
53 |
54 | @Override
55 | public void release() {
56 | super.release();
57 | releaseSurfaceTexture();
58 | }
59 |
60 | @Override
61 | public void setDisplay(SurfaceHolder sh) {
62 | if (mSurfaceTexture == null)
63 | super.setDisplay(sh);
64 | }
65 |
66 | @Override
67 | public void setSurface(Surface surface) {
68 | if (mSurfaceTexture == null)
69 | super.setSurface(surface);
70 | }
71 |
72 | //--------------------
73 | // ISurfaceTextureHolder
74 | //--------------------
75 |
76 | @Override
77 | public void setSurfaceTexture(SurfaceTexture surfaceTexture) {
78 | if (mSurfaceTexture == surfaceTexture)
79 | return;
80 |
81 | releaseSurfaceTexture();
82 | mSurfaceTexture = surfaceTexture;
83 | if (surfaceTexture == null) {
84 | super.setSurface(null);
85 | } else {
86 | super.setSurface(new Surface(surfaceTexture));
87 | }
88 | }
89 |
90 | @Override
91 | public SurfaceTexture getSurfaceTexture() {
92 | return mSurfaceTexture;
93 | }
94 |
95 | @Override
96 | public void setSurfaceTextureHost(ISurfaceTextureHost surfaceTextureHost) {
97 | mSurfaceTextureHost = surfaceTextureHost;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/annotations/AccessedByNative.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * is used by the JNI generator to create the necessary JNI
26 | * bindings and expose this method to native code.
27 | */
28 | @Target(ElementType.FIELD)
29 | @Retention(RetentionPolicy.CLASS)
30 | public @interface AccessedByNative {
31 | }
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/annotations/CalledByNative.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * is used by the JNI generator to create the necessary JNI
26 | * bindings and expose this method to native code.
27 | */
28 | @Target(ElementType.METHOD)
29 | @Retention(RetentionPolicy.CLASS)
30 | public @interface CalledByNative {
31 | /*
32 | * If present, tells which inner class the method belongs to.
33 | */
34 | String value() default "";
35 | }
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/exceptions/IjkMediaException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.exceptions;
18 |
19 | public class IjkMediaException extends Exception {
20 | private static final long serialVersionUID = 7234796519009099506L;
21 | }
22 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/ffmpeg/FFmpegApi.java:
--------------------------------------------------------------------------------
1 | package tv.danmaku.ijk.media.player.ffmpeg;
2 |
3 | public class FFmpegApi {
4 | public static native String av_base64_encode(byte in[]);
5 | }
6 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/AndroidMediaFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import android.annotation.TargetApi;
20 | import android.media.MediaFormat;
21 | import android.os.Build;
22 |
23 | public class AndroidMediaFormat implements IMediaFormat {
24 | private final MediaFormat mMediaFormat;
25 |
26 | public AndroidMediaFormat(MediaFormat mediaFormat) {
27 | mMediaFormat = mediaFormat;
28 | }
29 |
30 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
31 | @Override
32 | public int getInteger(String name) {
33 | if (mMediaFormat == null)
34 | return 0;
35 |
36 | return mMediaFormat.getInteger(name);
37 | }
38 |
39 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
40 | @Override
41 | public String getString(String name) {
42 | if (mMediaFormat == null)
43 | return null;
44 |
45 | return mMediaFormat.getString(name);
46 | }
47 |
48 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
49 | @Override
50 | public String toString() {
51 | StringBuilder out = new StringBuilder(128);
52 | out.append(getClass().getName());
53 | out.append('{');
54 | if (mMediaFormat != null) {
55 | out.append(mMediaFormat.toString());
56 | } else {
57 | out.append("null");
58 | }
59 | out.append('}');
60 | return out.toString();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/AndroidTrackInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import android.annotation.TargetApi;
20 | import android.media.MediaFormat;
21 | import android.media.MediaPlayer;
22 | import android.os.Build;
23 |
24 | public class AndroidTrackInfo implements ITrackInfo {
25 | private final MediaPlayer.TrackInfo mTrackInfo;
26 |
27 | public static AndroidTrackInfo[] fromMediaPlayer(MediaPlayer mp) {
28 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
29 | return fromTrackInfo(mp.getTrackInfo());
30 |
31 | return null;
32 | }
33 |
34 | private static AndroidTrackInfo[] fromTrackInfo(MediaPlayer.TrackInfo[] trackInfos) {
35 | if (trackInfos == null)
36 | return null;
37 |
38 | AndroidTrackInfo androidTrackInfo[] = new AndroidTrackInfo[trackInfos.length];
39 | for (int i = 0; i < trackInfos.length; ++i) {
40 | androidTrackInfo[i] = new AndroidTrackInfo(trackInfos[i]);
41 | }
42 |
43 | return androidTrackInfo;
44 | }
45 |
46 | private AndroidTrackInfo(MediaPlayer.TrackInfo trackInfo) {
47 | mTrackInfo = trackInfo;
48 | }
49 |
50 | @TargetApi(Build.VERSION_CODES.KITKAT)
51 | @Override
52 | public IMediaFormat getFormat() {
53 | if (mTrackInfo == null)
54 | return null;
55 |
56 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
57 | return null;
58 |
59 | MediaFormat mediaFormat = mTrackInfo.getFormat();
60 | if (mediaFormat == null)
61 | return null;
62 |
63 | return new AndroidMediaFormat(mediaFormat);
64 | }
65 |
66 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
67 | @Override
68 | public String getLanguage() {
69 | if (mTrackInfo == null)
70 | return "und";
71 |
72 | return mTrackInfo.getLanguage();
73 | }
74 |
75 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
76 | @Override
77 | public int getTrackType() {
78 | if (mTrackInfo == null)
79 | return MEDIA_TRACK_TYPE_UNKNOWN;
80 |
81 | return mTrackInfo.getTrackType();
82 | }
83 |
84 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
85 | @Override
86 | public String toString() {
87 | StringBuilder out = new StringBuilder(128);
88 | out.append(getClass().getSimpleName());
89 | out.append('{');
90 | if (mTrackInfo != null) {
91 | out.append(mTrackInfo.toString());
92 | } else {
93 | out.append("null");
94 | }
95 | out.append('}');
96 | return out.toString();
97 | }
98 |
99 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
100 | @Override
101 | public String getInfoInline() {
102 | if (mTrackInfo != null) {
103 | return mTrackInfo.toString();
104 | } else {
105 | return "null";
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/IMediaDataSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import java.io.IOException;
20 |
21 | @SuppressWarnings("RedundantThrows")
22 | public interface IMediaDataSource {
23 | int readAt(long position, byte[] buffer, int offset, int size) throws IOException;
24 |
25 | long getSize() throws IOException;
26 |
27 | void close() throws IOException;
28 | }
29 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/IMediaFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | public interface IMediaFormat {
20 | // Common keys
21 | String KEY_MIME = "mime";
22 |
23 | // Video Keys
24 | String KEY_WIDTH = "width";
25 | String KEY_HEIGHT = "height";
26 |
27 | String getString(String name);
28 |
29 | int getInteger(String name);
30 | }
31 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/ITrackInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | public interface ITrackInfo {
20 | int MEDIA_TRACK_TYPE_AUDIO = 2;
21 | int MEDIA_TRACK_TYPE_METADATA = 5;
22 | int MEDIA_TRACK_TYPE_SUBTITLE = 4;
23 | int MEDIA_TRACK_TYPE_TIMEDTEXT = 3;
24 | int MEDIA_TRACK_TYPE_UNKNOWN = 0;
25 | int MEDIA_TRACK_TYPE_VIDEO = 1;
26 |
27 | IMediaFormat getFormat();
28 |
29 | String getLanguage();
30 |
31 | int getTrackType();
32 |
33 | String getInfoInline();
34 | }
35 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/IjkTrackInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import android.text.TextUtils;
20 |
21 | import tv.danmaku.ijk.media.player.IjkMediaMeta;
22 |
23 | public class IjkTrackInfo implements ITrackInfo {
24 | private int mTrackType = MEDIA_TRACK_TYPE_UNKNOWN;
25 | private IjkMediaMeta.IjkStreamMeta mStreamMeta;
26 |
27 | public IjkTrackInfo(IjkMediaMeta.IjkStreamMeta streamMeta) {
28 | mStreamMeta = streamMeta;
29 | }
30 |
31 | public void setMediaMeta(IjkMediaMeta.IjkStreamMeta streamMeta) {
32 | mStreamMeta = streamMeta;
33 | }
34 |
35 | @Override
36 | public IMediaFormat getFormat() {
37 | return new IjkMediaFormat(mStreamMeta);
38 | }
39 |
40 | @Override
41 | public String getLanguage() {
42 | if (mStreamMeta == null || TextUtils.isEmpty(mStreamMeta.mLanguage))
43 | return "und";
44 |
45 | return mStreamMeta.mLanguage;
46 | }
47 |
48 | @Override
49 | public int getTrackType() {
50 | return mTrackType;
51 | }
52 |
53 | public void setTrackType(int trackType) {
54 | mTrackType = trackType;
55 | }
56 |
57 | @Override
58 | public String toString() {
59 | return getClass().getSimpleName() + '{' + getInfoInline() + "}";
60 | }
61 |
62 | @Override
63 | public String getInfoInline() {
64 | StringBuilder out = new StringBuilder(128);
65 | switch (mTrackType) {
66 | case MEDIA_TRACK_TYPE_VIDEO:
67 | out.append("VIDEO");
68 | out.append(", ");
69 | out.append(mStreamMeta.getCodecShortNameInline());
70 | out.append(", ");
71 | out.append(mStreamMeta.getBitrateInline());
72 | out.append(", ");
73 | out.append(mStreamMeta.getResolutionInline());
74 | break;
75 | case MEDIA_TRACK_TYPE_AUDIO:
76 | out.append("AUDIO");
77 | out.append(", ");
78 | out.append(mStreamMeta.getCodecShortNameInline());
79 | out.append(", ");
80 | out.append(mStreamMeta.getBitrateInline());
81 | out.append(", ");
82 | out.append(mStreamMeta.getSampleRateInline());
83 | break;
84 | case MEDIA_TRACK_TYPE_TIMEDTEXT:
85 | out.append("TIMEDTEXT");
86 | break;
87 | case MEDIA_TRACK_TYPE_SUBTITLE:
88 | out.append("SUBTITLE");
89 | break;
90 | default:
91 | out.append("UNKNOWN");
92 | break;
93 | }
94 | return out.toString();
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/pragma/DebugLog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.pragma;
18 |
19 | import java.util.Locale;
20 |
21 |
22 | import android.util.Log;
23 |
24 | @SuppressWarnings({"SameParameterValue", "WeakerAccess"})
25 | public class DebugLog {
26 | public static final boolean ENABLE_ERROR = Pragma.ENABLE_VERBOSE;
27 | public static final boolean ENABLE_INFO = Pragma.ENABLE_VERBOSE;
28 | public static final boolean ENABLE_WARN = Pragma.ENABLE_VERBOSE;
29 | public static final boolean ENABLE_DEBUG = Pragma.ENABLE_VERBOSE;
30 | public static final boolean ENABLE_VERBOSE = Pragma.ENABLE_VERBOSE;
31 |
32 | public static void e(String tag, String msg) {
33 | if (ENABLE_ERROR) {
34 | Log.e(tag, msg);
35 | }
36 | }
37 |
38 | public static void e(String tag, String msg, Throwable tr) {
39 | if (ENABLE_ERROR) {
40 | Log.e(tag, msg, tr);
41 | }
42 | }
43 |
44 | public static void efmt(String tag, String fmt, Object... args) {
45 | if (ENABLE_ERROR) {
46 | String msg = String.format(Locale.US, fmt, args);
47 | Log.e(tag, msg);
48 | }
49 | }
50 |
51 | public static void i(String tag, String msg) {
52 | if (ENABLE_INFO) {
53 | Log.i(tag, msg);
54 | }
55 | }
56 |
57 | public static void i(String tag, String msg, Throwable tr) {
58 | if (ENABLE_INFO) {
59 | Log.i(tag, msg, tr);
60 | }
61 | }
62 |
63 | public static void ifmt(String tag, String fmt, Object... args) {
64 | if (ENABLE_INFO) {
65 | String msg = String.format(Locale.US, fmt, args);
66 | Log.i(tag, msg);
67 | }
68 | }
69 |
70 | public static void w(String tag, String msg) {
71 | if (ENABLE_WARN) {
72 | Log.w(tag, msg);
73 | }
74 | }
75 |
76 | public static void w(String tag, String msg, Throwable tr) {
77 | if (ENABLE_WARN) {
78 | Log.w(tag, msg, tr);
79 | }
80 | }
81 |
82 | public static void wfmt(String tag, String fmt, Object... args) {
83 | if (ENABLE_WARN) {
84 | String msg = String.format(Locale.US, fmt, args);
85 | Log.w(tag, msg);
86 | }
87 | }
88 |
89 | public static void d(String tag, String msg) {
90 | if (ENABLE_DEBUG) {
91 | Log.d(tag, msg);
92 | }
93 | }
94 |
95 | public static void d(String tag, String msg, Throwable tr) {
96 | if (ENABLE_DEBUG) {
97 | Log.d(tag, msg, tr);
98 | }
99 | }
100 |
101 | public static void dfmt(String tag, String fmt, Object... args) {
102 | if (ENABLE_DEBUG) {
103 | String msg = String.format(Locale.US, fmt, args);
104 | Log.d(tag, msg);
105 | }
106 | }
107 |
108 | public static void v(String tag, String msg) {
109 | if (ENABLE_VERBOSE) {
110 | Log.v(tag, msg);
111 | }
112 | }
113 |
114 | public static void v(String tag, String msg, Throwable tr) {
115 | if (ENABLE_VERBOSE) {
116 | Log.v(tag, msg, tr);
117 | }
118 | }
119 |
120 | public static void vfmt(String tag, String fmt, Object... args) {
121 | if (ENABLE_VERBOSE) {
122 | String msg = String.format(Locale.US, fmt, args);
123 | Log.v(tag, msg);
124 | }
125 | }
126 |
127 | public static void printStackTrace(Throwable e) {
128 | if (ENABLE_WARN) {
129 | e.printStackTrace();
130 | }
131 | }
132 |
133 | public static void printCause(Throwable e) {
134 | if (ENABLE_WARN) {
135 | Throwable cause = e.getCause();
136 | if (cause != null)
137 | e = cause;
138 |
139 | printStackTrace(e);
140 | }
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/pragma/Pragma.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package tv.danmaku.ijk.media.player.pragma;
17 |
18 | /*-
19 | * configurated by app project
20 | */
21 | public class Pragma {
22 | public static final boolean ENABLE_VERBOSE = true;
23 | }
24 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/arm64-v8a/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/arm64-v8a/libijkffmpeg.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/arm64-v8a/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/arm64-v8a/libijkplayer.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/arm64-v8a/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/arm64-v8a/libijksdl.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/armeabi-v7a/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/armeabi-v7a/libijkffmpeg.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/armeabi-v7a/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/armeabi-v7a/libijkplayer.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/armeabi-v7a/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/armeabi-v7a/libijksdl.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/armeabi/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/armeabi/libijkffmpeg.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/armeabi/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/armeabi/libijkplayer.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/armeabi/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/armeabi/libijksdl.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/x86/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/x86/libijkffmpeg.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/x86/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/x86/libijkplayer.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/x86/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/x86/libijksdl.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/x86_64/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/x86_64/libijkffmpeg.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/x86_64/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/x86_64/libijkplayer.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/x86_64/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/ijkplayer-android-demo/d118cafee0b296b91623cf09e882254a4d6a6500/ijkplayer-java/src/main/libs/x86_64/libijksdl.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-22
15 | android.library=true
16 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ijkplayer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':ijkplayer-java'
2 | include ':ijkplayer-exo'
3 |
4 | include ':ijkplayer-example'
5 |
6 |
--------------------------------------------------------------------------------
/tools/gradle-bintray-upload.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.github.dcendents.android-maven'
18 | apply plugin: 'com.jfrog.bintray'
19 |
20 | group = GROUP
21 | version = VERSION_NAME
22 |
23 | bintray {
24 | user = project.hasProperty('BINTRAY_USER') ? BINTRAY_USER : ''
25 | key = project.hasProperty('BINTRAY_APIKEY') ? BINTRAY_APIKEY : ''
26 |
27 | configurations = ['archives']
28 |
29 | dryRun = false
30 | publish = true
31 |
32 | pkg {
33 | repo = 'maven'
34 | name = POM_NAME
35 | desc = POM_DESCRIPTION
36 | websiteUrl = POM_URL
37 | vcsUrl = POM_SCM_URL
38 | licenses = [POM_LICENSE_NAME]
39 | labels = ['FFmpeg', 'Android', 'player']
40 | publicDownloadNumbers = true
41 | version {
42 | name = VERSION_NAME
43 | gpg {
44 | sign = true
45 | passphrase = project.hasProperty('GPG_PASSWORD') ? GPG_PASSWORD : ''
46 | }
47 | }
48 | }
49 | }
50 |
51 | install {
52 | repositories.mavenInstaller {
53 | pom.project {
54 | name POM_NAME
55 | packaging POM_PACKAGING
56 | description POM_DESCRIPTION
57 | url POM_URL
58 |
59 | licenses {
60 | license {
61 | name POM_LICENSE_NAME
62 | url POM_LICENSE_URL
63 | distribution POM_LICENSE_DIST
64 | }
65 | }
66 |
67 | scm {
68 | url POM_SCM_URL
69 | connection POM_SCM_CONNECTION
70 | developerConnection POM_SCM_DEV_CONNECTION
71 | }
72 |
73 | developers {
74 | developer {
75 | id POM_DEVELOPER_ID
76 | name POM_DEVELOPER_NAME
77 | email POM_DEVELOPER_EMAIL
78 | }
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/tools/gradle-mvn-push.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Chris Banes
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'maven'
18 | apply plugin: 'signing'
19 |
20 | def isReleaseBuild() {
21 | return VERSION_NAME.contains("SNAPSHOT") == false
22 | }
23 |
24 | def getReleaseRepositoryUrl() {
25 | return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
26 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
27 | }
28 |
29 | def getSnapshotRepositoryUrl() {
30 | return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
31 | : "https://oss.sonatype.org/content/repositories/snapshots/"
32 | }
33 |
34 | def getRepositoryUsername() {
35 | return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
36 | }
37 |
38 | def getRepositoryPassword() {
39 | return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
40 | }
41 |
42 | afterEvaluate { project ->
43 | uploadArchives {
44 | repositories {
45 | mavenDeployer {
46 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
47 |
48 | pom.groupId = GROUP
49 | pom.artifactId = POM_ARTIFACT_ID
50 | pom.version = VERSION_NAME
51 |
52 | repository(url: getReleaseRepositoryUrl()) {
53 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
54 | }
55 | snapshotRepository(url: getSnapshotRepositoryUrl()) {
56 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
57 | }
58 |
59 | pom.project {
60 | name POM_NAME
61 | packaging POM_PACKAGING
62 | description POM_DESCRIPTION
63 | url POM_URL
64 |
65 | licenses {
66 | license {
67 | name POM_LICENSE_NAME
68 | url POM_LICENSE_URL
69 | distribution POM_LICENSE_DIST
70 | }
71 | }
72 |
73 | scm {
74 | url POM_SCM_URL
75 | connection POM_SCM_CONNECTION
76 | developerConnection POM_SCM_DEV_CONNECTION
77 | }
78 |
79 | developers {
80 | developer {
81 | id POM_DEVELOPER_ID
82 | name POM_DEVELOPER_NAME
83 | email POM_DEVELOPER_EMAIL
84 | }
85 | }
86 | }
87 | }
88 | }
89 | }
90 |
91 | signing {
92 | required { isReleaseBuild() && (gradle.taskGraph.hasTask("uploadArchives") || gradle.taskGraph.hasTask("bintrayUpload")) }
93 | sign configurations.archives
94 | }
95 |
96 | task androidJavadocs(type: Javadoc) {
97 | failOnError false
98 | source = android.sourceSets.main.java.srcDirs
99 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
100 | }
101 |
102 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
103 | classifier = 'javadoc'
104 | from androidJavadocs.destinationDir
105 | }
106 |
107 | task androidSourcesJar(type: Jar) {
108 | classifier = 'sources'
109 | from android.sourceSets.main.java.sourceFiles
110 | }
111 |
112 | artifacts {
113 | archives androidSourcesJar
114 | archives androidJavadocsJar
115 | }
116 | }
117 |
--------------------------------------------------------------------------------