├── ijkplayer-java
├── .gitignore
├── gradle.properties
├── src
│ ├── main
│ │ ├── libs
│ │ │ └── armeabi-v7a
│ │ │ │ ├── libijksdl.so
│ │ │ │ ├── libijkffmpeg.so
│ │ │ │ └── libijkplayer.so
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ ├── java
│ │ │ └── tv
│ │ │ │ └── danmaku
│ │ │ │ └── ijk
│ │ │ │ └── media
│ │ │ │ └── player
│ │ │ │ ├── ffmpeg
│ │ │ │ └── FFmpegApi.java
│ │ │ │ ├── pragma
│ │ │ │ ├── Pragma.java
│ │ │ │ └── DebugLog.java
│ │ │ │ ├── IjkLibLoader.java
│ │ │ │ ├── ISurfaceTextureHost.java
│ │ │ │ ├── exceptions
│ │ │ │ └── IjkMediaException.java
│ │ │ │ ├── MediaInfo.java
│ │ │ │ ├── misc
│ │ │ │ ├── IMediaFormat.java
│ │ │ │ ├── IMediaDataSource.java
│ │ │ │ ├── IAndroidIO.java
│ │ │ │ ├── ITrackInfo.java
│ │ │ │ ├── AndroidMediaFormat.java
│ │ │ │ ├── IjkTrackInfo.java
│ │ │ │ └── AndroidTrackInfo.java
│ │ │ │ ├── ISurfaceTextureHolder.java
│ │ │ │ ├── annotations
│ │ │ │ ├── AccessedByNative.java
│ │ │ │ └── CalledByNative.java
│ │ │ │ ├── IjkTimedText.java
│ │ │ │ ├── TextureMediaPlayer.java
│ │ │ │ ├── AbstractMediaPlayer.java
│ │ │ │ └── IMediaPlayer.java
│ │ ├── AndroidManifest.xml
│ │ ├── .settings
│ │ │ └── org.eclipse.jdt.core.prefs
│ │ ├── .classpath
│ │ ├── project.properties
│ │ └── .project
│ └── androidTest
│ │ └── java
│ │ └── tv
│ │ └── danmaku
│ │ └── ijk
│ │ └── media
│ │ └── player
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── ijkplayer-example
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values-v11
│ │ │ │ └── styles.xml
│ │ │ ├── values-v14
│ │ │ │ └── styles.xml
│ │ │ ├── values
│ │ │ │ ├── ids.xml
│ │ │ │ ├── themes.xml
│ │ │ │ ├── attrs.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── strings_pref.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_theme_folder.png
│ │ │ │ ├── ic_theme_description.png
│ │ │ │ ├── ic_theme_play_arrow.png
│ │ │ │ ├── ic_action_dark_filter.png
│ │ │ │ ├── ic_action_dark_settings.png
│ │ │ │ └── ic_action_dark_aspect_ratio.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_theme_folder.png
│ │ │ │ ├── ic_theme_description.png
│ │ │ │ ├── ic_theme_play_arrow.png
│ │ │ │ ├── ic_action_dark_filter.png
│ │ │ │ ├── ic_action_dark_settings.png
│ │ │ │ └── ic_action_dark_aspect_ratio.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_theme_folder.png
│ │ │ │ ├── ic_theme_play_arrow.png
│ │ │ │ ├── ic_action_dark_filter.png
│ │ │ │ ├── ic_theme_description.png
│ │ │ │ ├── ic_action_dark_settings.png
│ │ │ │ └── ic_action_dark_aspect_ratio.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── ic_theme_folder.png
│ │ │ │ ├── ic_theme_description.png
│ │ │ │ ├── ic_theme_play_arrow.png
│ │ │ │ ├── ic_action_dark_filter.png
│ │ │ │ ├── ic_action_dark_settings.png
│ │ │ │ └── ic_action_dark_aspect_ratio.png
│ │ │ ├── drawable-xxxhdpi
│ │ │ │ ├── ic_theme_folder.png
│ │ │ │ ├── ic_theme_play_arrow.png
│ │ │ │ ├── ic_action_dark_filter.png
│ │ │ │ ├── ic_theme_description.png
│ │ │ │ ├── ic_action_dark_settings.png
│ │ │ │ └── ic_action_dark_aspect_ratio.png
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── layout
│ │ │ │ ├── table_media_info.xml
│ │ │ │ ├── table_media_info_section.xml
│ │ │ │ ├── activity_app.xml
│ │ │ │ ├── widget_toolbar.xml
│ │ │ │ ├── fragment_track_list.xml
│ │ │ │ ├── table_media_info_row1.xml
│ │ │ │ ├── fragment_file_list_item.xml
│ │ │ │ ├── table_media_info_row2.xml
│ │ │ │ ├── fragment_file_list.xml
│ │ │ │ └── activity_player.xml
│ │ │ ├── menu
│ │ │ │ ├── menu_app.xml
│ │ │ │ └── menu_player.xml
│ │ │ └── xml
│ │ │ │ └── settings.xml
│ │ ├── .settings
│ │ │ └── org.eclipse.jdt.core.prefs
│ │ ├── .project
│ │ ├── project.properties
│ │ ├── .classpath
│ │ ├── java
│ │ │ └── tv
│ │ │ │ └── danmaku
│ │ │ │ └── ijk
│ │ │ │ └── media
│ │ │ │ └── example
│ │ │ │ ├── widget
│ │ │ │ ├── media
│ │ │ │ │ ├── IMediaController.java
│ │ │ │ │ ├── FileMediaDataSource.java
│ │ │ │ │ ├── AndroidMediaController.java
│ │ │ │ │ ├── IRenderView.java
│ │ │ │ │ ├── MediaPlayerCompat.java
│ │ │ │ │ ├── TableLayoutBinder.java
│ │ │ │ │ └── InfoHudViewHolder.java
│ │ │ │ └── preference
│ │ │ │ │ └── IjkListPreference.java
│ │ │ │ ├── fragments
│ │ │ │ ├── SettingsFragment.java
│ │ │ │ ├── RecentMediaListFragment.java
│ │ │ │ ├── SampleMediaListFragment.java
│ │ │ │ ├── TracksFragment.java
│ │ │ │ └── FileListFragment.java
│ │ │ │ ├── eventbus
│ │ │ │ └── FileExplorerEvents.java
│ │ │ │ ├── content
│ │ │ │ ├── PathCursorLoader.java
│ │ │ │ ├── RecentMediaStorage.java
│ │ │ │ └── PathCursor.java
│ │ │ │ ├── activities
│ │ │ │ ├── SettingsActivity.java
│ │ │ │ ├── RecentMediaActivity.java
│ │ │ │ ├── SampleMediaActivity.java
│ │ │ │ └── FileExplorerActivity.java
│ │ │ │ ├── services
│ │ │ │ └── MediaPlayerService.java
│ │ │ │ └── application
│ │ │ │ ├── AppActivity.java
│ │ │ │ └── Settings.java
│ │ └── AndroidManifest.xml
│ └── androidTest
│ │ └── java
│ │ └── tv
│ │ └── danmaku
│ │ └── ijk
│ │ └── media
│ │ └── example
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── .gitignore
├── aar
├── ijkplayer-java-debug.aar
└── ijkplayer-java-release.aar
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.md
├── tools
├── gradle-on-demand.gradle
├── gradle-bintray-upload.gradle
└── gradle-mvn-push.gradle
├── gradle.properties
├── gradlew.bat
└── gradlew
/ijkplayer-java/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ijkplayer-example/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':ijkplayer-java'
2 |
3 | include ':ijkplayer-example'
4 |
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | .DS_Store
3 | .idea/
4 | build/
5 | */build/
6 | *.iml
7 | local.properties
8 | .gradle/
--------------------------------------------------------------------------------
/aar/ijkplayer-java-debug.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/aar/ijkplayer-java-debug.aar
--------------------------------------------------------------------------------
/ijkplayer-java/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=ijkplayer-java
2 | POM_ARTIFACT_ID=ijkplayer-java
3 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/aar/ijkplayer-java-release.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/aar/ijkplayer-java-release.aar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/armeabi-v7a/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-java/src/main/libs/armeabi-v7a/libijksdl.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/armeabi-v7a/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-java/src/main/libs/armeabi-v7a/libijkffmpeg.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/libs/armeabi-v7a/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-java/src/main/libs/armeabi-v7a/libijkplayer.so
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-hdpi/ic_theme_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-hdpi/ic_theme_folder.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-mdpi/ic_theme_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-mdpi/ic_theme_folder.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xhdpi/ic_theme_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xhdpi/ic_theme_folder.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_theme_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_theme_folder.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-hdpi/ic_theme_description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-hdpi/ic_theme_description.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-hdpi/ic_theme_play_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-hdpi/ic_theme_play_arrow.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-mdpi/ic_theme_description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-mdpi/ic_theme_description.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-mdpi/ic_theme_play_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-mdpi/ic_theme_play_arrow.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xhdpi/ic_theme_play_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xhdpi/ic_theme_play_arrow.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_theme_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_theme_folder.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-hdpi/ic_action_dark_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-hdpi/ic_action_dark_filter.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-mdpi/ic_action_dark_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-mdpi/ic_action_dark_filter.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xhdpi/ic_action_dark_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xhdpi/ic_action_dark_filter.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xhdpi/ic_theme_description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xhdpi/ic_theme_description.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_theme_description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_theme_description.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_theme_play_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_theme_play_arrow.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_theme_play_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_theme_play_arrow.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-hdpi/ic_action_dark_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-hdpi/ic_action_dark_settings.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-mdpi/ic_action_dark_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-mdpi/ic_action_dark_settings.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xhdpi/ic_action_dark_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xhdpi/ic_action_dark_settings.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_action_dark_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/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/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_action_dark_settings.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_action_dark_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_action_dark_filter.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_theme_description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_theme_description.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 项目简介
2 |
3 | 自行编译支持Https的ijkplayer
4 |
5 | 使用方法:直接拿aar目录下的aar文件使用即可,或者:
6 | 自行编译ijkplayer,把so库丢ijk-player的libs库下,
7 | 然后打包成aar即可,更多内容可见:
8 | https://juejin.im/post/5a65b11a6fb9a01ca56097d2
9 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-hdpi/ic_action_dark_aspect_ratio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-hdpi/ic_action_dark_aspect_ratio.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-mdpi/ic_action_dark_aspect_ratio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-mdpi/ic_action_dark_aspect_ratio.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_action_dark_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_action_dark_settings.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xhdpi/ic_action_dark_aspect_ratio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xhdpi/ic_action_dark_aspect_ratio.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_action_dark_aspect_ratio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xxhdpi/ic_action_dark_aspect_ratio.png
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_action_dark_aspect_ratio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coder-pig/ijkplayer/HEAD/ijkplayer-example/src/main/res/drawable-xxxhdpi/ic_action_dark_aspect_ratio.png
--------------------------------------------------------------------------------
/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/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/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-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 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Aug 24 16:26:25 CST 2016
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.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
8 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/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-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-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/res/layout/table_media_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/table_media_info_section.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/activity_app.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/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-example/src/main/res/layout/widget_toolbar.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
14 |
15 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/fragment_track_list.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
17 |
18 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/menu/menu_app.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/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-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/main/res/layout/table_media_info_row1.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/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/layout/fragment_file_list_item.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
13 |
14 |
21 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
12 |
13 |
19 |
20 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/table_media_info_row2.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
23 |
24 |
--------------------------------------------------------------------------------
/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 26
7 | //noinspection GroovyAssignabilityCheck
8 | buildToolsVersion "26.0.2"
9 |
10 | lintOptions {
11 | abortOnError false
12 | }
13 | defaultConfig {
14 | minSdkVersion 9
15 | targetSdkVersion 26
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | sourceSets.main {
24 | jniLibs.srcDirs 'src/main/libs'
25 | jni.srcDirs = [] // This prevents the auto generation of Android.mk
26 | }
27 | }
28 |
29 | dependencies {
30 | compile fileTree(dir: 'libs', include: ['*.jar'])
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/pragma/Pragma.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 Bilibili
3 | * Copyright (C) 2013 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package tv.danmaku.ijk.media.player.pragma;
18 |
19 | /*-
20 | * configurated by app project
21 | */
22 | public class Pragma {
23 | public static final boolean ENABLE_VERBOSE = true;
24 | }
25 |
--------------------------------------------------------------------------------
/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-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-java/src/main/java/tv/danmaku/ijk/media/player/IjkLibLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Bilibili
3 | * Copyright (C) 2013-2014 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player;
19 |
20 | public interface IjkLibLoader {
21 | void loadLibrary(String libName) throws UnsatisfiedLinkError,
22 | SecurityException;
23 | }
24 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/ISurfaceTextureHost.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player;
19 |
20 | import android.graphics.SurfaceTexture;
21 |
22 | public interface ISurfaceTextureHost {
23 | void releaseSurfaceTexture(SurfaceTexture surfaceTexture);
24 | }
25 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/exceptions/IjkMediaException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Bilibili
3 | * Copyright (C) 2013-2014 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player.exceptions;
19 |
20 | public class IjkMediaException extends Exception {
21 | private static final long serialVersionUID = 7234796519009099506L;
22 | }
23 |
--------------------------------------------------------------------------------
/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/menu/menu_player.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/layout/fragment_file_list.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
19 |
20 |
26 |
27 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/MediaInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Bilibili
3 | * Copyright (C) 2013-2014 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player;
19 |
20 | public class MediaInfo {
21 | public String mMediaPlayerName;
22 |
23 | public String mVideoDecoder;
24 | public String mVideoDecoderImpl;
25 |
26 | public String mAudioDecoder;
27 | public String mAudioDecoderImpl;
28 |
29 | public IjkMediaMeta mMeta;
30 | }
31 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/IMediaFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player.misc;
19 |
20 | public interface IMediaFormat {
21 | // Common keys
22 | String KEY_MIME = "mime";
23 |
24 | // Video Keys
25 | String KEY_WIDTH = "width";
26 | String KEY_HEIGHT = "height";
27 |
28 | String getString(String name);
29 |
30 | int getInteger(String name);
31 | }
32 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/ISurfaceTextureHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player;
19 |
20 | import android.graphics.SurfaceTexture;
21 |
22 | public interface ISurfaceTextureHolder {
23 | void setSurfaceTexture(SurfaceTexture surfaceTexture);
24 |
25 | SurfaceTexture getSurfaceTexture();
26 |
27 | void setSurfaceTextureHost(ISurfaceTextureHost surfaceTextureHost);
28 | }
29 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/IMediaDataSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player.misc;
19 |
20 | import java.io.IOException;
21 |
22 | @SuppressWarnings("RedundantThrows")
23 | public interface IMediaDataSource {
24 | int readAt(long position, byte[] buffer, int offset, int size) throws IOException;
25 |
26 | long getSize() throws IOException;
27 |
28 | void close() throws IOException;
29 | }
30 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/IAndroidIO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Bilibili
3 | * Copyright (C) 2016 Raymond Zheng
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player.misc;
19 |
20 | import java.io.IOException;
21 |
22 | @SuppressWarnings("RedundantThrows")
23 | public interface IAndroidIO {
24 | int open(String url) throws IOException;
25 | int read(byte[] buffer, int size) throws IOException;
26 | long seek(long offset, int whence) throws IOException;
27 | int close() throws IOException;
28 | }
29 |
--------------------------------------------------------------------------------
/tools/gradle-on-demand.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 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 | gradle.startParameter.taskNames.each { task ->
18 | def taskName = task.split(":").last()
19 | switch (taskName) {
20 | case "uploadArchives":
21 | apply from: new File(rootProject.projectDir, 'tools/gradle-mvn-push.gradle')
22 | break;
23 | case "bintrayUpload":
24 | apply from: new File(rootProject.projectDir, 'tools/gradle-bintray-upload.gradle')
25 | break;
26 | default:
27 | // do nothing
28 | break;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/ITrackInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player.misc;
19 |
20 | public interface ITrackInfo {
21 | int MEDIA_TRACK_TYPE_AUDIO = 2;
22 | int MEDIA_TRACK_TYPE_METADATA = 5;
23 | int MEDIA_TRACK_TYPE_SUBTITLE = 4;
24 | int MEDIA_TRACK_TYPE_TIMEDTEXT = 3;
25 | int MEDIA_TRACK_TYPE_UNKNOWN = 0;
26 | int MEDIA_TRACK_TYPE_VIDEO = 1;
27 |
28 | IMediaFormat getFormat();
29 |
30 | String getLanguage();
31 |
32 | int getTrackType();
33 |
34 | String getInfoInline();
35 | }
36 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/annotations/AccessedByNative.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Bilibili
3 | * Copyright (C) 2013-2014 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player.annotations;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * is used by the JNI generator to create the necessary JNI
27 | * bindings and expose this method to native code.
28 | */
29 | @Target(ElementType.FIELD)
30 | @Retention(RetentionPolicy.CLASS)
31 | public @interface AccessedByNative {
32 | }
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/IjkTimedText.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Zheng Yuan
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.Rect;
20 | import java.lang.String;
21 |
22 | public final class IjkTimedText {
23 |
24 | private Rect mTextBounds = null;
25 | private String mTextChars = null;
26 |
27 | public IjkTimedText(Rect bounds, String text) {
28 | mTextBounds = bounds;
29 | mTextChars = text;
30 | }
31 |
32 | public Rect getBounds() {
33 | return mTextBounds;
34 | }
35 |
36 | public String getText() {
37 | return mTextChars;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/media/IMediaController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.widget.media;
19 |
20 | import android.view.View;
21 | import android.widget.MediaController;
22 |
23 | public interface IMediaController {
24 | void hide();
25 |
26 | boolean isShowing();
27 |
28 | void setAnchorView(View view);
29 |
30 | void setEnabled(boolean enabled);
31 |
32 | void setMediaPlayer(MediaController.MediaPlayerControl player);
33 |
34 | void show(int timeout);
35 |
36 | void show();
37 |
38 | //----------
39 | // Extends
40 | //----------
41 | void showOnce(View view);
42 | }
43 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/fragments/SettingsFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.fragments;
19 |
20 | import android.os.Bundle;
21 | import android.support.v7.preference.PreferenceFragmentCompat;
22 |
23 | import tv.danmaku.ijk.media.example.R;
24 |
25 | public class SettingsFragment extends PreferenceFragmentCompat {
26 | public static SettingsFragment newInstance() {
27 | SettingsFragment f = new SettingsFragment();
28 | return f;
29 | }
30 |
31 | @Override
32 | public void onCreatePreferences(Bundle bundle, String s) {
33 | addPreferencesFromResource(R.xml.settings);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/annotations/CalledByNative.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Bilibili
3 | * Copyright (C) 2013-2014 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player.annotations;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * is used by the JNI generator to create the necessary JNI
27 | * bindings and expose this method to native code.
28 | */
29 | @Target(ElementType.METHOD)
30 | @Retention(RetentionPolicy.CLASS)
31 | public @interface CalledByNative {
32 | /*
33 | * If present, tells which inner class the method belongs to.
34 | */
35 | String value() default "";
36 | }
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/eventbus/FileExplorerEvents.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.eventbus;
19 |
20 | import com.squareup.otto.Bus;
21 |
22 | import java.io.File;
23 |
24 | public class FileExplorerEvents {
25 | private static final Bus BUS = new Bus();
26 |
27 | public static Bus getBus() {
28 | return BUS;
29 | }
30 |
31 | private FileExplorerEvents() {
32 | // No instances.
33 | }
34 |
35 | public static class OnClickFile {
36 | public File mFile;
37 |
38 | public OnClickFile(String path) {
39 | this(new File(path));
40 | }
41 |
42 | public OnClickFile(File file) {
43 | mFile = file;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/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.8.4
21 | VERSION_CODE=800400
22 | GROUP=tv.danmaku.ijk.media
23 |
24 | # http://central.sonatype.org/pages/requirements.html
25 | POM_USER_ORG=bilibili
26 | POM_DESCRIPTION=Video player based on FFmpeg n3.1
27 | POM_URL=https://github.com/Bilibili/ijkplayer
28 | POM_SCM_URL=https://github.com/Bilibili/ijkplayer
29 | POM_SCM_CONNECTION=scm:git:git@github.com:Bilibili/ijkplayer.git
30 | POM_SCM_DEV_CONNECTION=scm:git:git@github.com:Bilibili/ijkplayer.git
31 | POM_LICENSE_NAME=LGPL-2.1
32 | POM_LICENSE_URL=https://www.gnu.org/licenses/lgpl-2.1.html
33 | POM_LICENSE_DIST=repo
34 | POM_DEVELOPER_ID=bbcallen
35 | POM_DEVELOPER_NAME=Zhang Rui
36 | POM_DEVELOPER_EMAIL=bbcallen@gmail.com
37 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/content/PathCursorLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.content;
19 |
20 | import android.content.Context;
21 | import android.database.Cursor;
22 | import android.os.Environment;
23 | import android.support.v4.content.AsyncTaskLoader;
24 |
25 | import java.io.File;
26 |
27 | public class PathCursorLoader extends AsyncTaskLoader {
28 | private File mPath;
29 |
30 | public PathCursorLoader(Context context) {
31 | this(context, Environment.getExternalStorageDirectory());
32 | }
33 |
34 | public PathCursorLoader(Context context, String path) {
35 | super(context);
36 | mPath = new File(path).getAbsoluteFile();
37 | }
38 |
39 | public PathCursorLoader(Context context, File path) {
40 | super(context);
41 | mPath = path;
42 | }
43 |
44 | @Override
45 | public Cursor loadInBackground() {
46 | File[] file_list = mPath.listFiles();
47 | return new PathCursor(mPath, file_list);
48 | }
49 |
50 | @Override
51 | protected void onStartLoading() {
52 | forceLoad();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/media/FileMediaDataSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.widget.media;
19 |
20 | import java.io.File;
21 | import java.io.FileInputStream;
22 | import java.io.FileNotFoundException;
23 | import java.io.IOException;
24 | import java.io.RandomAccessFile;
25 |
26 | import tv.danmaku.ijk.media.player.misc.IMediaDataSource;
27 |
28 | public class FileMediaDataSource implements IMediaDataSource {
29 | private RandomAccessFile mFile;
30 | private long mFileSize;
31 |
32 | public FileMediaDataSource(File file) throws IOException {
33 | mFile = new RandomAccessFile(file, "r");
34 | mFileSize = mFile.length();
35 | }
36 |
37 | @Override
38 | public int readAt(long position, byte[] buffer, int offset, int size) throws IOException {
39 | if (mFile.getFilePointer() != position)
40 | mFile.seek(position);
41 |
42 | if (size == 0)
43 | return 0;
44 |
45 | return mFile.read(buffer, 0, size);
46 | }
47 |
48 | @Override
49 | public long getSize() throws IOException {
50 | return mFileSize;
51 | }
52 |
53 | @Override
54 | public void close() throws IOException {
55 | mFileSize = 0;
56 | mFile.close();
57 | mFile = null;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/AndroidMediaFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player.misc;
19 |
20 | import android.annotation.TargetApi;
21 | import android.media.MediaFormat;
22 | import android.os.Build;
23 |
24 | public class AndroidMediaFormat implements IMediaFormat {
25 | private final MediaFormat mMediaFormat;
26 |
27 | public AndroidMediaFormat(MediaFormat mediaFormat) {
28 | mMediaFormat = mediaFormat;
29 | }
30 |
31 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
32 | @Override
33 | public int getInteger(String name) {
34 | if (mMediaFormat == null)
35 | return 0;
36 |
37 | return mMediaFormat.getInteger(name);
38 | }
39 |
40 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
41 | @Override
42 | public String getString(String name) {
43 | if (mMediaFormat == null)
44 | return null;
45 |
46 | return mMediaFormat.getString(name);
47 | }
48 |
49 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
50 | @Override
51 | public String toString() {
52 | StringBuilder out = new StringBuilder(128);
53 | out.append(getClass().getName());
54 | out.append('{');
55 | if (mMediaFormat != null) {
56 | out.append(mMediaFormat.toString());
57 | } else {
58 | out.append("null");
59 | }
60 | out.append('}');
61 | return out.toString();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/activities/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.activities;
19 |
20 | import android.content.Context;
21 | import android.content.Intent;
22 | import android.os.Bundle;
23 | import android.support.v4.app.Fragment;
24 | import android.support.v4.app.FragmentTransaction;
25 | import android.support.v7.app.AppCompatActivity;
26 | import android.support.v7.widget.Toolbar;
27 |
28 | import tv.danmaku.ijk.media.example.R;
29 | import tv.danmaku.ijk.media.example.fragments.SettingsFragment;
30 |
31 | public class SettingsActivity extends AppCompatActivity {
32 | public static Intent newIntent(Context context) {
33 | Intent intent = new Intent(context, SettingsActivity.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 | setContentView(R.layout.activity_app);
45 |
46 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
47 | setSupportActionBar(toolbar);
48 |
49 | Fragment newFragment = SettingsFragment.newInstance();
50 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
51 | transaction.replace(R.id.body, newFragment);
52 | transaction.commit();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/services/MediaPlayerService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.services;
19 |
20 | import android.app.Service;
21 | import android.content.Context;
22 | import android.content.Intent;
23 | import android.os.IBinder;
24 | import android.support.annotation.Nullable;
25 |
26 | import tv.danmaku.ijk.media.player.IMediaPlayer;
27 |
28 | public class MediaPlayerService extends Service {
29 | private static IMediaPlayer sMediaPlayer;
30 |
31 | public static Intent newIntent(Context context) {
32 | Intent intent = new Intent(context, MediaPlayerService.class);
33 | return intent;
34 | }
35 |
36 | public static void intentToStart(Context context) {
37 | context.startService(newIntent(context));
38 | }
39 |
40 | public static void intentToStop(Context context) {
41 | context.stopService(newIntent(context));
42 | }
43 |
44 | @Nullable
45 | @Override
46 | public IBinder onBind(Intent intent) {
47 | return null;
48 | }
49 |
50 | public static void setMediaPlayer(IMediaPlayer mp) {
51 | if (sMediaPlayer != null && sMediaPlayer != mp) {
52 | if (sMediaPlayer.isPlaying())
53 | sMediaPlayer.stop();
54 | sMediaPlayer.release();
55 | sMediaPlayer = null;
56 | }
57 | sMediaPlayer = mp;
58 | }
59 |
60 | public static IMediaPlayer getMediaPlayer() {
61 | return sMediaPlayer;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/activities/RecentMediaActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.activities;
19 |
20 | import android.content.Context;
21 | import android.content.Intent;
22 | import android.os.Bundle;
23 | import android.support.v4.app.Fragment;
24 | import android.support.v4.app.FragmentTransaction;
25 | import android.view.Menu;
26 | import android.view.MenuItem;
27 |
28 | import tv.danmaku.ijk.media.example.R;
29 | import tv.danmaku.ijk.media.example.application.AppActivity;
30 | import tv.danmaku.ijk.media.example.fragments.RecentMediaListFragment;
31 |
32 | public class RecentMediaActivity extends AppActivity {
33 | public static Intent newIntent(Context context) {
34 | Intent intent = new Intent(context, RecentMediaActivity.class);
35 | return intent;
36 | }
37 |
38 | public static void intentTo(Context context) {
39 | context.startActivity(newIntent(context));
40 | }
41 |
42 | @Override
43 | protected void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 |
46 | Fragment newFragment = RecentMediaListFragment.newInstance();
47 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
48 |
49 | transaction.replace(R.id.body, newFragment);
50 | transaction.commit();
51 | }
52 |
53 | @Override
54 | public boolean onPrepareOptionsMenu(Menu menu) {
55 | boolean show = super.onPrepareOptionsMenu(menu);
56 | if (!show)
57 | return show;
58 |
59 | MenuItem item = menu.findItem(R.id.action_recent);
60 | if (item != null)
61 | item.setVisible(false);
62 |
63 | return true;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/activities/SampleMediaActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.activities;
19 |
20 | import android.content.Context;
21 | import android.content.Intent;
22 | import android.os.Bundle;
23 | import android.support.v4.app.Fragment;
24 | import android.support.v4.app.FragmentTransaction;
25 | import android.view.Menu;
26 | import android.view.MenuItem;
27 |
28 | import tv.danmaku.ijk.media.example.R;
29 | import tv.danmaku.ijk.media.example.application.AppActivity;
30 | import tv.danmaku.ijk.media.example.fragments.SampleMediaListFragment;
31 |
32 | public class SampleMediaActivity extends AppActivity {
33 | public static Intent newIntent(Context context) {
34 | Intent intent = new Intent(context, SampleMediaActivity.class);
35 | return intent;
36 | }
37 |
38 | public static void intentTo(Context context) {
39 | context.startActivity(newIntent(context));
40 | }
41 |
42 | @Override
43 | protected void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 |
46 | Fragment newFragment = SampleMediaListFragment.newInstance();
47 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
48 |
49 | transaction.replace(R.id.body, newFragment);
50 | transaction.commit();
51 | }
52 |
53 | @Override
54 | public boolean onPrepareOptionsMenu(Menu menu) {
55 | boolean show = super.onPrepareOptionsMenu(menu);
56 | if (!show)
57 | return show;
58 |
59 | MenuItem item = menu.findItem(R.id.action_recent);
60 | if (item != null)
61 | item.setVisible(false);
62 |
63 | return true;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 : System.getenv('BINTRAY_USER')
25 | key = project.hasProperty('BINTRAY_APIKEY') ? BINTRAY_APIKEY : System.getenv('BINTRAY_APIKEY')
26 |
27 | configurations = ['archives']
28 |
29 | dryRun = false
30 | publish = true
31 |
32 | pkg {
33 | repo = 'maven'
34 | name = POM_NAME
35 | userOrg = POM_USER_ORG
36 | desc = POM_DESCRIPTION
37 | websiteUrl = POM_URL
38 | vcsUrl = POM_SCM_URL
39 | licenses = [POM_LICENSE_NAME]
40 | labels = ['FFmpeg', 'Android', 'player']
41 | publicDownloadNumbers = true
42 | version {
43 | name = VERSION_NAME
44 | gpg {
45 | sign = true
46 | passphrase = project.hasProperty('GPG_PASSWORD') ? GPG_PASSWORD : System.getenv('GPG_PASSWORD')
47 | }
48 | }
49 | }
50 | }
51 |
52 | install {
53 | repositories.mavenInstaller {
54 | pom.project {
55 | name POM_NAME
56 | packaging POM_PACKAGING
57 | description POM_DESCRIPTION
58 | url POM_URL
59 |
60 | licenses {
61 | license {
62 | name POM_LICENSE_NAME
63 | url POM_LICENSE_URL
64 | distribution POM_LICENSE_DIST
65 | }
66 | }
67 |
68 | scm {
69 | url POM_SCM_URL
70 | connection POM_SCM_CONNECTION
71 | developerConnection POM_SCM_DEV_CONNECTION
72 | }
73 |
74 | developers {
75 | developer {
76 | id POM_DEVELOPER_ID
77 | name POM_DEVELOPER_NAME
78 | email POM_DEVELOPER_EMAIL
79 | }
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/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/src/main/java/tv/danmaku/ijk/media/example/widget/media/AndroidMediaController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.widget.media;
19 |
20 | import android.content.Context;
21 | import android.support.annotation.NonNull;
22 | import android.support.annotation.Nullable;
23 | import android.support.v7.app.ActionBar;
24 | import android.util.AttributeSet;
25 | import android.view.View;
26 | import android.widget.MediaController;
27 |
28 | import java.util.ArrayList;
29 |
30 | public class AndroidMediaController extends MediaController implements IMediaController {
31 | private ActionBar mActionBar;
32 |
33 | public AndroidMediaController(Context context, AttributeSet attrs) {
34 | super(context, attrs);
35 | initView(context);
36 | }
37 |
38 | public AndroidMediaController(Context context, boolean useFastForward) {
39 | super(context, useFastForward);
40 | initView(context);
41 | }
42 |
43 | public AndroidMediaController(Context context) {
44 | super(context);
45 | initView(context);
46 | }
47 |
48 | private void initView(Context context) {
49 | }
50 |
51 | public void setSupportActionBar(@Nullable ActionBar actionBar) {
52 | mActionBar = actionBar;
53 | if (isShowing()) {
54 | actionBar.show();
55 | } else {
56 | actionBar.hide();
57 | }
58 | }
59 |
60 | @Override
61 | public void show() {
62 | super.show();
63 | if (mActionBar != null)
64 | mActionBar.show();
65 | }
66 |
67 | @Override
68 | public void hide() {
69 | super.hide();
70 | if (mActionBar != null)
71 | mActionBar.hide();
72 | for (View view : mShowOnceArray)
73 | view.setVisibility(View.GONE);
74 | mShowOnceArray.clear();
75 | }
76 |
77 | //----------
78 | // Extends
79 | //----------
80 | private ArrayList mShowOnceArray = new ArrayList();
81 |
82 | public void showOnce(@NonNull View view) {
83 | mShowOnceArray.add(view);
84 | view.setVisibility(View.VISIBLE);
85 | show();
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/media/IRenderView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.widget.media;
19 |
20 | import android.graphics.SurfaceTexture;
21 | import android.support.annotation.NonNull;
22 | import android.support.annotation.Nullable;
23 | import android.view.Surface;
24 | import android.view.SurfaceHolder;
25 | import android.view.View;
26 |
27 | import tv.danmaku.ijk.media.player.IMediaPlayer;
28 |
29 | public interface IRenderView {
30 | int AR_ASPECT_FIT_PARENT = 0; // without clip
31 | int AR_ASPECT_FILL_PARENT = 1; // may clip
32 | int AR_ASPECT_WRAP_CONTENT = 2;
33 | int AR_MATCH_PARENT = 3;
34 | int AR_16_9_FIT_PARENT = 4;
35 | int AR_4_3_FIT_PARENT = 5;
36 |
37 | View getView();
38 |
39 | boolean shouldWaitForResize();
40 |
41 | void setVideoSize(int videoWidth, int videoHeight);
42 |
43 | void setVideoSampleAspectRatio(int videoSarNum, int videoSarDen);
44 |
45 | void setVideoRotation(int degree);
46 |
47 | void setAspectRatio(int aspectRatio);
48 |
49 | void addRenderCallback(@NonNull IRenderCallback callback);
50 |
51 | void removeRenderCallback(@NonNull IRenderCallback callback);
52 |
53 | interface ISurfaceHolder {
54 | void bindToMediaPlayer(IMediaPlayer mp);
55 |
56 | @NonNull
57 | IRenderView getRenderView();
58 |
59 | @Nullable
60 | SurfaceHolder getSurfaceHolder();
61 |
62 | @Nullable
63 | Surface openSurface();
64 |
65 | @Nullable
66 | SurfaceTexture getSurfaceTexture();
67 | }
68 |
69 | interface IRenderCallback {
70 | /**
71 | * @param holder
72 | * @param width could be 0
73 | * @param height could be 0
74 | */
75 | void onSurfaceCreated(@NonNull ISurfaceHolder holder, int width, int height);
76 |
77 | /**
78 | * @param holder
79 | * @param format could be 0
80 | * @param width
81 | * @param height
82 | */
83 | void onSurfaceChanged(@NonNull ISurfaceHolder holder, int format, int width, int height);
84 |
85 | void onSurfaceDestroyed(@NonNull ISurfaceHolder holder);
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/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 | lintOptions {
11 | abortOnError false
12 | }
13 | defaultConfig {
14 | applicationId "tv.danmaku.ijk.media.example"
15 | minSdkVersion 9
16 | targetSdkVersion rootProject.ext.targetSdkVersion
17 | versionCode rootProject.ext.versionCode
18 | versionName rootProject.ext.versionName
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | productFlavors {
27 | all32 { minSdkVersion 9 }
28 | all64 { minSdkVersion 21 }
29 | // armv5 {}
30 | // armv7a {}
31 | // arm64 { minSdkVersion 21 }
32 | // x86 {}
33 | }
34 | }
35 |
36 | dependencies {
37 | compile fileTree(include: ['*.jar'], dir: 'libs')
38 | compile 'com.android.support:appcompat-v7:23.0.1'
39 | compile 'com.android.support:preference-v7:23.0.1'
40 | compile 'com.android.support:support-annotations:23.0.1'
41 |
42 | compile 'com.squareup:otto:1.3.8'
43 |
44 | compile project(':ijkplayer-java')
45 |
46 |
47 |
48 | // compile project(':ijkplayer-exo')
49 |
50 | // all32Compile project(':ijkplayer-armv5')
51 | // all32Compile project(':ijkplayer-armv7a')
52 | // all32Compile project(':ijkplayer-x86')
53 | //
54 | // all64Compile project(':ijkplayer-armv5')
55 | // all64Compile project(':ijkplayer-armv7a')
56 | // all64Compile project(':ijkplayer-arm64')
57 | // all64Compile project(':ijkplayer-x86')
58 | // all64Compile project(':ijkplayer-x86_64')
59 |
60 | // compile 'tv.danmaku.ijk.media:ijkplayer-java:0.8.4'
61 | // compile 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.4'
62 |
63 | // all32Compile 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.4'
64 | // all32Compile 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.4'
65 | // all32Compile 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.4'
66 |
67 | // all64Compile 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.4'
68 | // all64Compile 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.4'
69 | // all64Compile 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.4'
70 | // all64Compile 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.4'
71 | // all64Compile 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.4'
72 |
73 | // armv5Compile project(':player-armv5')
74 | // armv7aCompile project(':player-armv7a')
75 | // arm64Compile project(':player-arm64')
76 | // x86Compile project(':player-x86')
77 | // x86_64Compile project(':player-x86_64')
78 | }
79 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/media/MediaPlayerCompat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.widget.media;
19 |
20 | import tv.danmaku.ijk.media.player.IMediaPlayer;
21 | import tv.danmaku.ijk.media.player.IjkMediaPlayer;
22 | import tv.danmaku.ijk.media.player.MediaPlayerProxy;
23 | import tv.danmaku.ijk.media.player.TextureMediaPlayer;
24 |
25 | public class MediaPlayerCompat {
26 | public static String getName(IMediaPlayer mp) {
27 | if (mp == null) {
28 | return "null";
29 | } else if (mp instanceof TextureMediaPlayer) {
30 | StringBuilder sb = new StringBuilder("TextureMediaPlayer <");
31 | IMediaPlayer internalMediaPlayer = ((TextureMediaPlayer) mp).getInternalMediaPlayer();
32 | if (internalMediaPlayer == null) {
33 | sb.append("null>");
34 | } else {
35 | sb.append(internalMediaPlayer.getClass().getSimpleName());
36 | sb.append(">");
37 | }
38 | return sb.toString();
39 | } else {
40 | return mp.getClass().getSimpleName();
41 | }
42 | }
43 |
44 | public static IjkMediaPlayer getIjkMediaPlayer(IMediaPlayer mp) {
45 | IjkMediaPlayer ijkMediaPlayer = null;
46 | if (mp == null) {
47 | return null;
48 | } if (mp instanceof IjkMediaPlayer) {
49 | ijkMediaPlayer = (IjkMediaPlayer) mp;
50 | } else if (mp instanceof MediaPlayerProxy && ((MediaPlayerProxy) mp).getInternalMediaPlayer() instanceof IjkMediaPlayer) {
51 | ijkMediaPlayer = (IjkMediaPlayer) ((MediaPlayerProxy) mp).getInternalMediaPlayer();
52 | }
53 | return ijkMediaPlayer;
54 | }
55 |
56 | public static void selectTrack(IMediaPlayer mp, int stream) {
57 | IjkMediaPlayer ijkMediaPlayer = getIjkMediaPlayer(mp);
58 | if (ijkMediaPlayer == null)
59 | return;
60 | ijkMediaPlayer.selectTrack(stream);
61 | }
62 |
63 | public static void deselectTrack(IMediaPlayer mp, int stream) {
64 | IjkMediaPlayer ijkMediaPlayer = getIjkMediaPlayer(mp);
65 | if (ijkMediaPlayer == null)
66 | return;
67 | ijkMediaPlayer.deselectTrack(stream);
68 | }
69 |
70 | public static int getSelectedTrack(IMediaPlayer mp, int trackType) {
71 | IjkMediaPlayer ijkMediaPlayer = getIjkMediaPlayer(mp);
72 | if (ijkMediaPlayer == null)
73 | return -1;
74 | return ijkMediaPlayer.getSelectedTrack(trackType);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/TextureMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player;
19 |
20 | import android.annotation.TargetApi;
21 | import android.graphics.SurfaceTexture;
22 | import android.os.Build;
23 | import android.view.Surface;
24 | import android.view.SurfaceHolder;
25 |
26 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
27 | public class TextureMediaPlayer extends MediaPlayerProxy implements IMediaPlayer, ISurfaceTextureHolder {
28 | private SurfaceTexture mSurfaceTexture;
29 | private ISurfaceTextureHost mSurfaceTextureHost;
30 |
31 | public TextureMediaPlayer(IMediaPlayer backEndMediaPlayer) {
32 | super(backEndMediaPlayer);
33 | }
34 |
35 | public void releaseSurfaceTexture() {
36 | if (mSurfaceTexture != null) {
37 | if (mSurfaceTextureHost != null) {
38 | mSurfaceTextureHost.releaseSurfaceTexture(mSurfaceTexture);
39 | } else {
40 | mSurfaceTexture.release();
41 | }
42 | mSurfaceTexture = null;
43 | }
44 | }
45 |
46 | //--------------------
47 | // IMediaPlayer
48 | //--------------------
49 | @Override
50 | public void reset() {
51 | super.reset();
52 | releaseSurfaceTexture();
53 | }
54 |
55 | @Override
56 | public void release() {
57 | super.release();
58 | releaseSurfaceTexture();
59 | }
60 |
61 | @Override
62 | public void setDisplay(SurfaceHolder sh) {
63 | if (mSurfaceTexture == null)
64 | super.setDisplay(sh);
65 | }
66 |
67 | @Override
68 | public void setSurface(Surface surface) {
69 | if (mSurfaceTexture == null)
70 | super.setSurface(surface);
71 | }
72 |
73 | //--------------------
74 | // ISurfaceTextureHolder
75 | //--------------------
76 |
77 | @Override
78 | public void setSurfaceTexture(SurfaceTexture surfaceTexture) {
79 | if (mSurfaceTexture == surfaceTexture)
80 | return;
81 |
82 | releaseSurfaceTexture();
83 | mSurfaceTexture = surfaceTexture;
84 | if (surfaceTexture == null) {
85 | super.setSurface(null);
86 | } else {
87 | super.setSurface(new Surface(surfaceTexture));
88 | }
89 | }
90 |
91 | @Override
92 | public SurfaceTexture getSurfaceTexture() {
93 | return mSurfaceTexture;
94 | }
95 |
96 | @Override
97 | public void setSurfaceTextureHost(ISurfaceTextureHost surfaceTextureHost) {
98 | mSurfaceTextureHost = surfaceTextureHost;
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/activities/FileExplorerActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.activities;
19 |
20 | import android.os.Bundle;
21 | import android.support.v4.app.Fragment;
22 | import android.support.v4.app.FragmentTransaction;
23 | import android.text.TextUtils;
24 |
25 | import com.squareup.otto.Subscribe;
26 |
27 | import java.io.File;
28 | import java.io.IOException;
29 |
30 | import tv.danmaku.ijk.media.example.R;
31 | import tv.danmaku.ijk.media.example.application.AppActivity;
32 | import tv.danmaku.ijk.media.example.application.Settings;
33 | import tv.danmaku.ijk.media.example.eventbus.FileExplorerEvents;
34 | import tv.danmaku.ijk.media.example.fragments.FileListFragment;
35 |
36 | public class FileExplorerActivity extends AppActivity {
37 | private Settings mSettings;
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 |
43 | if (mSettings == null) {
44 | mSettings = new Settings(this);
45 | }
46 |
47 | String lastDirectory = mSettings.getLastDirectory();
48 | if (!TextUtils.isEmpty(lastDirectory) && new File(lastDirectory).isDirectory())
49 | doOpenDirectory(lastDirectory, false);
50 | else
51 | doOpenDirectory("/", false);
52 | }
53 |
54 | @Override
55 | protected void onResume() {
56 | super.onResume();
57 |
58 | FileExplorerEvents.getBus().register(this);
59 | }
60 |
61 | @Override
62 | protected void onPause() {
63 | super.onPause();
64 |
65 | FileExplorerEvents.getBus().unregister(this);
66 | }
67 |
68 | private void doOpenDirectory(String path, boolean addToBackStack) {
69 | Fragment newFragment = FileListFragment.newInstance(path);
70 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
71 |
72 | transaction.replace(R.id.body, newFragment);
73 |
74 | if (addToBackStack)
75 | transaction.addToBackStack(null);
76 | transaction.commit();
77 | }
78 |
79 | @Subscribe
80 | public void onClickFile(FileExplorerEvents.OnClickFile event) {
81 | File f = event.mFile;
82 | try {
83 | f = f.getAbsoluteFile();
84 | f = f.getCanonicalFile();
85 | if (TextUtils.isEmpty(f.toString()))
86 | f = new File("/");
87 | } catch (IOException e) {
88 | e.printStackTrace();
89 | }
90 |
91 | if (f.isDirectory()) {
92 | String path = f.toString();
93 | mSettings.setLastDirectory(path);
94 | doOpenDirectory(path, true);
95 | } else if (f.exists()) {
96 | VideoActivity.intentTo(this, f.getPath(), f.getName());
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/IjkTrackInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player.misc;
19 |
20 | import android.text.TextUtils;
21 |
22 | import tv.danmaku.ijk.media.player.IjkMediaMeta;
23 |
24 | public class IjkTrackInfo implements ITrackInfo {
25 | private int mTrackType = MEDIA_TRACK_TYPE_UNKNOWN;
26 | private IjkMediaMeta.IjkStreamMeta mStreamMeta;
27 |
28 | public IjkTrackInfo(IjkMediaMeta.IjkStreamMeta streamMeta) {
29 | mStreamMeta = streamMeta;
30 | }
31 |
32 | public void setMediaMeta(IjkMediaMeta.IjkStreamMeta streamMeta) {
33 | mStreamMeta = streamMeta;
34 | }
35 |
36 | @Override
37 | public IMediaFormat getFormat() {
38 | return new IjkMediaFormat(mStreamMeta);
39 | }
40 |
41 | @Override
42 | public String getLanguage() {
43 | if (mStreamMeta == null || TextUtils.isEmpty(mStreamMeta.mLanguage))
44 | return "und";
45 |
46 | return mStreamMeta.mLanguage;
47 | }
48 |
49 | @Override
50 | public int getTrackType() {
51 | return mTrackType;
52 | }
53 |
54 | public void setTrackType(int trackType) {
55 | mTrackType = trackType;
56 | }
57 |
58 | @Override
59 | public String toString() {
60 | return getClass().getSimpleName() + '{' + getInfoInline() + "}";
61 | }
62 |
63 | @Override
64 | public String getInfoInline() {
65 | StringBuilder out = new StringBuilder(128);
66 | switch (mTrackType) {
67 | case MEDIA_TRACK_TYPE_VIDEO:
68 | out.append("VIDEO");
69 | out.append(", ");
70 | out.append(mStreamMeta.getCodecShortNameInline());
71 | out.append(", ");
72 | out.append(mStreamMeta.getBitrateInline());
73 | out.append(", ");
74 | out.append(mStreamMeta.getResolutionInline());
75 | break;
76 | case MEDIA_TRACK_TYPE_AUDIO:
77 | out.append("AUDIO");
78 | out.append(", ");
79 | out.append(mStreamMeta.getCodecShortNameInline());
80 | out.append(", ");
81 | out.append(mStreamMeta.getBitrateInline());
82 | out.append(", ");
83 | out.append(mStreamMeta.getSampleRateInline());
84 | break;
85 | case MEDIA_TRACK_TYPE_TIMEDTEXT:
86 | out.append("TIMEDTEXT");
87 | out.append(", ");
88 | out.append(mStreamMeta.mLanguage);
89 | break;
90 | case MEDIA_TRACK_TYPE_SUBTITLE:
91 | out.append("SUBTITLE");
92 | break;
93 | default:
94 | out.append("UNKNOWN");
95 | break;
96 | }
97 | return out.toString();
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/AndroidTrackInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player.misc;
19 |
20 | import android.annotation.TargetApi;
21 | import android.media.MediaFormat;
22 | import android.media.MediaPlayer;
23 | import android.os.Build;
24 |
25 | public class AndroidTrackInfo implements ITrackInfo {
26 | private final MediaPlayer.TrackInfo mTrackInfo;
27 |
28 | public static AndroidTrackInfo[] fromMediaPlayer(MediaPlayer mp) {
29 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
30 | return fromTrackInfo(mp.getTrackInfo());
31 |
32 | return null;
33 | }
34 |
35 | private static AndroidTrackInfo[] fromTrackInfo(MediaPlayer.TrackInfo[] trackInfos) {
36 | if (trackInfos == null)
37 | return null;
38 |
39 | AndroidTrackInfo androidTrackInfo[] = new AndroidTrackInfo[trackInfos.length];
40 | for (int i = 0; i < trackInfos.length; ++i) {
41 | androidTrackInfo[i] = new AndroidTrackInfo(trackInfos[i]);
42 | }
43 |
44 | return androidTrackInfo;
45 | }
46 |
47 | private AndroidTrackInfo(MediaPlayer.TrackInfo trackInfo) {
48 | mTrackInfo = trackInfo;
49 | }
50 |
51 | @TargetApi(Build.VERSION_CODES.KITKAT)
52 | @Override
53 | public IMediaFormat getFormat() {
54 | if (mTrackInfo == null)
55 | return null;
56 |
57 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
58 | return null;
59 |
60 | MediaFormat mediaFormat = mTrackInfo.getFormat();
61 | if (mediaFormat == null)
62 | return null;
63 |
64 | return new AndroidMediaFormat(mediaFormat);
65 | }
66 |
67 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
68 | @Override
69 | public String getLanguage() {
70 | if (mTrackInfo == null)
71 | return "und";
72 |
73 | return mTrackInfo.getLanguage();
74 | }
75 |
76 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
77 | @Override
78 | public int getTrackType() {
79 | if (mTrackInfo == null)
80 | return MEDIA_TRACK_TYPE_UNKNOWN;
81 |
82 | return mTrackInfo.getTrackType();
83 | }
84 |
85 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
86 | @Override
87 | public String toString() {
88 | StringBuilder out = new StringBuilder(128);
89 | out.append(getClass().getSimpleName());
90 | out.append('{');
91 | if (mTrackInfo != null) {
92 | out.append(mTrackInfo.toString());
93 | } else {
94 | out.append("null");
95 | }
96 | out.append('}');
97 | return out.toString();
98 | }
99 |
100 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
101 | @Override
102 | public String getInfoInline() {
103 | if (mTrackInfo != null) {
104 | return mTrackInfo.toString();
105 | } else {
106 | return "null";
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/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 | load-cost
22 | seek_cost
23 | seek_load_cost
24 | tcp_speed
25 | bit_rate
26 |
27 | Media Information
28 | Player
29 | Media
30 | Profile level
31 | Pixel format
32 | Resolution
33 | Length
34 | Stream #%d
35 | Type
36 | Language
37 | Codec
38 | Frame rate
39 | Bit rate
40 | Sample rate
41 | Channels
42 | *
43 | *
44 | *
45 |
46 | Video
47 | Audio
48 | Subtitle
49 | Timed text
50 | Meta data
51 | Unknown
52 |
53 | Invalid progressive playback
54 | Unknown
55 | OK
56 |
57 | Aspect / Fit parent
58 | Aspect / Fill parent
59 | Aspect / Wrap content
60 | Free / Fill parent
61 | 16:9 / Fit parent
62 | 4:3 / Fit parent
63 |
64 | Render: None
65 | Render: SurfaceView
66 | Render: TextureView
67 |
68 | Player: None
69 | Player: AndroidMediaPlayer
70 | Player: IjkMediaPlayer
71 | Player: IjkExoMediaPlayer
72 |
73 |
74 |
--------------------------------------------------------------------------------
/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/widget/preference/IjkListPreference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.widget.preference;
19 |
20 | import android.content.Context;
21 | import android.content.res.TypedArray;
22 | import android.support.v7.preference.ListPreference;
23 | import android.text.TextUtils;
24 | import android.util.AttributeSet;
25 |
26 | import tv.danmaku.ijk.media.example.R;
27 |
28 | public class IjkListPreference extends ListPreference {
29 | private CharSequence[] mEntrySummaries;
30 |
31 | public IjkListPreference(Context context) {
32 | super(context);
33 | initPreference(context, null);
34 | }
35 |
36 | public IjkListPreference(Context context, AttributeSet attrs) {
37 | super(context, attrs);
38 | initPreference(context, attrs);
39 | }
40 |
41 | public IjkListPreference(Context context, AttributeSet attrs, int defStyleAttr) {
42 | super(context, attrs, defStyleAttr);
43 | initPreference(context, attrs);
44 | }
45 |
46 | public IjkListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
47 | super(context, attrs, defStyleAttr, defStyleRes);
48 | initPreference(context, attrs);
49 | }
50 |
51 | private void initPreference(Context context, AttributeSet attrs) {
52 | TypedArray a = context.obtainStyledAttributes(attrs,
53 | R.styleable.IjkListPreference, 0, 0);
54 | if (a == null)
55 | return;
56 |
57 | mEntrySummaries = a
58 | .getTextArray(R.styleable.IjkListPreference_entrySummaries);
59 |
60 | a.recycle();
61 | }
62 |
63 | @Override
64 | protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
65 | super.onSetInitialValue(restoreValue, defaultValue);
66 | syncSummary();
67 | }
68 |
69 | @Override
70 | public void setValue(String value) {
71 | super.setValue(value);
72 | syncSummary();
73 | }
74 |
75 | @Override
76 | public void setValueIndex(int index) {
77 | super.setValueIndex(index);
78 | syncSummary();
79 | }
80 |
81 | public int getEntryIndex() {
82 | CharSequence[] entryValues = getEntryValues();
83 | CharSequence value = getValue();
84 |
85 | if (entryValues == null || value == null) {
86 | return -1;
87 | }
88 |
89 | for (int i = 0; i < entryValues.length; ++i) {
90 | if (TextUtils.equals(value, entryValues[i])) {
91 | return i;
92 | }
93 | }
94 |
95 | return -1;
96 | }
97 |
98 | // ----- summary --------------------
99 | public void setEntrySummaries(Context context, int resId) {
100 | setEntrySummaries(context.getResources().getTextArray(resId));
101 | }
102 |
103 | public void setEntrySummaries(CharSequence[] entrySummaries) {
104 | mEntrySummaries = entrySummaries;
105 | notifyChanged();
106 | }
107 |
108 | public CharSequence[] getEntrySummaries() {
109 | return mEntrySummaries;
110 | }
111 |
112 | private void syncSummary() {
113 | int index = getEntryIndex();
114 | if (index < 0)
115 | return;
116 |
117 | if (mEntrySummaries != null && index < mEntrySummaries.length) {
118 | setSummary(mEntrySummaries[index]);
119 | } else {
120 | setSummary(getEntries()[index]);
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/application/AppActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.application;
19 |
20 | import android.Manifest;
21 | import android.annotation.SuppressLint;
22 | import android.content.pm.PackageManager;
23 | import android.os.Bundle;
24 | import android.support.v4.app.ActivityCompat;
25 | import android.support.v4.content.ContextCompat;
26 | import android.support.v7.app.AppCompatActivity;
27 | import android.support.v7.widget.Toolbar;
28 | import android.view.Menu;
29 | import android.view.MenuItem;
30 |
31 | import tv.danmaku.ijk.media.example.R;
32 | import tv.danmaku.ijk.media.example.activities.RecentMediaActivity;
33 | import tv.danmaku.ijk.media.example.activities.SampleMediaActivity;
34 | import tv.danmaku.ijk.media.example.activities.SettingsActivity;
35 |
36 | @SuppressLint("Registered")
37 | public class AppActivity extends AppCompatActivity {
38 | private static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1;
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 | if (ContextCompat.checkSelfPermission(this,
49 | Manifest.permission.READ_EXTERNAL_STORAGE)
50 | != PackageManager.PERMISSION_GRANTED) {
51 | if (ActivityCompat.shouldShowRequestPermissionRationale(this,
52 | Manifest.permission.READ_EXTERNAL_STORAGE)) {
53 | // TODO: show explanation
54 | } else {
55 | ActivityCompat.requestPermissions(this,
56 | new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
57 | MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
58 | }
59 | }
60 | }
61 |
62 | @Override
63 | public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
64 | switch (requestCode) {
65 | case MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE: {
66 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
67 | // permission was granted, yay! Do the task you need to do.
68 | } else {
69 | // permission denied, boo! Disable the functionality that depends on this permission.
70 | }
71 | }
72 | }
73 | }
74 |
75 | @Override
76 | public boolean onCreateOptionsMenu(Menu menu) {
77 | getMenuInflater().inflate(R.menu.menu_app, menu);
78 | return true;
79 | }
80 |
81 | @Override
82 | public boolean onOptionsItemSelected(MenuItem item) {
83 | int id = item.getItemId();
84 | if (id == R.id.action_settings) {
85 | SettingsActivity.intentTo(this);
86 | return true;
87 | } else if (id == R.id.action_recent) {
88 | RecentMediaActivity.intentTo(this);
89 | } else if (id == R.id.action_sample) {
90 | SampleMediaActivity.intentTo(this);
91 | }
92 |
93 | return super.onOptionsItemSelected(item);
94 | }
95 |
96 | @Override
97 | public boolean onPrepareOptionsMenu(Menu menu) {
98 | boolean show = super.onPrepareOptionsMenu(menu);
99 | if (!show)
100 | return show;
101 |
102 | return true;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/pragma/DebugLog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 Bilibili
3 | * Copyright (C) 2013 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player.pragma;
19 |
20 | import java.util.Locale;
21 |
22 |
23 | import android.util.Log;
24 |
25 | @SuppressWarnings({"SameParameterValue", "WeakerAccess"})
26 | public class DebugLog {
27 | public static final boolean ENABLE_ERROR = Pragma.ENABLE_VERBOSE;
28 | public static final boolean ENABLE_INFO = Pragma.ENABLE_VERBOSE;
29 | public static final boolean ENABLE_WARN = Pragma.ENABLE_VERBOSE;
30 | public static final boolean ENABLE_DEBUG = Pragma.ENABLE_VERBOSE;
31 | public static final boolean ENABLE_VERBOSE = Pragma.ENABLE_VERBOSE;
32 |
33 | public static void e(String tag, String msg) {
34 | if (ENABLE_ERROR) {
35 | Log.e(tag, msg);
36 | }
37 | }
38 |
39 | public static void e(String tag, String msg, Throwable tr) {
40 | if (ENABLE_ERROR) {
41 | Log.e(tag, msg, tr);
42 | }
43 | }
44 |
45 | public static void efmt(String tag, String fmt, Object... args) {
46 | if (ENABLE_ERROR) {
47 | String msg = String.format(Locale.US, fmt, args);
48 | Log.e(tag, msg);
49 | }
50 | }
51 |
52 | public static void i(String tag, String msg) {
53 | if (ENABLE_INFO) {
54 | Log.i(tag, msg);
55 | }
56 | }
57 |
58 | public static void i(String tag, String msg, Throwable tr) {
59 | if (ENABLE_INFO) {
60 | Log.i(tag, msg, tr);
61 | }
62 | }
63 |
64 | public static void ifmt(String tag, String fmt, Object... args) {
65 | if (ENABLE_INFO) {
66 | String msg = String.format(Locale.US, fmt, args);
67 | Log.i(tag, msg);
68 | }
69 | }
70 |
71 | public static void w(String tag, String msg) {
72 | if (ENABLE_WARN) {
73 | Log.w(tag, msg);
74 | }
75 | }
76 |
77 | public static void w(String tag, String msg, Throwable tr) {
78 | if (ENABLE_WARN) {
79 | Log.w(tag, msg, tr);
80 | }
81 | }
82 |
83 | public static void wfmt(String tag, String fmt, Object... args) {
84 | if (ENABLE_WARN) {
85 | String msg = String.format(Locale.US, fmt, args);
86 | Log.w(tag, msg);
87 | }
88 | }
89 |
90 | public static void d(String tag, String msg) {
91 | if (ENABLE_DEBUG) {
92 | Log.d(tag, msg);
93 | }
94 | }
95 |
96 | public static void d(String tag, String msg, Throwable tr) {
97 | if (ENABLE_DEBUG) {
98 | Log.d(tag, msg, tr);
99 | }
100 | }
101 |
102 | public static void dfmt(String tag, String fmt, Object... args) {
103 | if (ENABLE_DEBUG) {
104 | String msg = String.format(Locale.US, fmt, args);
105 | Log.d(tag, msg);
106 | }
107 | }
108 |
109 | public static void v(String tag, String msg) {
110 | if (ENABLE_VERBOSE) {
111 | Log.v(tag, msg);
112 | }
113 | }
114 |
115 | public static void v(String tag, String msg, Throwable tr) {
116 | if (ENABLE_VERBOSE) {
117 | Log.v(tag, msg, tr);
118 | }
119 | }
120 |
121 | public static void vfmt(String tag, String fmt, Object... args) {
122 | if (ENABLE_VERBOSE) {
123 | String msg = String.format(Locale.US, fmt, args);
124 | Log.v(tag, msg);
125 | }
126 | }
127 |
128 | public static void printStackTrace(Throwable e) {
129 | if (ENABLE_WARN) {
130 | e.printStackTrace();
131 | }
132 | }
133 |
134 | public static void printCause(Throwable e) {
135 | if (ENABLE_WARN) {
136 | Throwable cause = e.getCause();
137 | if (cause != null)
138 | e = cause;
139 |
140 | printStackTrace(e);
141 | }
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/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 | android.libraryVariants.all { variant ->
92 | if(variant.buildType.name.equals("release")) {
93 | def jarTask = project.tasks.create(name: "jar${variant.name.capitalize()}", type: Jar) {
94 | from variant.javaCompile.destinationDir
95 | exclude "**/R.class"
96 | exclude "**/R\$**.class"
97 | exclude "**/BuildConfig.class"
98 | }
99 | jarTask.dependsOn variant.javaCompile
100 | }
101 | }
102 |
103 | signing {
104 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
105 | sign configurations.archives
106 | }
107 |
108 | task androidJavadocs(type: Javadoc) {
109 | failOnError false
110 | source = android.sourceSets.main.java.srcDirs
111 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
112 | }
113 |
114 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
115 | classifier = 'javadoc'
116 | from androidJavadocs.destinationDir
117 | }
118 |
119 | task androidSourcesJar(type: Jar) {
120 | classifier = 'sources'
121 | from android.sourceSets.main.java.sourceFiles
122 | }
123 |
124 | artifacts {
125 | archives androidSourcesJar
126 | archives androidJavadocsJar
127 | archives jarRelease
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/application/Settings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.application;
19 |
20 | import android.content.Context;
21 | import android.content.SharedPreferences;
22 | import android.preference.PreferenceManager;
23 |
24 | import tv.danmaku.ijk.media.example.R;
25 |
26 | public class Settings {
27 | private Context mAppContext;
28 | private SharedPreferences mSharedPreferences;
29 |
30 | public static final int PV_PLAYER__Auto = 0;
31 | public static final int PV_PLAYER__AndroidMediaPlayer = 1;
32 | public static final int PV_PLAYER__IjkMediaPlayer = 2;
33 | public static final int PV_PLAYER__IjkExoMediaPlayer = 3;
34 |
35 | public Settings(Context context) {
36 | mAppContext = context.getApplicationContext();
37 | mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mAppContext);
38 | }
39 |
40 | public boolean getEnableBackgroundPlay() {
41 | String key = mAppContext.getString(R.string.pref_key_enable_background_play);
42 | return mSharedPreferences.getBoolean(key, false);
43 | }
44 |
45 | public int getPlayer() {
46 | String key = mAppContext.getString(R.string.pref_key_player);
47 | String value = mSharedPreferences.getString(key, "");
48 | try {
49 | return Integer.valueOf(value).intValue();
50 | } catch (NumberFormatException e) {
51 | return 0;
52 | }
53 | }
54 |
55 | public boolean getUsingMediaCodec() {
56 | String key = mAppContext.getString(R.string.pref_key_using_media_codec);
57 | return mSharedPreferences.getBoolean(key, false);
58 | }
59 |
60 | public boolean getUsingMediaCodecAutoRotate() {
61 | String key = mAppContext.getString(R.string.pref_key_using_media_codec_auto_rotate);
62 | return mSharedPreferences.getBoolean(key, false);
63 | }
64 |
65 | public boolean getMediaCodecHandleResolutionChange() {
66 | String key = mAppContext.getString(R.string.pref_key_media_codec_handle_resolution_change);
67 | return mSharedPreferences.getBoolean(key, false);
68 | }
69 |
70 | public boolean getUsingOpenSLES() {
71 | String key = mAppContext.getString(R.string.pref_key_using_opensl_es);
72 | return mSharedPreferences.getBoolean(key, false);
73 | }
74 |
75 | public String getPixelFormat() {
76 | String key = mAppContext.getString(R.string.pref_key_pixel_format);
77 | return mSharedPreferences.getString(key, "");
78 | }
79 |
80 | public boolean getEnableNoView() {
81 | String key = mAppContext.getString(R.string.pref_key_enable_no_view);
82 | return mSharedPreferences.getBoolean(key, false);
83 | }
84 |
85 | public boolean getEnableSurfaceView() {
86 | String key = mAppContext.getString(R.string.pref_key_enable_surface_view);
87 | return mSharedPreferences.getBoolean(key, false);
88 | }
89 |
90 | public boolean getEnableTextureView() {
91 | String key = mAppContext.getString(R.string.pref_key_enable_texture_view);
92 | return mSharedPreferences.getBoolean(key, false);
93 | }
94 |
95 | public boolean getEnableDetachedSurfaceTextureView() {
96 | String key = mAppContext.getString(R.string.pref_key_enable_detached_surface_texture);
97 | return mSharedPreferences.getBoolean(key, false);
98 | }
99 |
100 | public boolean getUsingMediaDataSource() {
101 | String key = mAppContext.getString(R.string.pref_key_using_mediadatasource);
102 | return mSharedPreferences.getBoolean(key, false);
103 | }
104 |
105 | public String getLastDirectory() {
106 | String key = mAppContext.getString(R.string.pref_key_last_directory);
107 | return mSharedPreferences.getString(key, "/");
108 | }
109 |
110 | public void setLastDirectory(String path) {
111 | String key = mAppContext.getString(R.string.pref_key_last_directory);
112 | mSharedPreferences.edit().putString(key, path).apply();
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/AbstractMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Bilibili
3 | * Copyright (C) 2013-2014 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player;
19 |
20 | import tv.danmaku.ijk.media.player.misc.IMediaDataSource;
21 |
22 | @SuppressWarnings("WeakerAccess")
23 | public abstract class AbstractMediaPlayer implements IMediaPlayer {
24 | private OnPreparedListener mOnPreparedListener;
25 | private OnCompletionListener mOnCompletionListener;
26 | private OnBufferingUpdateListener mOnBufferingUpdateListener;
27 | private OnSeekCompleteListener mOnSeekCompleteListener;
28 | private OnVideoSizeChangedListener mOnVideoSizeChangedListener;
29 | private OnErrorListener mOnErrorListener;
30 | private OnInfoListener mOnInfoListener;
31 | private OnTimedTextListener mOnTimedTextListener;
32 |
33 | public final void setOnPreparedListener(OnPreparedListener listener) {
34 | mOnPreparedListener = listener;
35 | }
36 |
37 | public final void setOnCompletionListener(OnCompletionListener listener) {
38 | mOnCompletionListener = listener;
39 | }
40 |
41 | public final void setOnBufferingUpdateListener(
42 | OnBufferingUpdateListener listener) {
43 | mOnBufferingUpdateListener = listener;
44 | }
45 |
46 | public final void setOnSeekCompleteListener(OnSeekCompleteListener listener) {
47 | mOnSeekCompleteListener = listener;
48 | }
49 |
50 | public final void setOnVideoSizeChangedListener(
51 | OnVideoSizeChangedListener listener) {
52 | mOnVideoSizeChangedListener = listener;
53 | }
54 |
55 | public final void setOnErrorListener(OnErrorListener listener) {
56 | mOnErrorListener = listener;
57 | }
58 |
59 | public final void setOnInfoListener(OnInfoListener listener) {
60 | mOnInfoListener = listener;
61 | }
62 |
63 | public final void setOnTimedTextListener(OnTimedTextListener listener) {
64 | mOnTimedTextListener = listener;
65 | }
66 |
67 | public void resetListeners() {
68 | mOnPreparedListener = null;
69 | mOnBufferingUpdateListener = null;
70 | mOnCompletionListener = null;
71 | mOnSeekCompleteListener = null;
72 | mOnVideoSizeChangedListener = null;
73 | mOnErrorListener = null;
74 | mOnInfoListener = null;
75 | mOnTimedTextListener = null;
76 | }
77 |
78 | protected final void notifyOnPrepared() {
79 | if (mOnPreparedListener != null)
80 | mOnPreparedListener.onPrepared(this);
81 | }
82 |
83 | protected final void notifyOnCompletion() {
84 | if (mOnCompletionListener != null)
85 | mOnCompletionListener.onCompletion(this);
86 | }
87 |
88 | protected final void notifyOnBufferingUpdate(int percent) {
89 | if (mOnBufferingUpdateListener != null)
90 | mOnBufferingUpdateListener.onBufferingUpdate(this, percent);
91 | }
92 |
93 | protected final void notifyOnSeekComplete() {
94 | if (mOnSeekCompleteListener != null)
95 | mOnSeekCompleteListener.onSeekComplete(this);
96 | }
97 |
98 | protected final void notifyOnVideoSizeChanged(int width, int height,
99 | int sarNum, int sarDen) {
100 | if (mOnVideoSizeChangedListener != null)
101 | mOnVideoSizeChangedListener.onVideoSizeChanged(this, width, height,
102 | sarNum, sarDen);
103 | }
104 |
105 | protected final boolean notifyOnError(int what, int extra) {
106 | return mOnErrorListener != null && mOnErrorListener.onError(this, what, extra);
107 | }
108 |
109 | protected final boolean notifyOnInfo(int what, int extra) {
110 | return mOnInfoListener != null && mOnInfoListener.onInfo(this, what, extra);
111 | }
112 |
113 | protected final void notifyOnTimedText(IjkTimedText text) {
114 | if (mOnTimedTextListener != null)
115 | mOnTimedTextListener.onTimedText(this, text);
116 | }
117 |
118 | public void setDataSource(IMediaDataSource mediaDataSource) {
119 | throw new UnsupportedOperationException();
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/media/TableLayoutBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.widget.media;
19 |
20 | import android.content.Context;
21 | import android.support.v7.app.AlertDialog;
22 | import android.view.LayoutInflater;
23 | import android.view.View;
24 | import android.view.ViewGroup;
25 | import android.widget.TableLayout;
26 | import android.widget.TextView;
27 |
28 | import tv.danmaku.ijk.media.example.R;
29 |
30 | public class TableLayoutBinder {
31 | private Context mContext;
32 | public ViewGroup mTableView;
33 | public TableLayout mTableLayout;
34 |
35 | public TableLayoutBinder(Context context) {
36 | this(context, R.layout.table_media_info);
37 | }
38 |
39 | public TableLayoutBinder(Context context, int layoutResourceId) {
40 | mContext = context;
41 | mTableView = (ViewGroup) LayoutInflater.from(mContext).inflate(layoutResourceId, null);
42 | mTableLayout = (TableLayout) mTableView.findViewById(R.id.table);
43 | }
44 |
45 | public TableLayoutBinder(Context context, TableLayout tableLayout) {
46 | mContext = context;
47 | mTableView = tableLayout;
48 | mTableLayout = tableLayout;
49 | }
50 |
51 | public View appendRow1(String name, String value) {
52 | return appendRow(R.layout.table_media_info_row1, name, value);
53 | }
54 |
55 | public View appendRow1(int nameId, String value) {
56 | return appendRow1(mContext.getString(nameId), value);
57 | }
58 |
59 | public View appendRow2(String name, String value) {
60 | return appendRow(R.layout.table_media_info_row2, name, value);
61 | }
62 |
63 | public View appendRow2(int nameId, String value) {
64 | return appendRow2(mContext.getString(nameId), value);
65 | }
66 |
67 | public View appendSection(String name) {
68 | return appendRow(R.layout.table_media_info_section, name, null);
69 | }
70 |
71 | public View appendSection(int nameId) {
72 | return appendSection(mContext.getString(nameId));
73 | }
74 |
75 | public View appendRow(int layoutId, String name, String value) {
76 | ViewGroup rowView = (ViewGroup) LayoutInflater.from(mContext).inflate(layoutId, mTableLayout, false);
77 | setNameValueText(rowView, name, value);
78 |
79 | mTableLayout.addView(rowView);
80 | return rowView;
81 | }
82 |
83 | public ViewHolder obtainViewHolder(View rowView) {
84 | ViewHolder viewHolder = (ViewHolder) rowView.getTag();
85 | if (viewHolder == null) {
86 | viewHolder = new ViewHolder();
87 | viewHolder.mNameTextView = (TextView) rowView.findViewById(R.id.name);
88 | viewHolder.mValueTextView = (TextView) rowView.findViewById(R.id.value);
89 | rowView.setTag(viewHolder);
90 | }
91 | return viewHolder;
92 | }
93 |
94 | public void setNameValueText(View rowView, String name, String value) {
95 | ViewHolder viewHolder = obtainViewHolder(rowView);
96 | viewHolder.setName(name);
97 | viewHolder.setValue(value);
98 | }
99 |
100 | public void setValueText(View rowView, String value) {
101 | ViewHolder viewHolder = obtainViewHolder(rowView);
102 | viewHolder.setValue(value);
103 | }
104 |
105 | public ViewGroup buildLayout() {
106 | return mTableView;
107 | }
108 |
109 | public AlertDialog.Builder buildAlertDialogBuilder() {
110 | AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(mContext);
111 | dlgBuilder.setView(buildLayout());
112 | return dlgBuilder;
113 | }
114 |
115 | private static class ViewHolder {
116 | public TextView mNameTextView;
117 | public TextView mValueTextView;
118 |
119 | public void setName(String name) {
120 | if (mNameTextView != null) {
121 | mNameTextView.setText(name);
122 | }
123 | }
124 |
125 | public void setValue(String value) {
126 | if (mValueTextView != null) {
127 | mValueTextView.setText(value);
128 | }
129 | }
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/res/xml/settings.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
11 |
19 |
20 |
21 |
27 |
33 |
39 |
47 |
48 |
49 |
55 |
56 |
57 |
63 |
69 |
75 |
81 |
82 |
83 |
89 |
90 |
--------------------------------------------------------------------------------
/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.media_codec_handle_resolution_change
47 | MediaCodec handle resolution change
48 |
49 |
50 | pref.pixel_format
51 | Pixel Format
52 |
53 | - Auto Select
54 | - RGB 565
55 | - RGB 888
56 | - RGBX 8888
57 | - YV12
58 | - OpenGL ES2
59 |
60 |
61 |
62 | - fcc-rv16
63 | - fcc-rv24
64 | - fcc-rv32
65 | - fcc-yv12
66 | - fcc-_es2
67 |
68 |
69 | - Auto Select
70 | - RGB 565
71 | - RGB 888
72 | - RGBX 8888
73 | - YV12
74 | - OpenGL ES2
75 |
76 |
77 |
78 | Audio: ijkplayer
79 |
80 | pref.using_opensl_es
81 | Using OpenSL ES
82 |
83 |
84 |
85 | RenderView
86 |
87 | pref.enable_no_view
88 | Enable NoView
89 |
90 |
91 | pref.enable_surface_view
92 | Enable SurfaceView
93 |
94 |
95 | pref.enable_texture_view
96 | Enable TextureView
97 |
98 |
99 | pref.enable_detached_surface_texture
100 | Enable detached SurfaceTexture
101 |
102 |
103 |
104 | Misc
105 | pref.using_mediadatasource
106 | Using MediaDataSource
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/content/RecentMediaStorage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.content;
19 |
20 | import android.content.ContentValues;
21 | import android.content.Context;
22 | import android.database.Cursor;
23 | import android.database.sqlite.SQLiteDatabase;
24 | import android.database.sqlite.SQLiteOpenHelper;
25 | import android.os.AsyncTask;
26 | import android.support.v4.content.AsyncTaskLoader;
27 | import android.text.TextUtils;
28 |
29 | public class RecentMediaStorage {
30 | private Context mAppContext;
31 |
32 | public RecentMediaStorage(Context context) {
33 | mAppContext = context.getApplicationContext();
34 | }
35 |
36 | public void saveUrlAsync(String url) {
37 | new AsyncTask() {
38 | @Override
39 | protected Void doInBackground(String... params) {
40 | saveUrl(params[0]);
41 | return null;
42 | }
43 | }.execute(url);
44 | }
45 |
46 | public void saveUrl(String url) {
47 | ContentValues cv = new ContentValues();
48 | cv.putNull(Entry.COLUMN_NAME_ID);
49 | cv.put(Entry.COLUMN_NAME_URL, url);
50 | cv.put(Entry.COLUMN_NAME_LAST_ACCESS, System.currentTimeMillis());
51 | cv.put(Entry.COLUMN_NAME_NAME, getNameOfUrl(url));
52 | save(cv);
53 | }
54 |
55 | public void save(ContentValues contentValue) {
56 | OpenHelper openHelper = new OpenHelper(mAppContext);
57 | SQLiteDatabase db = openHelper.getWritableDatabase();
58 | db.replace(Entry.TABLE_NAME, null, contentValue);
59 | }
60 |
61 | public static String getNameOfUrl(String url) {
62 | return getNameOfUrl(url, "");
63 | }
64 |
65 | public static String getNameOfUrl(String url, String defaultName) {
66 | String name = null;
67 | int pos = url.lastIndexOf('/');
68 | if (pos >= 0)
69 | name = url.substring(pos + 1);
70 |
71 | if (TextUtils.isEmpty(name))
72 | name = defaultName;
73 |
74 | return name;
75 | }
76 |
77 | public static class Entry {
78 | public static final String TABLE_NAME = "RecentMedia";
79 | public static final String COLUMN_NAME_ID = "id";
80 | public static final String COLUMN_NAME_URL = "url";
81 | public static final String COLUMN_NAME_NAME = "name";
82 | public static final String COLUMN_NAME_LAST_ACCESS = "last_access";
83 | }
84 |
85 | public static final String ALL_COLUMNS[] = new String[]{
86 | Entry.COLUMN_NAME_ID + " as _id",
87 | Entry.COLUMN_NAME_ID,
88 | Entry.COLUMN_NAME_URL,
89 | Entry.COLUMN_NAME_NAME,
90 | Entry.COLUMN_NAME_LAST_ACCESS};
91 |
92 | public static class OpenHelper extends SQLiteOpenHelper {
93 | private static final int DATABASE_VERSION = 1;
94 | private static final String DATABASE_NAME = "RecentMedia.db";
95 | private static final String SQL_CREATE_ENTRIES =
96 | " CREATE TABLE IF NOT EXISTS " + Entry.TABLE_NAME + " (" +
97 | Entry.COLUMN_NAME_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
98 | Entry.COLUMN_NAME_URL + " VARCHAR UNIQUE, " +
99 | Entry.COLUMN_NAME_NAME + " VARCHAR, " +
100 | Entry.COLUMN_NAME_LAST_ACCESS + " INTEGER) ";
101 |
102 | public OpenHelper(Context context) {
103 | super(context, DATABASE_NAME, null, DATABASE_VERSION);
104 | }
105 |
106 | @Override
107 | public void onCreate(SQLiteDatabase db) {
108 | db.execSQL(SQL_CREATE_ENTRIES);
109 | }
110 |
111 | @Override
112 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
113 | }
114 | }
115 |
116 | public static class CursorLoader extends AsyncTaskLoader {
117 | public CursorLoader(Context context) {
118 | super(context);
119 | }
120 |
121 | @Override
122 | public Cursor loadInBackground() {
123 | Context context = getContext();
124 | OpenHelper openHelper = new OpenHelper(context);
125 | SQLiteDatabase db = openHelper.getReadableDatabase();
126 |
127 | return db.query(Entry.TABLE_NAME, ALL_COLUMNS, null, null, null, null,
128 | Entry.COLUMN_NAME_LAST_ACCESS + " DESC",
129 | "100");
130 | }
131 |
132 | @Override
133 | protected void onStartLoading() {
134 | forceLoad();
135 | }
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/content/PathCursor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.content;
19 |
20 | import android.database.AbstractCursor;
21 | import android.provider.BaseColumns;
22 | import android.text.TextUtils;
23 |
24 | import java.io.File;
25 | import java.util.ArrayList;
26 | import java.util.Collections;
27 | import java.util.Comparator;
28 | import java.util.List;
29 | import java.util.Set;
30 | import java.util.TreeSet;
31 |
32 | public class PathCursor extends AbstractCursor {
33 | private List mFileList = new ArrayList<>();
34 |
35 | public static final String CN_ID = BaseColumns._ID;
36 | public static final String CN_FILE_NAME = "file_name";
37 | public static final String CN_FILE_PATH = "file_path";
38 | public static final String CN_IS_DIRECTORY = "is_directory";
39 | public static final String CN_IS_VIDEO = "is_video";
40 | public static final String[] columnNames = new String[]{CN_ID, CN_FILE_NAME, CN_FILE_PATH, CN_IS_DIRECTORY, CN_IS_VIDEO};
41 | public static final int CI_ID = 0;
42 | public static final int CI_FILE_NAME = 1;
43 | public static final int CI_FILE_PATH = 2;
44 | public static final int CI_IS_DIRECTORY = 3;
45 | public static final int CI_IS_VIDEO = 4;
46 |
47 | PathCursor(File parentDirectory, File[] fileList) {
48 | if (parentDirectory.getParent() != null) {
49 | FileItem parentFile = new FileItem(new File(parentDirectory, ".."));
50 | parentFile.isDirectory = true;
51 | mFileList.add(parentFile);
52 | }
53 |
54 | if (fileList != null) {
55 | for (File file : fileList) {
56 | mFileList.add(new FileItem(file));
57 | }
58 | Collections.sort(this.mFileList, sComparator);
59 | }
60 | }
61 |
62 | @Override
63 | public int getCount() {
64 | return mFileList.size();
65 | }
66 |
67 | @Override
68 | public String[] getColumnNames() {
69 | return columnNames;
70 | }
71 |
72 | @Override
73 | public String getString(int column) {
74 | switch (column) {
75 | case CI_FILE_NAME:
76 | return mFileList.get(getPosition()).file.getName();
77 | case CI_FILE_PATH:
78 | return mFileList.get(getPosition()).file.toString();
79 | }
80 | return null;
81 | }
82 |
83 | @Override
84 | public short getShort(int column) {
85 | return (short) getLong(column);
86 | }
87 |
88 | @Override
89 | public int getInt(int column) {
90 | return (int) getLong(column);
91 | }
92 |
93 | @Override
94 | public long getLong(int column) {
95 | switch (column) {
96 | case CI_ID:
97 | return getPosition();
98 | case CI_IS_DIRECTORY:
99 | return mFileList.get(getPosition()).isDirectory ? 1 : 0;
100 | case CI_IS_VIDEO:
101 | return mFileList.get(getPosition()).isVideo ? 1 : 0;
102 | }
103 | return 0;
104 | }
105 |
106 | @Override
107 | public float getFloat(int column) {
108 | return 0;
109 | }
110 |
111 | @Override
112 | public double getDouble(int column) {
113 | return 0;
114 | }
115 |
116 | @Override
117 | public boolean isNull(int column) {
118 | return mFileList == null;
119 | }
120 |
121 | public static Comparator sComparator = new Comparator() {
122 | @Override
123 | public int compare(FileItem lhs, FileItem rhs) {
124 | if (lhs.isDirectory && !rhs.isDirectory)
125 | return -1;
126 | else if (!lhs.isDirectory && rhs.isDirectory)
127 | return 1;
128 | return lhs.file.getName().compareToIgnoreCase(rhs.file.getName());
129 | }
130 | };
131 |
132 | private static Set sMediaExtSet = new TreeSet(String.CASE_INSENSITIVE_ORDER);
133 |
134 | static {
135 | sMediaExtSet.add("flv");
136 | sMediaExtSet.add("mp4");
137 | }
138 |
139 | private class FileItem {
140 | public File file;
141 | public boolean isDirectory;
142 | public boolean isVideo;
143 |
144 | public FileItem(String file) {
145 | this(new File(file));
146 | }
147 |
148 | public FileItem(File file) {
149 | this.file = file;
150 | this.isDirectory = file.isDirectory();
151 |
152 | String fileName = file.getName();
153 | if (!TextUtils.isEmpty(fileName)) {
154 | int extPos = fileName.lastIndexOf('.');
155 | if (extPos >= 0) {
156 | String ext = fileName.substring(extPos + 1);
157 | if (!TextUtils.isEmpty(ext) && sMediaExtSet.contains(ext)) {
158 | this.isVideo = true;
159 | }
160 | }
161 | }
162 | }
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/fragments/RecentMediaListFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.fragments;
19 |
20 | import android.app.Activity;
21 | import android.content.Context;
22 | import android.database.Cursor;
23 | import android.os.Bundle;
24 | import android.support.annotation.Nullable;
25 | import android.support.v4.app.Fragment;
26 | import android.support.v4.app.LoaderManager;
27 | import android.support.v4.content.Loader;
28 | import android.support.v4.widget.SimpleCursorAdapter;
29 | import android.view.LayoutInflater;
30 | import android.view.View;
31 | import android.view.ViewGroup;
32 | import android.widget.AdapterView;
33 | import android.widget.ListView;
34 |
35 | import tv.danmaku.ijk.media.example.R;
36 | import tv.danmaku.ijk.media.example.activities.VideoActivity;
37 | import tv.danmaku.ijk.media.example.content.RecentMediaStorage;
38 |
39 | public class RecentMediaListFragment extends Fragment implements LoaderManager.LoaderCallbacks {
40 | private ListView mFileListView;
41 | private RecentMediaAdapter mAdapter;
42 |
43 | public static RecentMediaListFragment newInstance() {
44 | RecentMediaListFragment f = new RecentMediaListFragment();
45 | return f;
46 | }
47 |
48 | @Nullable
49 | @Override
50 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
51 | ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_file_list, container, false);
52 | mFileListView = (ListView) viewGroup.findViewById(R.id.file_list_view);
53 | return viewGroup;
54 | }
55 |
56 | @Override
57 | public void onActivityCreated(@Nullable Bundle savedInstanceState) {
58 | super.onActivityCreated(savedInstanceState);
59 |
60 | final Activity activity = getActivity();
61 |
62 | mAdapter = new RecentMediaAdapter(activity);
63 | mFileListView.setAdapter(mAdapter);
64 | mFileListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
65 | @Override
66 | public void onItemClick(AdapterView> parent, View view, final int position, final long id) {
67 | String url = mAdapter.getUrl(position);
68 | String name = mAdapter.getName(position);
69 | VideoActivity.intentTo(activity, url, name);
70 | }
71 | });
72 |
73 | getLoaderManager().initLoader(2, null, this);
74 | }
75 |
76 | @Override
77 | public Loader onCreateLoader(int id, Bundle args) {
78 | return new RecentMediaStorage.CursorLoader(getActivity());
79 | }
80 |
81 | @Override
82 | public void onLoadFinished(Loader loader, Cursor data) {
83 | mAdapter.swapCursor(data);
84 | mAdapter.notifyDataSetChanged();
85 | }
86 |
87 | @Override
88 | public void onLoaderReset(Loader loader) {
89 |
90 | }
91 |
92 | final class RecentMediaAdapter extends SimpleCursorAdapter {
93 | private int mIndex_id = -1;
94 | private int mIndex_url = -1;
95 | private int mIndex_name = -1;
96 |
97 | public RecentMediaAdapter(Context context) {
98 | super(context, android.R.layout.simple_list_item_2, null,
99 | new String[]{RecentMediaStorage.Entry.COLUMN_NAME_NAME, RecentMediaStorage.Entry.COLUMN_NAME_URL},
100 | new int[]{android.R.id.text1, android.R.id.text2}, 0);
101 | }
102 |
103 | @Override
104 | public Cursor swapCursor(Cursor c) {
105 | Cursor res = super.swapCursor(c);
106 |
107 | mIndex_id = c.getColumnIndex(RecentMediaStorage.Entry.COLUMN_NAME_ID);
108 | mIndex_url = c.getColumnIndex(RecentMediaStorage.Entry.COLUMN_NAME_URL);
109 | mIndex_name = c.getColumnIndex(RecentMediaStorage.Entry.COLUMN_NAME_NAME);
110 |
111 | return res;
112 | }
113 |
114 | @Override
115 | public long getItemId(int position) {
116 | final Cursor cursor = moveToPosition(position);
117 | if (cursor == null)
118 | return 0;
119 |
120 | return cursor.getLong(mIndex_id);
121 | }
122 |
123 | Cursor moveToPosition(int position) {
124 | final Cursor cursor = getCursor();
125 | if (cursor.getCount() == 0 || position >= cursor.getCount()) {
126 | return null;
127 | }
128 | cursor.moveToPosition(position);
129 | return cursor;
130 | }
131 |
132 | public String getUrl(int position) {
133 | final Cursor cursor = moveToPosition(position);
134 | if (cursor == null)
135 | return "";
136 |
137 | return cursor.getString(mIndex_url);
138 | }
139 |
140 | public String getName(int position) {
141 | final Cursor cursor = moveToPosition(position);
142 | if (cursor == null)
143 | return "";
144 |
145 | return cursor.getString(mIndex_name);
146 | }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/fragments/SampleMediaListFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.fragments;
19 |
20 | import android.app.Activity;
21 | import android.content.Context;
22 | import android.os.Bundle;
23 | import android.support.annotation.Nullable;
24 | import android.support.v4.app.Fragment;
25 | import android.view.LayoutInflater;
26 | import android.view.View;
27 | import android.view.ViewGroup;
28 | import android.widget.AdapterView;
29 | import android.widget.ArrayAdapter;
30 | import android.widget.ListView;
31 | import android.widget.TextView;
32 |
33 | import tv.danmaku.ijk.media.example.R;
34 | import tv.danmaku.ijk.media.example.activities.VideoActivity;
35 |
36 | public class SampleMediaListFragment extends Fragment {
37 | private ListView mFileListView;
38 | private SampleMediaAdapter mAdapter;
39 |
40 | public static SampleMediaListFragment newInstance() {
41 | SampleMediaListFragment f = new SampleMediaListFragment();
42 | return f;
43 | }
44 |
45 | @Nullable
46 | @Override
47 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
48 | ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_file_list, container, false);
49 | mFileListView = (ListView) viewGroup.findViewById(R.id.file_list_view);
50 | return viewGroup;
51 | }
52 |
53 | @Override
54 | public void onActivityCreated(@Nullable Bundle savedInstanceState) {
55 | super.onActivityCreated(savedInstanceState);
56 |
57 | final Activity activity = getActivity();
58 |
59 | mAdapter = new SampleMediaAdapter(activity);
60 | mFileListView.setAdapter(mAdapter);
61 | mFileListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
62 | @Override
63 | public void onItemClick(AdapterView> parent, View view, final int position, final long id) {
64 | SampleMediaItem item = mAdapter.getItem(position);
65 | String name = item.mName;
66 | String url = item.mUrl;
67 | VideoActivity.intentTo(activity, url, name);
68 | }
69 | });
70 |
71 | mAdapter.addItem("https://csminiimagehost.blob.core.chinacloudapi.cn/audio/Qtz_Story/2018-01-16/1/audio_story.mp3", "bipbop basic master playlist");
72 | mAdapter.addItem("http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/prog_index.m3u8", "bipbop basic 400x300 @ 232 kbps");
73 | mAdapter.addItem("http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear2/prog_index.m3u8", "bipbop basic 640x480 @ 650 kbps");
74 | mAdapter.addItem("http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear3/prog_index.m3u8", "bipbop basic 640x480 @ 1 Mbps");
75 | mAdapter.addItem("http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear4/prog_index.m3u8", "bipbop basic 960x720 @ 2 Mbps");
76 | mAdapter.addItem("http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear0/prog_index.m3u8", "bipbop basic 22.050Hz stereo @ 40 kbps");
77 | mAdapter.addItem("http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8", "bipbop advanced master playlist");
78 | mAdapter.addItem("http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8", "bipbop advanced 416x234 @ 265 kbps");
79 | mAdapter.addItem("http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/gear2/prog_index.m3u8", "bipbop advanced 640x360 @ 580 kbps");
80 | mAdapter.addItem("http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/gear3/prog_index.m3u8", "bipbop advanced 960x540 @ 910 kbps");
81 | mAdapter.addItem("http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/gear4/prog_index.m3u8", "bipbop advanced 1289x720 @ 1 Mbps");
82 | mAdapter.addItem("http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8", "bipbop advanced 1920x1080 @ 2 Mbps");
83 | mAdapter.addItem("http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/gear0/prog_index.m3u8", "bipbop advanced 22.050Hz stereo @ 40 kbps");
84 | }
85 |
86 | final class SampleMediaItem {
87 | String mUrl;
88 | String mName;
89 |
90 | public SampleMediaItem(String url, String name) {
91 | mUrl = url;
92 | mName = name;
93 | }
94 | }
95 |
96 | final class SampleMediaAdapter extends ArrayAdapter {
97 | public SampleMediaAdapter(Context context) {
98 | super(context, android.R.layout.simple_list_item_2);
99 | }
100 |
101 | public void addItem(String url, String name) {
102 | add(new SampleMediaItem(url, name));
103 | }
104 |
105 | @Override
106 | public long getItemId(int position) {
107 | return position;
108 | }
109 |
110 | @Override
111 | public View getView(int position, View convertView, ViewGroup parent) {
112 | View view = convertView;
113 | if (view == null) {
114 | LayoutInflater inflater = LayoutInflater.from(parent.getContext());
115 | view = inflater.inflate(android.R.layout.simple_list_item_2, parent, false);
116 | }
117 |
118 | ViewHolder viewHolder = (ViewHolder) view.getTag();
119 | if (viewHolder == null) {
120 | viewHolder = new ViewHolder();
121 | viewHolder.mNameTextView = (TextView) view.findViewById(android.R.id.text1);
122 | viewHolder.mUrlTextView = (TextView) view.findViewById(android.R.id.text2);
123 | }
124 |
125 | SampleMediaItem item = getItem(position);
126 | viewHolder.mNameTextView.setText(item.mName);
127 | viewHolder.mUrlTextView.setText(item.mUrl);
128 |
129 | return view;
130 | }
131 |
132 | final class ViewHolder {
133 | public TextView mNameTextView;
134 | public TextView mUrlTextView;
135 | }
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/IMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Bilibili
3 | * Copyright (C) 2013-2014 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player;
19 |
20 | import android.annotation.TargetApi;
21 | import android.content.Context;
22 | import android.net.Uri;
23 | import android.os.Build;
24 | import android.view.Surface;
25 | import android.view.SurfaceHolder;
26 |
27 | import java.io.FileDescriptor;
28 | import java.io.IOException;
29 | import java.util.Map;
30 |
31 | import tv.danmaku.ijk.media.player.misc.IMediaDataSource;
32 | import tv.danmaku.ijk.media.player.misc.ITrackInfo;
33 |
34 | public interface IMediaPlayer {
35 | /*
36 | * Do not change these values without updating their counterparts in native
37 | */
38 | int MEDIA_INFO_UNKNOWN = 1;
39 | int MEDIA_INFO_STARTED_AS_NEXT = 2;
40 | int MEDIA_INFO_VIDEO_RENDERING_START = 3;
41 | int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700;
42 | int MEDIA_INFO_BUFFERING_START = 701;
43 | int MEDIA_INFO_BUFFERING_END = 702;
44 | int MEDIA_INFO_NETWORK_BANDWIDTH = 703;
45 | int MEDIA_INFO_BAD_INTERLEAVING = 800;
46 | int MEDIA_INFO_NOT_SEEKABLE = 801;
47 | int MEDIA_INFO_METADATA_UPDATE = 802;
48 | int MEDIA_INFO_TIMED_TEXT_ERROR = 900;
49 | int MEDIA_INFO_UNSUPPORTED_SUBTITLE = 901;
50 | int MEDIA_INFO_SUBTITLE_TIMED_OUT = 902;
51 |
52 | int MEDIA_INFO_VIDEO_ROTATION_CHANGED = 10001;
53 | int MEDIA_INFO_AUDIO_RENDERING_START = 10002;
54 | int MEDIA_INFO_AUDIO_DECODED_START = 10003;
55 | int MEDIA_INFO_VIDEO_DECODED_START = 10004;
56 | int MEDIA_INFO_OPEN_INPUT = 10005;
57 | int MEDIA_INFO_FIND_STREAM_INFO = 10006;
58 | int MEDIA_INFO_COMPONENT_OPEN = 10007;
59 | int MEDIA_INFO_MEDIA_ACCURATE_SEEK_COMPLETE = 10100;
60 |
61 | int MEDIA_ERROR_UNKNOWN = 1;
62 | int MEDIA_ERROR_SERVER_DIED = 100;
63 | int MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200;
64 | int MEDIA_ERROR_IO = -1004;
65 | int MEDIA_ERROR_MALFORMED = -1007;
66 | int MEDIA_ERROR_UNSUPPORTED = -1010;
67 | int MEDIA_ERROR_TIMED_OUT = -110;
68 |
69 | void setDisplay(SurfaceHolder sh);
70 |
71 | void setDataSource(Context context, Uri uri)
72 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
73 |
74 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
75 | void setDataSource(Context context, Uri uri, Map headers)
76 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
77 |
78 | void setDataSource(FileDescriptor fd)
79 | throws IOException, IllegalArgumentException, IllegalStateException;
80 |
81 | void setDataSource(String path)
82 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
83 |
84 | String getDataSource();
85 |
86 | void prepareAsync() throws IllegalStateException;
87 |
88 | void start() throws IllegalStateException;
89 |
90 | void stop() throws IllegalStateException;
91 |
92 | void pause() throws IllegalStateException;
93 |
94 | void setScreenOnWhilePlaying(boolean screenOn);
95 |
96 | int getVideoWidth();
97 |
98 | int getVideoHeight();
99 |
100 | boolean isPlaying();
101 |
102 | void seekTo(long msec) throws IllegalStateException;
103 |
104 | long getCurrentPosition();
105 |
106 | long getDuration();
107 |
108 | void release();
109 |
110 | void reset();
111 |
112 | void setVolume(float leftVolume, float rightVolume);
113 |
114 | int getAudioSessionId();
115 |
116 | MediaInfo getMediaInfo();
117 |
118 | @SuppressWarnings("EmptyMethod")
119 | @Deprecated
120 | void setLogEnabled(boolean enable);
121 |
122 | @Deprecated
123 | boolean isPlayable();
124 |
125 | void setOnPreparedListener(OnPreparedListener listener);
126 |
127 | void setOnCompletionListener(OnCompletionListener listener);
128 |
129 | void setOnBufferingUpdateListener(
130 | OnBufferingUpdateListener listener);
131 |
132 | void setOnSeekCompleteListener(
133 | OnSeekCompleteListener listener);
134 |
135 | void setOnVideoSizeChangedListener(
136 | OnVideoSizeChangedListener listener);
137 |
138 | void setOnErrorListener(OnErrorListener listener);
139 |
140 | void setOnInfoListener(OnInfoListener listener);
141 |
142 | void setOnTimedTextListener(OnTimedTextListener listener);
143 |
144 | /*--------------------
145 | * Listeners
146 | */
147 | interface OnPreparedListener {
148 | void onPrepared(IMediaPlayer mp);
149 | }
150 |
151 | interface OnCompletionListener {
152 | void onCompletion(IMediaPlayer mp);
153 | }
154 |
155 | interface OnBufferingUpdateListener {
156 | void onBufferingUpdate(IMediaPlayer mp, int percent);
157 | }
158 |
159 | interface OnSeekCompleteListener {
160 | void onSeekComplete(IMediaPlayer mp);
161 | }
162 |
163 | interface OnVideoSizeChangedListener {
164 | void onVideoSizeChanged(IMediaPlayer mp, int width, int height,
165 | int sar_num, int sar_den);
166 | }
167 |
168 | interface OnErrorListener {
169 | boolean onError(IMediaPlayer mp, int what, int extra);
170 | }
171 |
172 | interface OnInfoListener {
173 | boolean onInfo(IMediaPlayer mp, int what, int extra);
174 | }
175 |
176 | interface OnTimedTextListener {
177 | void onTimedText(IMediaPlayer mp, IjkTimedText text);
178 | }
179 |
180 | /*--------------------
181 | * Optional
182 | */
183 | void setAudioStreamType(int streamtype);
184 |
185 | @Deprecated
186 | void setKeepInBackground(boolean keepInBackground);
187 |
188 | int getVideoSarNum();
189 |
190 | int getVideoSarDen();
191 |
192 | @Deprecated
193 | void setWakeMode(Context context, int mode);
194 |
195 | void setLooping(boolean looping);
196 |
197 | boolean isLooping();
198 |
199 | /*--------------------
200 | * AndroidMediaPlayer: JELLY_BEAN
201 | */
202 | ITrackInfo[] getTrackInfo();
203 |
204 | /*--------------------
205 | * AndroidMediaPlayer: ICE_CREAM_SANDWICH:
206 | */
207 | void setSurface(Surface surface);
208 |
209 | /*--------------------
210 | * AndroidMediaPlayer: M:
211 | */
212 | void setDataSource(IMediaDataSource mediaDataSource);
213 | }
214 |
--------------------------------------------------------------------------------
/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 | private long mLoadCost = 0;
22 | private long mSeekCost = 0;
23 |
24 | public InfoHudViewHolder(Context context, TableLayout tableLayout) {
25 | mTableLayoutBinder = new TableLayoutBinder(context, tableLayout);
26 | }
27 |
28 | private void appendSection(int nameId) {
29 | mTableLayoutBinder.appendSection(nameId);
30 | }
31 |
32 | private void appendRow(int nameId) {
33 | View rowView = mTableLayoutBinder.appendRow2(nameId, null);
34 | mRowMap.put(nameId, rowView);
35 | }
36 |
37 | private void setRowValue(int id, String value) {
38 | View rowView = mRowMap.get(id);
39 | if (rowView == null) {
40 | rowView = mTableLayoutBinder.appendRow2(id, value);
41 | mRowMap.put(id, rowView);
42 | } else {
43 | mTableLayoutBinder.setValueText(rowView, value);
44 | }
45 | }
46 |
47 | public void setMediaPlayer(IMediaPlayer mp) {
48 | mMediaPlayer = mp;
49 | if (mMediaPlayer != null) {
50 | mHandler.sendEmptyMessageDelayed(MSG_UPDATE_HUD, 500);
51 | } else {
52 | mHandler.removeMessages(MSG_UPDATE_HUD);
53 | }
54 | }
55 |
56 | private static String formatedDurationMilli(long duration) {
57 | if (duration >= 1000) {
58 | return String.format(Locale.US, "%.2f sec", ((float)duration) / 1000);
59 | } else {
60 | return String.format(Locale.US, "%d msec", duration);
61 | }
62 | }
63 |
64 | private static String formatedSpeed(long bytes,long elapsed_milli) {
65 | if (elapsed_milli <= 0) {
66 | return "0 B/s";
67 | }
68 |
69 | if (bytes <= 0) {
70 | return "0 B/s";
71 | }
72 |
73 | float bytes_per_sec = ((float)bytes) * 1000.f / elapsed_milli;
74 | if (bytes_per_sec >= 1000 * 1000) {
75 | return String.format(Locale.US, "%.2f MB/s", ((float)bytes_per_sec) / 1000 / 1000);
76 | } else if (bytes_per_sec >= 1000) {
77 | return String.format(Locale.US, "%.1f KB/s", ((float)bytes_per_sec) / 1000);
78 | } else {
79 | return String.format(Locale.US, "%d B/s", (long)bytes_per_sec);
80 | }
81 | }
82 |
83 | public void updateLoadCost(long time) {
84 | mLoadCost = time;
85 | }
86 |
87 | public void updateSeekCost(long time) {
88 | mSeekCost = time;
89 | }
90 |
91 | private static String formatedSize(long bytes) {
92 | if (bytes >= 100 * 1000) {
93 | return String.format(Locale.US, "%.2f MB", ((float)bytes) / 1000 / 1000);
94 | } else if (bytes >= 100) {
95 | return String.format(Locale.US, "%.1f KB", ((float)bytes) / 1000);
96 | } else {
97 | return String.format(Locale.US, "%d B", bytes);
98 | }
99 | }
100 |
101 | private static final int MSG_UPDATE_HUD = 1;
102 | private Handler mHandler = new Handler() {
103 | @Override
104 | public void handleMessage(Message msg) {
105 | switch (msg.what) {
106 | case MSG_UPDATE_HUD: {
107 | InfoHudViewHolder holder = InfoHudViewHolder.this;
108 | IjkMediaPlayer mp = null;
109 | if (mMediaPlayer == null)
110 | break;
111 | if (mMediaPlayer instanceof IjkMediaPlayer) {
112 | mp = (IjkMediaPlayer) mMediaPlayer;
113 | } else if (mMediaPlayer instanceof MediaPlayerProxy) {
114 | MediaPlayerProxy proxy = (MediaPlayerProxy) mMediaPlayer;
115 | IMediaPlayer internal = proxy.getInternalMediaPlayer();
116 | if (internal != null && internal instanceof IjkMediaPlayer)
117 | mp = (IjkMediaPlayer) internal;
118 | }
119 | if (mp == null)
120 | break;
121 |
122 | int vdec = mp.getVideoDecoder();
123 | switch (vdec) {
124 | case IjkMediaPlayer.FFP_PROPV_DECODER_AVCODEC:
125 | setRowValue(R.string.vdec, "avcodec");
126 | break;
127 | case IjkMediaPlayer.FFP_PROPV_DECODER_MEDIACODEC:
128 | setRowValue(R.string.vdec, "MediaCodec");
129 | break;
130 | default:
131 | setRowValue(R.string.vdec, "");
132 | break;
133 | }
134 |
135 | float fpsOutput = mp.getVideoOutputFramesPerSecond();
136 | float fpsDecode = mp.getVideoDecodeFramesPerSecond();
137 | setRowValue(R.string.fps, String.format(Locale.US, "%.2f / %.2f", fpsDecode, fpsOutput));
138 |
139 | long videoCachedDuration = mp.getVideoCachedDuration();
140 | long audioCachedDuration = mp.getAudioCachedDuration();
141 | long videoCachedBytes = mp.getVideoCachedBytes();
142 | long audioCachedBytes = mp.getAudioCachedBytes();
143 | long tcpSpeed = mp.getTcpSpeed();
144 | long bitRate = mp.getBitRate();
145 | long seekLoadDuration = mp.getSeekLoadDuration();
146 |
147 | setRowValue(R.string.v_cache, String.format(Locale.US, "%s, %s", formatedDurationMilli(videoCachedDuration), formatedSize(videoCachedBytes)));
148 | setRowValue(R.string.a_cache, String.format(Locale.US, "%s, %s", formatedDurationMilli(audioCachedDuration), formatedSize(audioCachedBytes)));
149 | setRowValue(R.string.load_cost, String.format(Locale.US, "%d ms", mLoadCost));
150 | setRowValue(R.string.seek_cost, String.format(Locale.US, "%d ms", mSeekCost));
151 | setRowValue(R.string.seek_load_cost, String.format(Locale.US, "%d ms", seekLoadDuration));
152 | setRowValue(R.string.tcp_speed, String.format(Locale.US, "%s", formatedSpeed(tcpSpeed, 1000)));
153 | setRowValue(R.string.bit_rate, String.format(Locale.US, "%.2f kbs", bitRate/1000f));
154 |
155 | mHandler.removeMessages(MSG_UPDATE_HUD);
156 | mHandler.sendEmptyMessageDelayed(MSG_UPDATE_HUD, 500);
157 | }
158 | }
159 | }
160 | };
161 | }
162 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/fragments/TracksFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.fragments;
19 |
20 | import android.app.Activity;
21 | import android.content.Context;
22 | import android.os.Bundle;
23 | import android.support.annotation.Nullable;
24 | import android.support.v4.app.Fragment;
25 | import android.util.Log;
26 | import android.view.LayoutInflater;
27 | import android.view.View;
28 | import android.view.ViewGroup;
29 | import android.widget.AdapterView;
30 | import android.widget.ArrayAdapter;
31 | import android.widget.ListView;
32 | import android.widget.TextView;
33 |
34 | import java.util.Locale;
35 |
36 | import tv.danmaku.ijk.media.player.misc.ITrackInfo;
37 | import tv.danmaku.ijk.media.example.R;
38 |
39 | public class TracksFragment extends Fragment {
40 | private ListView mTrackListView;
41 | private TrackAdapter mAdapter;
42 |
43 | public static TracksFragment newInstance() {
44 | TracksFragment f = new TracksFragment();
45 | return f;
46 | }
47 |
48 | @Nullable
49 | @Override
50 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
51 | ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_track_list, container, false);
52 | mTrackListView = (ListView) viewGroup.findViewById(R.id.track_list_view);
53 | return viewGroup;
54 | }
55 |
56 | @Override
57 | public void onActivityCreated(@Nullable Bundle savedInstanceState) {
58 | super.onActivityCreated(savedInstanceState);
59 |
60 | final Activity activity = getActivity();
61 |
62 | mAdapter = new TrackAdapter(activity);
63 | mTrackListView.setAdapter(mAdapter);
64 |
65 | if (activity instanceof ITrackHolder) {
66 | final ITrackHolder trackHolder = (ITrackHolder) activity;
67 | mAdapter.setTrackHolder(trackHolder);
68 |
69 | int selectedVideoTrack = trackHolder.getSelectedTrack(ITrackInfo.MEDIA_TRACK_TYPE_VIDEO);
70 | int selectedAudioTrack = trackHolder.getSelectedTrack(ITrackInfo.MEDIA_TRACK_TYPE_AUDIO);
71 | int selectedSubtitleTrack = trackHolder.getSelectedTrack(ITrackInfo.MEDIA_TRACK_TYPE_TIMEDTEXT);
72 | if (selectedVideoTrack >= 0)
73 | mTrackListView.setItemChecked(selectedVideoTrack, true);
74 | if (selectedAudioTrack >= 0)
75 | mTrackListView.setItemChecked(selectedAudioTrack, true);
76 | if (selectedSubtitleTrack >= 0)
77 | mTrackListView.setItemChecked(selectedSubtitleTrack, true);
78 |
79 | mTrackListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
80 | @Override
81 | public void onItemClick(AdapterView> parent, View view, final int position, final long id) {
82 | TrackItem trackItem = (TrackItem) mTrackListView.getItemAtPosition(position);
83 | for (int i = 0; i < mAdapter.getCount(); ++i) {
84 | TrackItem compareItem = mAdapter.getItem(i);
85 | if (compareItem.mIndex == trackItem.mIndex)
86 | continue;
87 |
88 | if (compareItem.mTrackInfo.getTrackType() != trackItem.mTrackInfo.getTrackType())
89 | continue;
90 |
91 | if (mTrackListView.isItemChecked(i))
92 | mTrackListView.setItemChecked(i, false);
93 | }
94 | if (mTrackListView.isItemChecked(position)) {
95 | trackHolder.selectTrack(trackItem.mIndex);
96 | } else {
97 | trackHolder.deselectTrack(trackItem.mIndex);
98 | }
99 | }
100 | });
101 | } else {
102 | Log.e("TracksFragment", "activity is not an instance of ITrackHolder.");
103 | }
104 | }
105 |
106 | public interface ITrackHolder {
107 | ITrackInfo[] getTrackInfo();
108 | int getSelectedTrack(int trackType);
109 | void selectTrack(int stream);
110 | void deselectTrack(int stream);
111 | }
112 |
113 | final class TrackItem {
114 | public int mIndex;
115 | public ITrackInfo mTrackInfo;
116 |
117 | public String mInfoInline;
118 |
119 | public TrackItem(int index, ITrackInfo trackInfo) {
120 | mIndex = index;
121 | mTrackInfo = trackInfo;
122 | mInfoInline = String.format(Locale.US, "# %d: %s", mIndex, mTrackInfo.getInfoInline());
123 | }
124 |
125 | public String getInfoInline() {
126 | return mInfoInline;
127 | }
128 | }
129 |
130 | final class TrackAdapter extends ArrayAdapter {
131 | private ITrackHolder mTrackHolder;
132 | private ITrackInfo[] mTrackInfos;
133 |
134 | public TrackAdapter(Context context) {
135 | super(context, android.R.layout.simple_list_item_checked);
136 | }
137 |
138 | public void setTrackHolder(ITrackHolder trackHolder) {
139 | clear();
140 | mTrackHolder = trackHolder;
141 | mTrackInfos = mTrackHolder.getTrackInfo();
142 | if (mTrackInfos != null) {
143 | for(ITrackInfo trackInfo: mTrackInfos) {
144 | int index = getCount();
145 | TrackItem item = new TrackItem(index, trackInfo);
146 | add(item);
147 | }
148 | }
149 | }
150 |
151 | @Override
152 | public long getItemId(int position) {
153 | return position;
154 | }
155 |
156 | @Override
157 | public View getView(int position, View convertView, ViewGroup parent) {
158 | View view = convertView;
159 | if (view == null) {
160 | LayoutInflater inflater = LayoutInflater.from(parent.getContext());
161 | view = inflater.inflate(android.R.layout.simple_list_item_checked, parent, false);
162 | }
163 |
164 | ViewHolder viewHolder = (ViewHolder) view.getTag();
165 | if (viewHolder == null) {
166 | viewHolder = new ViewHolder();
167 | viewHolder.mNameTextView = (TextView) view.findViewById(android.R.id.text1);
168 | }
169 |
170 | TrackItem item = getItem(position);
171 | viewHolder.mNameTextView.setText(item.getInfoInline());
172 |
173 | return view;
174 | }
175 |
176 | final class ViewHolder {
177 | public TextView mNameTextView;
178 | }
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/fragments/FileListFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Bilibili
3 | * Copyright (C) 2015 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.example.fragments;
19 |
20 | import android.app.Activity;
21 | import android.content.Context;
22 | import android.database.Cursor;
23 | import android.os.Bundle;
24 | import android.support.annotation.Nullable;
25 | import android.support.v4.app.Fragment;
26 | import android.support.v4.app.LoaderManager;
27 | import android.support.v4.content.Loader;
28 | import android.support.v4.widget.SimpleCursorAdapter;
29 | import android.text.TextUtils;
30 | import android.view.LayoutInflater;
31 | import android.view.View;
32 | import android.view.ViewGroup;
33 | import android.widget.AdapterView;
34 | import android.widget.ImageView;
35 | import android.widget.ListView;
36 | import android.widget.TextView;
37 |
38 | import java.io.File;
39 |
40 | import tv.danmaku.ijk.media.example.R;
41 | import tv.danmaku.ijk.media.example.content.PathCursor;
42 | import tv.danmaku.ijk.media.example.content.PathCursorLoader;
43 | import tv.danmaku.ijk.media.example.eventbus.FileExplorerEvents;
44 |
45 | public class FileListFragment extends Fragment implements LoaderManager.LoaderCallbacks {
46 | private static final String ARG_PATH = "path";
47 |
48 | private TextView mPathView;
49 | private ListView mFileListView;
50 | private VideoAdapter mAdapter;
51 | private String mPath;
52 |
53 | public static FileListFragment newInstance(String path) {
54 | FileListFragment f = new FileListFragment();
55 |
56 | // Supply index input as an argument.
57 | Bundle args = new Bundle();
58 | args.putString(ARG_PATH, path);
59 | f.setArguments(args);
60 |
61 | return f;
62 | }
63 |
64 | @Nullable
65 | @Override
66 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
67 | ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_file_list, container, false);
68 | mPathView = (TextView) viewGroup.findViewById(R.id.path_view);
69 | mFileListView = (ListView) viewGroup.findViewById(R.id.file_list_view);
70 |
71 | mPathView.setVisibility(View.VISIBLE);
72 |
73 | return viewGroup;
74 | }
75 |
76 | @Override
77 | public void onActivityCreated(@Nullable Bundle savedInstanceState) {
78 | super.onActivityCreated(savedInstanceState);
79 |
80 | Activity activity = getActivity();
81 |
82 | Bundle bundle = getArguments();
83 | if (bundle != null) {
84 | mPath = bundle.getString(ARG_PATH);
85 | mPath = new File(mPath).getAbsolutePath();
86 | mPathView.setText(mPath);
87 | }
88 |
89 | mAdapter = new VideoAdapter(activity);
90 | mFileListView.setAdapter(mAdapter);
91 | mFileListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
92 | @Override
93 | public void onItemClick(AdapterView> parent, View view, final int position, final long id) {
94 | String path = mAdapter.getFilePath(position);
95 | if (TextUtils.isEmpty(path))
96 | return;
97 | FileExplorerEvents.getBus().post(new FileExplorerEvents.OnClickFile(path));
98 | }
99 | });
100 |
101 | getLoaderManager().initLoader(1, null, this);
102 | }
103 |
104 | @Override
105 | public Loader onCreateLoader(int id, Bundle args) {
106 | if (TextUtils.isEmpty(mPath))
107 | return null;
108 | return new PathCursorLoader(getActivity(), mPath);
109 | }
110 |
111 | @Override
112 | public void onLoadFinished(Loader loader, Cursor data) {
113 | mAdapter.swapCursor(data);
114 | mAdapter.notifyDataSetChanged();
115 | }
116 |
117 | @Override
118 | public void onLoaderReset(Loader loader) {
119 |
120 | }
121 |
122 | final class VideoAdapter extends SimpleCursorAdapter {
123 | final class ViewHolder {
124 | public ImageView iconImageView;
125 | public TextView nameTextView;
126 | }
127 |
128 | public VideoAdapter(Context context) {
129 | super(context, android.R.layout.simple_list_item_2, null,
130 | new String[]{PathCursor.CN_FILE_NAME, PathCursor.CN_FILE_PATH},
131 | new int[]{android.R.id.text1, android.R.id.text2}, 0);
132 | }
133 |
134 | @Override
135 | public View getView(int position, View convertView, ViewGroup parent) {
136 | View view = convertView;
137 | if (view == null) {
138 | LayoutInflater inflater = LayoutInflater.from(parent.getContext());
139 | view = inflater.inflate(R.layout.fragment_file_list_item, parent, false);
140 | }
141 |
142 | ViewHolder viewHolder = (ViewHolder) view.getTag();
143 | if (viewHolder == null) {
144 | viewHolder = new ViewHolder();
145 | viewHolder.iconImageView = (ImageView) view.findViewById(R.id.icon);
146 | viewHolder.nameTextView = (TextView) view.findViewById(R.id.name);
147 | }
148 |
149 | if (isDirectory(position)) {
150 | viewHolder.iconImageView.setImageResource(R.drawable.ic_theme_folder);
151 | } else if (isVideo(position)) {
152 | viewHolder.iconImageView.setImageResource(R.drawable.ic_theme_play_arrow);
153 | } else {
154 | viewHolder.iconImageView.setImageResource(R.drawable.ic_theme_description);
155 | }
156 | viewHolder.nameTextView.setText(getFileName(position));
157 |
158 | return view;
159 | }
160 |
161 | @Override
162 | public long getItemId(int position) {
163 | final Cursor cursor = moveToPosition(position);
164 | if (cursor == null)
165 | return 0;
166 |
167 | return cursor.getLong(PathCursor.CI_ID);
168 | }
169 |
170 | Cursor moveToPosition(int position) {
171 | final Cursor cursor = getCursor();
172 | if (cursor.getCount() == 0 || position >= cursor.getCount()) {
173 | return null;
174 | }
175 | cursor.moveToPosition(position);
176 | return cursor;
177 | }
178 |
179 | public boolean isDirectory(int position) {
180 | final Cursor cursor = moveToPosition(position);
181 | if (cursor == null)
182 | return true;
183 |
184 | return cursor.getInt(PathCursor.CI_IS_DIRECTORY) != 0;
185 | }
186 |
187 | public boolean isVideo(int position) {
188 | final Cursor cursor = moveToPosition(position);
189 | if (cursor == null)
190 | return true;
191 |
192 | return cursor.getInt(PathCursor.CI_IS_VIDEO) != 0;
193 | }
194 |
195 | public String getFileName(int position) {
196 | final Cursor cursor = moveToPosition(position);
197 | if (cursor == null)
198 | return "";
199 |
200 | return cursor.getString(PathCursor.CI_FILE_NAME);
201 | }
202 |
203 | public String getFilePath(int position) {
204 | final Cursor cursor = moveToPosition(position);
205 | if (cursor == null)
206 | return "";
207 |
208 | return cursor.getString(PathCursor.CI_FILE_PATH);
209 | }
210 | }
211 | }
212 |
--------------------------------------------------------------------------------