├── settings.gradle
├── TvPlayer
├── .gitignore
├── libs
│ ├── x86
│ │ ├── libijksdl.so
│ │ ├── libijkffmpeg.so
│ │ └── libijkplayer.so
│ ├── armeabi
│ │ ├── libijksdl.so
│ │ ├── libijkffmpeg.so
│ │ └── libijkplayer.so
│ └── armeabi-v7a
│ │ ├── libijksdl.so
│ │ ├── libijkffmpeg.so
│ │ └── libijkplayer.so
├── src
│ └── main
│ │ ├── res
│ │ ├── drawable
│ │ │ ├── bg.png
│ │ │ ├── down.png
│ │ │ ├── load.png
│ │ │ ├── mybg.png
│ │ │ ├── tvbk.png
│ │ │ ├── clearc.png
│ │ │ ├── daoru.png
│ │ │ ├── diver.png
│ │ │ ├── exit_n.png
│ │ │ ├── home_bg.jpg
│ │ │ ├── huikan.png
│ │ │ ├── img_1.png
│ │ │ ├── img_2.png
│ │ │ ├── img_3.png
│ │ │ ├── img_4.png
│ │ │ ├── img_5.png
│ │ │ ├── line760.png
│ │ │ ├── loading.png
│ │ │ ├── main_bg.jpg
│ │ │ ├── manbtn.png
│ │ │ ├── manitem.png
│ │ │ ├── manleft.png
│ │ │ ├── radio.jpg
│ │ │ ├── userid.png
│ │ │ ├── exit_bg_n.png
│ │ │ ├── home_bggm.jpg
│ │ │ ├── jiemahuan.png
│ │ │ ├── listleft.png
│ │ │ ├── listright.png
│ │ │ ├── manlistbg.jpg
│ │ │ ├── manright.png
│ │ │ ├── menu_fav.png
│ │ │ ├── menu_left.png
│ │ │ ├── menu_vol.png
│ │ │ ├── sxhuantai.png
│ │ │ ├── tuchaoshi.png
│ │ │ ├── yaoqingtu.png
│ │ │ ├── apptuijian.png
│ │ │ ├── back_my_fav.png
│ │ │ ├── bannerword.png
│ │ │ ├── controlman.png
│ │ │ ├── exit_play_n.png
│ │ │ ├── fileviewbg.jpg
│ │ │ ├── ic_launcher.png
│ │ │ ├── icon_loading.png
│ │ │ ├── login_check.png
│ │ │ ├── login_laybg.png
│ │ │ ├── login_line.png
│ │ │ ├── login_pass.png
│ │ │ ├── login_user.png
│ │ │ ├── manbtn_press.png
│ │ │ ├── menu_right.png
│ │ │ ├── menu_scaler.png
│ │ │ ├── menu_tvlist.png
│ │ │ ├── menu_tvsize.png
│ │ │ ├── osd_new_time.png
│ │ │ ├── tvmenu_xzt.png
│ │ │ ├── video_vol_bg.png
│ │ │ ├── wifi_server.png
│ │ │ ├── channeltype_bg.png
│ │ │ ├── dark_no_shadow.png
│ │ │ ├── exit_dialog_bg.jpg
│ │ │ ├── fileitem_press.png
│ │ │ ├── ic_app_install.png
│ │ │ ├── listleft_press.png
│ │ │ ├── manitem_press.png
│ │ │ ├── manleft_press.png
│ │ │ ├── manright_press.png
│ │ │ ├── menu_more_one.png
│ │ │ ├── menu_more_two.png
│ │ │ ├── splash_holder.jpg
│ │ │ ├── gdt_splash_logo.png
│ │ │ ├── listright_press.png
│ │ │ ├── logn_background.jpg
│ │ │ ├── osd_new_epg_next.png
│ │ │ ├── osd_new_soure_bg.png
│ │ │ ├── video_vol_black.png
│ │ │ ├── video_vol_whrite.png
│ │ │ ├── detail_juji_focused.png
│ │ │ ├── osd_new_channle_bg.png
│ │ │ ├── osd_new_epg_current.png
│ │ │ ├── general_loading_flower.png
│ │ │ ├── img_frame_background.jpg
│ │ │ ├── live_channel_list_bg.png
│ │ │ ├── live_control_main_bg.png
│ │ │ ├── detail_juji_selected_focused.png
│ │ │ ├── border_color.xml
│ │ │ ├── bg_dialog_confirm.xml
│ │ │ ├── tv_switch_bg_left.xml
│ │ │ ├── tv_switch_bg_right.xml
│ │ │ ├── background_button.xml
│ │ │ ├── background_circle.xml
│ │ │ └── video_loading.xml
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── values
│ │ │ ├── attr.xml
│ │ │ ├── dimens.xml
│ │ │ ├── colors.xml
│ │ │ ├── styles.xml
│ │ │ └── strings.xml
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ └── layout
│ │ │ ├── table_media_info.xml
│ │ │ ├── table_media_info_section.xml
│ │ │ ├── table_media_info_row1.xml
│ │ │ ├── table_media_info_row2.xml
│ │ │ ├── detail_menu_item.xml
│ │ │ ├── item_menu.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── layout_menu.xml
│ │ │ ├── activity_service_settings.xml
│ │ │ ├── dialog_confirm.xml
│ │ │ ├── activity_play_rel.xml
│ │ │ └── activity_login.xml
│ │ ├── java
│ │ └── com
│ │ │ └── gxf
│ │ │ └── liveplay
│ │ │ ├── update
│ │ │ ├── CallBack.java
│ │ │ ├── ConfirmDialog.java
│ │ │ ├── UpdateAppReceiver.java
│ │ │ ├── DownloadAppUtils.java
│ │ │ └── UpdateAppUtils.java
│ │ │ ├── Constants.java
│ │ │ ├── BootBroadcastReceiver.java
│ │ │ ├── ijkplayer
│ │ │ ├── media
│ │ │ │ ├── IMediaController.java
│ │ │ │ ├── IRenderView.java
│ │ │ │ ├── InfoHudViewHolder.java
│ │ │ │ ├── TableLayoutBinder.java
│ │ │ │ └── SurfaceRenderView.java
│ │ │ ├── services
│ │ │ │ └── MediaPlayerService.java
│ │ │ └── Settings.java
│ │ │ ├── MainActivityOffline.java
│ │ │ ├── MainActivity.java
│ │ │ ├── ServiceSettings.java
│ │ │ ├── PlayListCache.java
│ │ │ ├── DeviceUtils.java
│ │ │ └── LoginActivity.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── screenshot
├── 1.jpeg
├── 2.jpeg
└── 3.jpeg
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── Ijkplayer
├── src
│ └── main
│ │ ├── java
│ │ └── tv
│ │ │ └── danmaku
│ │ │ └── ijk
│ │ │ └── media
│ │ │ └── player
│ │ │ ├── ffmpeg
│ │ │ └── FFmpegApi.java
│ │ │ ├── pragma
│ │ │ ├── Pragma.java
│ │ │ └── DebugLog.java
│ │ │ ├── IjkLibLoader.java
│ │ │ ├── exceptions
│ │ │ └── IjkMediaException.java
│ │ │ ├── ISurfaceTextureHost.java
│ │ │ ├── MediaInfo.java
│ │ │ ├── ISurfaceTextureHolder.java
│ │ │ ├── misc
│ │ │ ├── IMediaFormat.java
│ │ │ ├── ITrackInfo.java
│ │ │ ├── AndroidMediaFormat.java
│ │ │ ├── IjkTrackInfo.java
│ │ │ ├── AndroidTrackInfo.java
│ │ │ └── IjkMediaFormat.java
│ │ │ ├── annotations
│ │ │ ├── AccessedByNative.java
│ │ │ └── CalledByNative.java
│ │ │ ├── BaseMediaPlayer.java
│ │ │ ├── TextureMediaPlayer.java
│ │ │ ├── AbstractMediaPlayer.java
│ │ │ ├── SimpleMediaPlayer.java
│ │ │ └── IMediaPlayer.java
│ │ ├── AndroidManifest.xml
│ │ └── res
│ │ └── values
│ │ ├── strings.xml
│ │ └── strings_pref.xml
├── proguard-rules.pro
└── build.gradle
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/settings.gradle:
--------------------------------------------------------------------------------
1 | include "TvPlayer", "Ijkplayer"
2 |
--------------------------------------------------------------------------------
/TvPlayer/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | *.iml
3 | .idea
4 | /.gradle
5 |
--------------------------------------------------------------------------------
/screenshot/1.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/screenshot/1.jpeg
--------------------------------------------------------------------------------
/screenshot/2.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/screenshot/2.jpeg
--------------------------------------------------------------------------------
/screenshot/3.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/screenshot/3.jpeg
--------------------------------------------------------------------------------
/TvPlayer/libs/x86/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/libs/x86/libijksdl.so
--------------------------------------------------------------------------------
/TvPlayer/libs/armeabi/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/libs/armeabi/libijksdl.so
--------------------------------------------------------------------------------
/TvPlayer/libs/x86/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/libs/x86/libijkffmpeg.so
--------------------------------------------------------------------------------
/TvPlayer/libs/x86/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/libs/x86/libijkplayer.so
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/TvPlayer/libs/armeabi/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/libs/armeabi/libijkffmpeg.so
--------------------------------------------------------------------------------
/TvPlayer/libs/armeabi/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/libs/armeabi/libijkplayer.so
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/bg.png
--------------------------------------------------------------------------------
/TvPlayer/libs/armeabi-v7a/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/libs/armeabi-v7a/libijksdl.so
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/down.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/load.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/load.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/mybg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/mybg.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/tvbk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/tvbk.png
--------------------------------------------------------------------------------
/TvPlayer/libs/armeabi-v7a/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/libs/armeabi-v7a/libijkffmpeg.so
--------------------------------------------------------------------------------
/TvPlayer/libs/armeabi-v7a/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/libs/armeabi-v7a/libijkplayer.so
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/clearc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/clearc.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/daoru.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/daoru.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/diver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/diver.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/exit_n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/exit_n.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/home_bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/home_bg.jpg
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/huikan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/huikan.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/img_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/img_1.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/img_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/img_2.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/img_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/img_3.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/img_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/img_4.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/img_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/img_5.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/line760.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/line760.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/loading.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/main_bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/main_bg.jpg
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/manbtn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/manbtn.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/manitem.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/manitem.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/manleft.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/manleft.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/radio.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/radio.jpg
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/userid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/userid.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/exit_bg_n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/exit_bg_n.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/home_bggm.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/home_bggm.jpg
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/jiemahuan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/jiemahuan.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/listleft.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/listleft.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/listright.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/listright.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/manlistbg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/manlistbg.jpg
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/manright.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/manright.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/menu_fav.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/menu_fav.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/menu_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/menu_left.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/menu_vol.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/menu_vol.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/sxhuantai.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/sxhuantai.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/tuchaoshi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/tuchaoshi.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/yaoqingtu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/yaoqingtu.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/apptuijian.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/apptuijian.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/back_my_fav.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/back_my_fav.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/bannerword.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/bannerword.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/controlman.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/controlman.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/exit_play_n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/exit_play_n.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/fileviewbg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/fileviewbg.jpg
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/icon_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/icon_loading.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/login_check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/login_check.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/login_laybg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/login_laybg.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/login_line.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/login_line.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/login_pass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/login_pass.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/login_user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/login_user.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/manbtn_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/manbtn_press.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/menu_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/menu_right.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/menu_scaler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/menu_scaler.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/menu_tvlist.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/menu_tvlist.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/menu_tvsize.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/menu_tvsize.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/osd_new_time.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/osd_new_time.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/tvmenu_xzt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/tvmenu_xzt.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/video_vol_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/video_vol_bg.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/wifi_server.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/wifi_server.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/channeltype_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/channeltype_bg.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/dark_no_shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/dark_no_shadow.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/exit_dialog_bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/exit_dialog_bg.jpg
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/fileitem_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/fileitem_press.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/ic_app_install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/ic_app_install.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/listleft_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/listleft_press.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/manitem_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/manitem_press.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/manleft_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/manleft_press.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/manright_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/manright_press.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/menu_more_one.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/menu_more_one.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/menu_more_two.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/menu_more_two.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/splash_holder.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/splash_holder.jpg
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/gdt_splash_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/gdt_splash_logo.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/listright_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/listright_press.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/logn_background.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/logn_background.jpg
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/osd_new_epg_next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/osd_new_epg_next.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/osd_new_soure_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/osd_new_soure_bg.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/video_vol_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/video_vol_black.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/video_vol_whrite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/video_vol_whrite.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/detail_juji_focused.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/detail_juji_focused.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/osd_new_channle_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/osd_new_channle_bg.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/osd_new_epg_current.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/osd_new_epg_current.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/general_loading_flower.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/general_loading_flower.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/img_frame_background.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/img_frame_background.jpg
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/live_channel_list_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/live_channel_list_bg.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/live_control_main_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/live_control_main_bg.png
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/detail_juji_selected_focused.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zero-edge-code/TvPlayer/HEAD/TvPlayer/src/main/res/drawable/detail_juji_selected_focused.png
--------------------------------------------------------------------------------
/Ijkplayer/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/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/update/CallBack.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay.update;
2 |
3 | /**
4 | * Created by gongxufan on 2017/9/6.
5 | */
6 |
7 | public interface CallBack {
8 | public void callback(int position);
9 | }
10 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Oct 28 01:20:16 CST 2017
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-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/values/attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/border_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/bg_dialog_confirm.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/tv_switch_bg_left.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
8 |
9 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/tv_switch_bg_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
8 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/layout/table_media_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/background_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/layout/table_media_info_section.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #FFFFFF
8 | #3F51B5
9 | #87CEFA
10 | #ADFF2F
11 | #000000
12 | #33000000
13 |
14 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/Constants.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay;
2 |
3 | public class Constants {
4 | public static final String APPID = "1106310717";
5 | public static final String BannerPosID = "9079537218417626401";
6 | public static final String InterteristalPosID = "8575134060152130849";
7 | public static final String SplashPosID = "8863364436303842593";
8 | public static final String NativePosID = "5000709048439488";
9 | public static final String NativeVideoPosID = "2050206699818455";
10 | public static final String NativeExpressPosID = "7030020348049331";
11 | }
12 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/background_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
12 |
13 |
18 |
19 |
--------------------------------------------------------------------------------
/TvPlayer/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Studio SDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/Ijkplayer/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 /usr/local/softs/android-sdk-linux/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 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/layout/table_media_info_row1.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/drawable/video_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
13 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/BootBroadcastReceiver.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay;
2 |
3 |
4 | import android.content.BroadcastReceiver;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.util.Log;
8 |
9 | /**
10 | * @Description 功能描述: 该类用来实现该app开机自动运行
11 | */
12 | public class BootBroadcastReceiver extends BroadcastReceiver {
13 |
14 | @Override
15 | public void onReceive(Context context, Intent intent) {
16 |
17 | Log.d("XRGPS", "BootReceiver.onReceive: " + intent.getAction());
18 | //MainActivity就是开机显示的界面
19 | Intent mBootIntent = new Intent(context, MainActivity.class);
20 | //下面这句话必须加上才能开机自动运行app的界面
21 | mBootIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
22 | context.startActivity(mBootIntent);
23 | }
24 | }
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/layout/table_media_info_row2.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
23 |
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ## Project-wide Gradle settings.
2 | #
3 | # For more details on how to configure your build environment visit
4 | # http://www.gradle.org/docs/current/userguide/build_environment.html
5 | #
6 | # Specifies the JVM arguments used for the daemon process.
7 | # The setting is particularly useful for tweaking memory settings.
8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m
9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
10 | #
11 | # When configured, Gradle will run in incubating parallel mode.
12 | # This option should only be used with decoupled projects. More details, visit
13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14 | # org.gradle.parallel=true
15 | #Thu Oct 26 15:14:29 CST 2017
16 | systemProp.http.proxyHost=mirrors.neusoft.edu.cn
17 | systemProp.http.proxyPort=80
18 |
--------------------------------------------------------------------------------
/Ijkplayer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion '26.0.2'
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | lintOptions {
20 | checkReleaseBuilds false
21 | // Or, if you prefer, you can continue to checkforerrorsinrelease builds,
22 | // but continue the build even whenerrorsarefound:
23 | abortOnError false
24 | }
25 | }
26 |
27 | dependencies {
28 | compile fileTree(dir: 'libs', include: ['*.jar'])
29 | testCompile 'junit:junit:4.12'
30 | compile 'com.android.support:appcompat-v7:23.4.0'
31 | }
32 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/layout/detail_menu_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/pragma/Pragma.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package tv.danmaku.ijk.media.player.pragma;
17 |
18 | /*-
19 | * configurated by app project
20 | */
21 | public class Pragma {
22 | public static final boolean ENABLE_VERBOSE = true;
23 | }
24 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/IjkLibLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | public interface IjkLibLoader {
20 | public void loadLibrary(String libName) throws UnsatisfiedLinkError,
21 | SecurityException;
22 | }
23 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/exceptions/IjkMediaException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.exceptions;
18 |
19 | public class IjkMediaException extends Exception {
20 | private static final long serialVersionUID = 7234796519009099506L;
21 | }
22 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/ISurfaceTextureHost.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.graphics.SurfaceTexture;
20 |
21 | public interface ISurfaceTextureHost {
22 | void releaseSurfaceTexture(SurfaceTexture surfaceTexture);
23 | }
24 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/layout/item_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
27 |
28 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/MediaInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | public class MediaInfo {
20 | public String mMediaPlayerName;
21 |
22 | public String mVideoDecoder;
23 | public String mVideoDecoderImpl;
24 |
25 | public String mAudioDecoder;
26 | public String mAudioDecoderImpl;
27 |
28 | public IjkMediaMeta mMeta;
29 | }
30 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/ISurfaceTextureHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.graphics.SurfaceTexture;
20 |
21 | public interface ISurfaceTextureHolder {
22 | void setSurfaceTexture(SurfaceTexture surfaceTexture);
23 |
24 | SurfaceTexture getSurfaceTexture();
25 |
26 | void setSurfaceTextureHost(ISurfaceTextureHost surfaceTextureHost);
27 | }
28 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/misc/IMediaFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | public interface IMediaFormat {
20 | // Common keys
21 | String KEY_MIME = "mime";
22 |
23 | // Video Keys
24 | String KEY_WIDTH = "width";
25 | String KEY_HEIGHT = "height";
26 |
27 | String getString(String name);
28 |
29 | int getInteger(String name);
30 | }
31 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
18 |
19 |
29 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/misc/ITrackInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | public interface ITrackInfo {
20 | int MEDIA_TRACK_TYPE_AUDIO = 2;
21 | int MEDIA_TRACK_TYPE_METADATA = 5;
22 | int MEDIA_TRACK_TYPE_SUBTITLE = 4;
23 | int MEDIA_TRACK_TYPE_TIMEDTEXT = 3;
24 | int MEDIA_TRACK_TYPE_UNKNOWN = 0;
25 | int MEDIA_TRACK_TYPE_VIDEO = 1;
26 |
27 | IMediaFormat getFormat();
28 |
29 | int getTrackType();
30 | }
31 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/annotations/AccessedByNative.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * is used by the JNI generator to create the necessary JNI
26 | * bindings and expose this method to native code.
27 | */
28 | @Target(ElementType.FIELD)
29 | @Retention(RetentionPolicy.CLASS)
30 | public @interface AccessedByNative {
31 | }
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/ijkplayer/media/IMediaController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
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 com.gxf.liveplay.ijkplayer.media;
18 |
19 | import android.view.View;
20 | import android.widget.MediaController;
21 |
22 | public interface IMediaController {
23 | void hide();
24 |
25 | boolean isShowing();
26 |
27 | void setAnchorView(View view);
28 |
29 | void setEnabled(boolean enabled);
30 |
31 | void setMediaPlayer(MediaController.MediaPlayerControl player);
32 |
33 | void show(int timeout);
34 |
35 | void show();
36 |
37 | //----------
38 | // Extends
39 | //----------
40 | void showOnce(View view);
41 | }
42 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/annotations/CalledByNative.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * is used by the JNI generator to create the necessary JNI
26 | * bindings and expose this method to native code.
27 | */
28 | @Target(ElementType.METHOD)
29 | @Retention(RetentionPolicy.CLASS)
30 | public @interface CalledByNative {
31 | /*
32 | * If present, tells which inner class the method belongs to.
33 | */
34 | public String value() default "";
35 | }
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 电视直播
3 | 登录
4 |
5 |
6 | 帐号
7 | 密码
8 | 登录直播平台
9 | 登录
10 | 帐号无效
11 | 密码长度太短
12 | 帐号或者密码错误
13 | 输入项不能为空
14 | 权限不足
15 | GDTslogan
16 | 点击跳过
17 | 提示信息
18 | 取消
19 | 确认
20 |
21 |
29 |
30 | ServiceSettings
31 |
32 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/update/ConfirmDialog.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay.update;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.TextView;
9 |
10 | import com.gxf.liveplay.R;
11 |
12 |
13 | public class ConfirmDialog extends Dialog {
14 |
15 | CallBack callback;
16 | private TextView content;
17 | private Button sureBtn;
18 | private Button cancleBtn;
19 |
20 | public ConfirmDialog(Context context, CallBack callback) {
21 | super(context, R.style.CustomDialog);
22 | this.callback = callback;
23 | setCustomDialog();
24 | }
25 |
26 | private void setCustomDialog() {
27 | View mView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_confirm, null);
28 | sureBtn = (Button)mView.findViewById(R.id.dialog_confirm_sure);
29 | cancleBtn = (Button)mView.findViewById(R.id.dialog_confirm_cancle);
30 | content = (TextView) mView.findViewById(R.id.dialog_confirm_title);
31 |
32 |
33 | sureBtn.setOnClickListener(new View.OnClickListener() {
34 | @Override
35 | public void onClick(View v) {
36 | callback.callback(1);
37 | ConfirmDialog.this.cancel();
38 | }
39 | });
40 | cancleBtn.setOnClickListener(new View.OnClickListener() {
41 | @Override
42 | public void onClick(View v) {
43 | callback.callback(0);
44 | ConfirmDialog.this.cancel();
45 | }
46 | });
47 | super.setContentView(mView);
48 | }
49 |
50 |
51 | public ConfirmDialog setContent(String s){
52 | content.setText(s);
53 | return this;
54 | }
55 |
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/MainActivityOffline.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.SharedPreferences;
7 | import android.os.Bundle;
8 | import android.widget.Toast;
9 |
10 | /**
11 | * splash
12 | * 启动登录检测
13 | */
14 | public class MainActivityOffline extends Activity {
15 | private final int SPLASH_DISPLAY_LENGHT = 1000; // 两秒后进入系统
16 | private boolean isUpdateChecked = false;
17 | public void checkLogin(){
18 | SharedPreferences userSettings = getSharedPreferences("auth", Context.MODE_PRIVATE);
19 | final String lastVedioUrl = userSettings.getString("lastVedioUrl", "none");
20 | final Toast toast = Toast.makeText(MainActivityOffline.this, "系统初始化失败...", Toast.LENGTH_SHORT);
21 | // 开启一个子线程,进行网络操作,等待有返回结果,使用handler通知UI
22 | new Thread(new Runnable() {
23 | @Override
24 | public void run() {
25 | try {
26 | PlayListCache.initPlayInfo(null,null);
27 | String url = lastVedioUrl;
28 | if (url.equals("none"))
29 | url = PlayListCache.playListMap.get(PlayListCache.playListMap.keySet().iterator().next());
30 | LiveActivityRel.activityStart(MainActivityOffline.this, url);
31 | MainActivityOffline.this.finish();
32 | } catch (Exception e) {
33 | toast.show();
34 | e.printStackTrace();
35 | }
36 | }
37 | }).start();
38 | }
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | setContentView(R.layout.activity_main);
43 | checkLogin();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TvPlayer
2 |
3 | 1,android智能电视播放器,可以播放各电视台节目,播放基于ijkplayer的实现
4 |
5 | 2,测试的源地址可能失效,如需测试可以自己更换播放源。HttpUtils.getOfflinePlayList()返回的是测试源地址
6 |
7 | 3,项目有MainActivityOffline和MainActivity,MainActivityOffline是离线使用的,MainActivity涉及到登录和节目列表获取
8 |
9 | 4,编译环境:Android Studio3.0,jdk8
10 |
11 | 本项目中的播放源地址可能会失效,如需测试需要更改可用的播放源,具体代码在com.gxf.liveplay.HttpUtils#getOfflinePlayList,数据格式如下:
12 |
13 | ```
14 | [
15 | {
16 | "group": "省内频道",
17 | "list": [
18 | {
19 | "湖南都市": "http://220.248.175.231:6610/001/2/ch00000090990000001049/index.m3u8?virtualDomain=001.live_hls.zte.com"
20 | },
21 | {
22 | "湖南经视": "http://220.248.175.230:6610/001/2/ch00000090990000001052/index.m3u8?virtualDomain=001.live_hls.zte.com"
23 | }
24 | ]
25 | },
26 | {
27 | "group": "其他频道",
28 | "list": [
29 | {
30 | "安徽卫视": "http://220.248.175.230:6610/001/2/ch00000090990000001024/index.m3u8?virtualDomain=001.live_hls.zte.com"
31 | },
32 | {
33 | "北京卫视": "http://220.248.175.230:6610/001/2/ch00000090990000001025/index.m3u8?virtualDomain=001.live_hls.zte.com"
34 | }
35 | ]
36 | },
37 | {
38 | "group": "高清频道",
39 | "list": [
40 | {
41 | "CCTV1综合HD": "http://220.248.175.230:6610/001/2/ch00000090990000001075/index.m3u8?virtualDomain=001.live_hls.zte.com"
42 | },
43 | {
44 | "湖南经视HD": "http://220.248.175.230:6610/001/2/ch00000090990000001080/index.m3u8?virtualDomain=001.live_hls.zte.com"
45 | }
46 | ]
47 | },
48 | {
49 | "group": "央视频道",
50 | "list": [
51 | {
52 | "CCTV1综合": "http://220.248.175.230:6610/001/2/ch00000090990000001075/index.m3u8?virtualDomain=001.live_hls.zte.com"
53 | },
54 | {
55 | "CCTV证券": "http://220.248.175.230:6610/001/2/ch00000090990000001133/index.m3u8?virtualDomain=001.live_hls.zte.com"
56 | }
57 | ]
58 | }
59 | ]
60 | ```
61 | # screenshot
62 | 
63 |
--------------------------------------------------------------------------------
/TvPlayer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion '26.0.2'
6 |
7 | defaultConfig {
8 | applicationId "com.gxf.liveplay"
9 | minSdkVersion 17
10 | targetSdkVersion 22
11 | versionCode 9
12 | versionName "1.9"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | lintOptions {
21 | checkReleaseBuilds false
22 | // Or, if you prefer, you can continue to checkforerrorsinrelease builds,
23 | // but continue the build even whenerrorsarefound:
24 | abortOnError false
25 | }
26 | sourceSets {
27 | main {
28 | jniLibs.srcDir 'libs'
29 | }
30 |
31 | // Move the tests to tests/java, tests/res, etc...
32 | instrumentTest.setRoot('tests')
33 |
34 | // Move the build types to build-types/
35 | // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
36 | // This moves them out of them default location under src//... which would
37 | // conflict with src/ being used by the main source set.
38 | // Adding new build types or product flavors should be accompanied
39 | // by a similar customization.
40 | debug.setRoot('build-types/debug')
41 | release.setRoot('build-types/release')
42 | }
43 | }
44 |
45 | dependencies {
46 | compile fileTree(dir: 'libs', include: ['*.jar'])
47 | compile project(':Ijkplayer')
48 |
49 | compile 'com.android.support:appcompat-v7:23.4.0'
50 | compile 'com.android.support:design:23.1.1'
51 | compile 'com.android.support:cardview-v7:23.1.1'
52 | compile 'com.alibaba:fastjson:1.1.62.android'
53 | compile 'com.squareup.okhttp3:okhttp:3.8.1'
54 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
55 | testCompile 'junit:junit:4.12'
56 | }
57 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/layout/layout_menu.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
16 |
17 |
25 |
26 |
36 |
37 |
45 |
46 |
47 |
48 |
55 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/misc/AndroidMediaFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import android.annotation.TargetApi;
20 | import android.media.MediaFormat;
21 | import android.os.Build;
22 |
23 | public class AndroidMediaFormat implements IMediaFormat {
24 | private MediaFormat mMediaFormat;
25 |
26 | public AndroidMediaFormat(MediaFormat mediaFormat) {
27 | mMediaFormat = mediaFormat;
28 | }
29 |
30 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
31 | @Override
32 | public int getInteger(String name) {
33 | if (mMediaFormat == null)
34 | return 0;
35 |
36 | return mMediaFormat.getInteger(name);
37 | }
38 |
39 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
40 | @Override
41 | public String getString(String name) {
42 | if (mMediaFormat == null)
43 | return null;
44 |
45 | return mMediaFormat.getString(name);
46 | }
47 |
48 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
49 | @Override
50 | public String toString() {
51 | StringBuilder out = new StringBuilder(128);
52 | out.append(getClass().getName());
53 | out.append('{');
54 | if (mMediaFormat != null) {
55 | out.append(mMediaFormat.toString());
56 | } else {
57 | out.append("null");
58 | }
59 | out.append('}');
60 | return out.toString();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/layout/activity_service_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
24 |
25 |
31 |
32 |
41 |
42 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/ijkplayer/services/MediaPlayerService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
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 com.gxf.liveplay.ijkplayer.services;
18 |
19 | import android.app.Service;
20 | import android.content.Context;
21 | import android.content.Intent;
22 | import android.os.IBinder;
23 | import android.support.annotation.Nullable;
24 |
25 | import tv.danmaku.ijk.media.player.IMediaPlayer;
26 |
27 | public class MediaPlayerService extends Service {
28 | private static IMediaPlayer sMediaPlayer;
29 |
30 | public static Intent newIntent(Context context) {
31 | Intent intent = new Intent(context, MediaPlayerService.class);
32 | return intent;
33 | }
34 |
35 | public static void intentToStart(Context context) {
36 | context.startService(newIntent(context));
37 | }
38 |
39 | public static void intentToStop(Context context) {
40 | context.stopService(newIntent(context));
41 | }
42 |
43 | @Nullable
44 | @Override
45 | public IBinder onBind(Intent intent) {
46 | return null;
47 | }
48 |
49 | public static void setMediaPlayer(IMediaPlayer mp) {
50 | if (sMediaPlayer != null && sMediaPlayer != mp) {
51 | if (sMediaPlayer.isPlaying())
52 | sMediaPlayer.stop();
53 | sMediaPlayer.release();
54 | sMediaPlayer = null;
55 | }
56 | sMediaPlayer = mp;
57 | }
58 |
59 | public static IMediaPlayer getMediaPlayer() {
60 | return sMediaPlayer;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/misc/IjkTrackInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import tv.danmaku.ijk.media.player.IjkMediaMeta;
20 |
21 | public class IjkTrackInfo implements ITrackInfo {
22 | private int mTrackType = MEDIA_TRACK_TYPE_UNKNOWN;
23 | private IjkMediaMeta.IjkStreamMeta mStreamMeta;
24 |
25 | public IjkTrackInfo(IjkMediaMeta.IjkStreamMeta streamMeta) {
26 | mStreamMeta = streamMeta;
27 | }
28 |
29 | @Override
30 | public IMediaFormat getFormat() {
31 | return new IjkMediaFormat(mStreamMeta);
32 | }
33 |
34 | public void setMediaMeta(IjkMediaMeta.IjkStreamMeta streamMeta) {
35 | mStreamMeta = streamMeta;
36 | }
37 |
38 | @Override
39 | public int getTrackType() {
40 | return mTrackType;
41 | }
42 |
43 | public void setTrackType(int trackType) {
44 | mTrackType = trackType;
45 | }
46 |
47 | @Override
48 | public String toString() {
49 | StringBuilder out = new StringBuilder(128);
50 | out.append(getClass().getName());
51 | out.append('{');
52 | switch (mTrackType) {
53 | case MEDIA_TRACK_TYPE_VIDEO:
54 | out.append("VIDEO");
55 | break;
56 | case MEDIA_TRACK_TYPE_AUDIO:
57 | out.append("AUDIO");
58 | break;
59 | case MEDIA_TRACK_TYPE_TIMEDTEXT:
60 | out.append("TIMEDTEXT");
61 | break;
62 | case MEDIA_TRACK_TYPE_SUBTITLE:
63 | out.append("SUBTITLE");
64 | break;
65 | default:
66 | out.append("UNKNOWN");
67 | break;
68 | }
69 | // out.append(", " + mFormat.toString());
70 | out.append("}");
71 | return out.toString();
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.SharedPreferences;
7 | import android.os.Bundle;
8 | import android.widget.Toast;
9 |
10 | /**
11 | * splash
12 | * 启动登录检测
13 | */
14 | public class MainActivity extends Activity {
15 | private final int SPLASH_DISPLAY_LENGHT = 1000; // 两秒后进入系统
16 | private boolean isUpdateChecked = false;
17 | public void checkLogin(){
18 | SharedPreferences userSettings = getSharedPreferences("auth", Context.MODE_PRIVATE);
19 | final String userName = userSettings.getString("userName", "none");
20 | final String password = userSettings.getString("password", "none");
21 | final String lastVedioUrl = userSettings.getString("lastVedioUrl", "none");
22 | final String serviceUrl = userSettings.getString("serviceUrl", "none");
23 | if(!"none".equals(serviceUrl))
24 | HttpUtils.apiPath = serviceUrl;
25 | final Toast toast = Toast.makeText(MainActivity.this, "获取节目列表错误,系统初始化失败...", Toast.LENGTH_SHORT);
26 | // 开启一个子线程,进行网络操作,等待有返回结果,使用handler通知UI
27 | new Thread(new Runnable() {
28 | @Override
29 | public void run() {
30 | try {
31 | //Thread.currentThread().sleep(SPLASH_DISPLAY_LENGHT);
32 | //跳转登录
33 | if ("none".equals(userName) || !HttpUtils.login(userName, password,MainActivity.this) || LoginActivity.state != -1) {
34 | MainActivity.this.startActivity(new Intent(MainActivity.this, LoginActivity.class));
35 | } else {
36 | PlayListCache.initPlayInfo(userName,password);
37 | String url = lastVedioUrl;
38 | if (url.equals("none"))
39 | url = PlayListCache.playListMap.get(PlayListCache.playListMap.keySet().iterator().next());
40 | LiveActivityRel.activityStart(MainActivity.this, url);
41 | }
42 | MainActivity.this.finish();
43 | } catch (Exception e) {
44 | toast.show();
45 | e.printStackTrace();
46 | }
47 | }
48 | }).start();
49 | }
50 | @Override
51 | protected void onCreate(Bundle savedInstanceState) {
52 | super.onCreate(savedInstanceState);
53 | setContentView(R.layout.activity_main);
54 | checkLogin();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/Ijkplayer/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 | Render
13 | Scale
14 | Info
15 | fps (output)
16 | fps (decode)
17 |
18 | Media Information
19 | Player
20 | Media
21 | Profile level
22 | Pixel format
23 | Resolution
24 | Length
25 | Stream #%d
26 | Type
27 | Codec
28 | Frame rate
29 | Bit rate
30 | Sample rate
31 | Channels
32 |
33 | Video
34 | Audio
35 | Subtitle
36 | Timed text
37 | Meta data
38 | Unknown
39 |
40 | Invalid progressive playback
41 | Unknown
42 | OK
43 |
44 | Aspect / Fit parent
45 | Aspect / Fill parent
46 | Aspect / Wrap content
47 | Free / Fill parent
48 | 16:9 / Fit parent
49 | 4:3 / Fit parent
50 |
51 | Render: None
52 | Render: SurfaceView
53 | Render: TextureView
54 |
55 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/ServiceSettings.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.os.Bundle;
6 | import android.support.design.widget.FloatingActionButton;
7 | import android.support.design.widget.Snackbar;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.Toolbar;
10 | import android.view.View;
11 | import android.widget.Button;
12 | import android.widget.EditText;
13 | import android.widget.Toast;
14 |
15 | public class ServiceSettings extends AppCompatActivity {
16 |
17 | private EditText editText;
18 | private Button saveUrl;
19 | private Button reloadUrl;
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_service_settings);
24 | final SharedPreferences userSettings = getSharedPreferences("auth", Context.MODE_PRIVATE);
25 | String serviceUrl = userSettings.getString("serviceUrl","none");
26 | editText = (EditText) findViewById(R.id.serviceUrl);
27 | saveUrl = (Button) findViewById(R.id.saveServiceUrl);
28 | reloadUrl = (Button) findViewById(R.id.reloadServiceUrl);
29 | final Toast toast = Toast.makeText(this, "服务地址提交成功...", Toast.LENGTH_SHORT);
30 | final Toast toast2 = Toast.makeText(this, "服务地址恢复默认值成功...", Toast.LENGTH_SHORT);
31 | //设置默认地址
32 | if("none".equals(serviceUrl)){
33 | editText.setText(HttpUtils.apiPathOuter);
34 | }else{
35 | editText.setText(serviceUrl);
36 | }
37 | saveUrl.setOnClickListener(new View.OnClickListener() {
38 | @Override
39 | public void onClick(View v) {
40 | SharedPreferences.Editor editor = userSettings.edit();
41 | String newUrl = editText.getText().toString();
42 | editor.putString("serviceUrl",newUrl);
43 | HttpUtils.apiPath = newUrl;
44 | editor.commit();
45 | toast.show();
46 | ServiceSettings.this.finish();
47 | }
48 | });
49 | reloadUrl.setOnClickListener(new View.OnClickListener() {
50 | @Override
51 | public void onClick(View v) {
52 | SharedPreferences.Editor editor = userSettings.edit();
53 | editText.setText(HttpUtils.apiPathOuter);
54 | editor.putString("serviceUrl",HttpUtils.apiPathOuter);
55 | HttpUtils.apiPath = HttpUtils.apiPathOuter;
56 | editor.commit();
57 | toast2.show();
58 | ServiceSettings.this.finish();
59 | }
60 | });
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/ijkplayer/media/IRenderView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
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 com.gxf.liveplay.ijkplayer.media;
18 |
19 | import android.graphics.SurfaceTexture;
20 | import android.support.annotation.NonNull;
21 | import android.support.annotation.Nullable;
22 | import android.view.Surface;
23 | import android.view.SurfaceHolder;
24 | import android.view.View;
25 |
26 | import tv.danmaku.ijk.media.player.IMediaPlayer;
27 |
28 | public interface IRenderView {
29 | static final int AR_ASPECT_FIT_PARENT = 0; // without clip
30 | static final int AR_ASPECT_FILL_PARENT = 1; // may clip
31 | static final int AR_ASPECT_WRAP_CONTENT = 2;
32 | static final int AR_MATCH_PARENT = 3;
33 | static final int AR_16_9_FIT_PARENT = 4;
34 | static final int AR_4_3_FIT_PARENT = 5;
35 |
36 | View getView();
37 |
38 | boolean shouldWaitForResize();
39 |
40 | void setVideoSize(int videoWidth, int videoHeight);
41 |
42 | void setVideoSampleAspectRatio(int videoSarNum, int videoSarDen);
43 |
44 | void setVideoRotation(int degree);
45 |
46 | void setAspectRatio(int aspectRatio);
47 |
48 | void addRenderCallback(@NonNull IRenderCallback callback);
49 |
50 | void removeRenderCallback(@NonNull IRenderCallback callback);
51 |
52 | interface ISurfaceHolder {
53 | void bindToMediaPlayer(IMediaPlayer mp);
54 |
55 | @NonNull
56 | IRenderView getRenderView();
57 |
58 | @Nullable
59 | SurfaceHolder getSurfaceHolder();
60 |
61 | @Nullable
62 | Surface openSurface();
63 |
64 | @Nullable
65 | SurfaceTexture getSurfaceTexture();
66 | }
67 |
68 | public interface IRenderCallback {
69 | /**
70 | * @param holder
71 | * @param width could be 0
72 | * @param height could be 0
73 | */
74 | void onSurfaceCreated(@NonNull ISurfaceHolder holder, int width, int height);
75 |
76 | /**
77 | * @param holder
78 | * @param format could be 0
79 | * @param width
80 | * @param height
81 | */
82 | void onSurfaceChanged(@NonNull ISurfaceHolder holder, int format, int width, int height);
83 |
84 | void onSurfaceDestroyed(@NonNull ISurfaceHolder holder);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/PlayListCache.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay;
2 |
3 | import com.alibaba.fastjson.JSON;
4 | import com.alibaba.fastjson.JSONArray;
5 | import com.alibaba.fastjson.JSONObject;
6 |
7 | import java.util.ArrayList;
8 | import java.util.HashMap;
9 | import java.util.List;
10 | import java.util.Map;
11 |
12 | /**
13 | * Created by gongxufan on 2017/8/25.
14 | */
15 |
16 | public class PlayListCache {
17 | public static Map playListMap = new HashMap();
18 | public static Map>> groupInfo = new HashMap>>();
19 | //1=全部频道 2=央视频道 3=卫视频道 4=省内频道 5=其他频道
20 | public static String[] groupInfoArray;
21 | public static List channelInfoList = new ArrayList<>();
22 | //当前频道分组编号
23 | public static int index = 0;
24 | //当前播放的节目编号
25 | public static int currChannel = 0;
26 |
27 | public static void locateCurrChannel(String url){
28 | for (int i = 0; i < channelInfoList.size(); i++) {
29 | String s = channelInfoList.get(i);
30 | if(url.equals(s)){
31 | PlayListCache.currChannel = i;
32 | return;
33 | }
34 | }
35 | }
36 | public static void initPlayInfo(String userName,String password) throws Exception{
37 | String playList = HttpUtils.getOfflinePlayList();
38 | JSONArray jsonArray = JSON.parseArray(playList);
39 | PlayListCache.groupInfoArray = new String[jsonArray.size() + 1];
40 | PlayListCache.groupInfoArray[0] = "我的频道";
41 | if (jsonArray != null && jsonArray.size() > 0) {
42 | for (int i = 0; i < jsonArray.size(); i++) {
43 | JSONObject jo = jsonArray.getJSONObject(i);
44 | //分组
45 | String group = (String) jo.get("group");
46 | PlayListCache.groupInfoArray[i + 1] = group;
47 | JSONArray list = jo.getJSONArray("list");
48 | if (list != null && list.size() > 0) {
49 | ArrayList> hashMaps = new ArrayList>();
50 | int no = 0;
51 | for (int j = 0; j < list.size(); j++) {
52 | JSONObject o = list.getJSONObject(j);
53 | HashMap m = new HashMap();
54 | for (String k : o.keySet()) {
55 | String v = (String) o.get(k);
56 | m.put("title", k);
57 | m.put("no", String.valueOf(++no));
58 | channelInfoList.add(v);
59 | PlayListCache.playListMap.put(k, v);
60 | hashMaps.add(m);
61 | }
62 | }
63 | PlayListCache.groupInfo.put(group, hashMaps);
64 | }
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/update/UpdateAppReceiver.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay.update;
2 |
3 | import android.app.DownloadManager;
4 | import android.content.BroadcastReceiver;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.database.Cursor;
8 | import android.net.Uri;
9 | import android.os.Build;
10 | import android.support.v4.content.FileProvider;
11 |
12 | import java.io.File;
13 |
14 |
15 | /**
16 | * 注册
17 | *
18 | *
19 | */
20 | public class UpdateAppReceiver extends BroadcastReceiver {
21 | public UpdateAppReceiver() {
22 | }
23 |
24 | @Override
25 | public void onReceive(Context context, Intent intent) {
26 | // 处理下载完成
27 | Cursor c = null;
28 |
29 | if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) {
30 | if (DownloadAppUtils.downloadUpdateApkId >= 0) {
31 | long downloadId = DownloadAppUtils.downloadUpdateApkId;
32 | DownloadManager.Query query = new DownloadManager.Query();
33 | query.setFilterById(downloadId);
34 | DownloadManager downloadManager = (DownloadManager) context
35 | .getSystemService(Context.DOWNLOAD_SERVICE);
36 | c = downloadManager.query(query);
37 | if (c.moveToFirst()) {
38 | int status = c.getInt(c
39 | .getColumnIndex(DownloadManager.COLUMN_STATUS));
40 | if (status == DownloadManager.STATUS_FAILED) {
41 | downloadManager.remove(downloadId);
42 |
43 | } else if (status == DownloadManager.STATUS_SUCCESSFUL) {
44 | if (DownloadAppUtils.downloadUpdateApkFilePath != null) {
45 | Intent i = new Intent(Intent.ACTION_VIEW);
46 | File apkFile = new File(DownloadAppUtils.downloadUpdateApkFilePath);
47 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
48 | i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
49 | Uri contentUri = FileProvider.getUriForFile(
50 | context, context.getPackageName() + ".fileprovider", apkFile);
51 | i.setDataAndType(contentUri, "application/vnd.android.package-archive");
52 | } else {
53 | i.setDataAndType(Uri.fromFile(apkFile),
54 | "application/vnd.android.package-archive");
55 | }
56 | i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
57 | context.startActivity(i);
58 | }
59 | }
60 | }
61 | c.close();
62 | }
63 | }
64 |
65 |
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/misc/AndroidTrackInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import android.annotation.TargetApi;
20 | import android.media.MediaFormat;
21 | import android.media.MediaPlayer;
22 | import android.os.Build;
23 |
24 | public class AndroidTrackInfo implements ITrackInfo {
25 | private MediaPlayer.TrackInfo mTrackInfo;
26 |
27 | public static AndroidTrackInfo[] fromMediaPlayer(MediaPlayer mp) {
28 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
29 | return fromTrackInfo(mp.getTrackInfo());
30 |
31 | return null;
32 | }
33 |
34 | public static AndroidTrackInfo[] fromTrackInfo(MediaPlayer.TrackInfo[] trackInfos) {
35 | if (trackInfos == null)
36 | return null;
37 |
38 | AndroidTrackInfo androidTrackInfo[] = new AndroidTrackInfo[trackInfos.length];
39 | for (int i = 0; i < trackInfos.length; ++i) {
40 | androidTrackInfo[i] = new AndroidTrackInfo(trackInfos[i]);
41 | }
42 |
43 | return androidTrackInfo;
44 | }
45 |
46 | public AndroidTrackInfo(MediaPlayer.TrackInfo trackInfo) {
47 | mTrackInfo = trackInfo;
48 | }
49 |
50 | @TargetApi(Build.VERSION_CODES.KITKAT)
51 | @Override
52 | public IMediaFormat getFormat() {
53 | if (mTrackInfo == null)
54 | return null;
55 |
56 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
57 | return null;
58 |
59 | MediaFormat mediaFormat = mTrackInfo.getFormat();
60 | if (mediaFormat == null)
61 | return null;
62 |
63 | return new AndroidMediaFormat(mediaFormat);
64 | }
65 |
66 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
67 | @Override
68 | public int getTrackType() {
69 | if (mTrackInfo == null)
70 | return MEDIA_TRACK_TYPE_UNKNOWN;
71 |
72 | return mTrackInfo.getTrackType();
73 | }
74 |
75 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
76 | @Override
77 | public String toString() {
78 | StringBuilder out = new StringBuilder(128);
79 | out.append(getClass().getName());
80 | out.append('{');
81 | if (mTrackInfo != null) {
82 | out.append(mTrackInfo.toString());
83 | } else {
84 | out.append("null");
85 | }
86 | out.append('}');
87 | return out.toString();
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/BaseMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.annotation.TargetApi;
20 | import android.content.Context;
21 | import android.net.Uri;
22 | import android.os.Build;
23 | import android.view.Surface;
24 |
25 | import java.io.FileDescriptor;
26 | import java.io.IOException;
27 | import java.util.Map;
28 |
29 | @Deprecated
30 | public abstract class BaseMediaPlayer implements IMediaPlayer {
31 | private boolean mIsLogEnabled;
32 |
33 | public boolean isLogEnabled() {
34 | return mIsLogEnabled;
35 | }
36 |
37 | @Override
38 | public void setLogEnabled(boolean enable) {
39 | mIsLogEnabled = enable;
40 | }
41 |
42 | @Override
43 | public boolean isPlayable() {
44 | return true;
45 | }
46 |
47 | @Override
48 | public void setAudioStreamType(int streamtype) {
49 | }
50 |
51 | @Override
52 | public void setKeepInBackground(boolean keepInBackground) {
53 | }
54 |
55 | @Override
56 | public int getVideoSarNum() {
57 | return 1;
58 | }
59 |
60 | @Override
61 | public int getVideoSarDen() {
62 | return 1;
63 | }
64 |
65 | @Deprecated
66 | @Override
67 | public void setWakeMode(Context context, int mode) {
68 | return;
69 | }
70 |
71 | @Override
72 | public int getAudioSessionId() {
73 | return 0;
74 | }
75 |
76 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
77 | @Override
78 | public void setSurface(Surface surface) {
79 | }
80 |
81 | @Override
82 | public void setDataSource(Context context, Uri uri)
83 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
84 | setDataSource(uri.getPath());
85 | }
86 |
87 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
88 | @Override
89 | public void setDataSource(Context context, Uri uri, Map headers)
90 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
91 | setDataSource(uri.getPath());
92 | }
93 |
94 | @Override
95 | public void setDataSource(FileDescriptor fd)
96 | throws IOException, IllegalArgumentException, IllegalStateException {
97 | throw new RuntimeException("does not support setDataSource(FileDescriptor fd)");
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/layout/dialog_confirm.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
15 |
26 |
27 |
39 |
40 |
41 |
42 |
47 |
48 |
49 |
53 |
54 |
65 |
69 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/TextureMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.annotation.TargetApi;
20 | import android.graphics.SurfaceTexture;
21 | import android.os.Build;
22 | import android.view.Surface;
23 | import android.view.SurfaceHolder;
24 |
25 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
26 | public class TextureMediaPlayer extends MediaPlayerProxy implements IMediaPlayer, ISurfaceTextureHolder {
27 | private SurfaceTexture mSurfaceTexture;
28 | private ISurfaceTextureHost mSurfaceTextureHost;
29 |
30 | public TextureMediaPlayer(IMediaPlayer backEndMediaPlayer) {
31 | super(backEndMediaPlayer);
32 | }
33 |
34 | public void releaseSurfaceTexture() {
35 | if (mSurfaceTexture != null) {
36 | if (mSurfaceTextureHost != null) {
37 | mSurfaceTextureHost.releaseSurfaceTexture(mSurfaceTexture);
38 | } else {
39 | mSurfaceTexture.release();
40 | }
41 | mSurfaceTexture = null;
42 | }
43 | }
44 |
45 | //--------------------
46 | // IMediaPlayer
47 | //--------------------
48 | @Override
49 | public void reset() {
50 | super.reset();
51 | releaseSurfaceTexture();
52 | }
53 |
54 | @Override
55 | public void release() {
56 | super.release();
57 | releaseSurfaceTexture();
58 | }
59 |
60 | @Override
61 | public void setDisplay(SurfaceHolder sh) {
62 | if (mSurfaceTexture == null)
63 | super.setDisplay(sh);
64 | }
65 |
66 | @Override
67 | public void setSurface(Surface surface) {
68 | if (mSurfaceTexture == null)
69 | super.setSurface(surface);
70 | }
71 |
72 | //--------------------
73 | // ISurfaceTextureHolder
74 | //--------------------
75 |
76 | @Override
77 | public void setSurfaceTexture(SurfaceTexture surfaceTexture) {
78 | if (mSurfaceTexture == surfaceTexture)
79 | return;
80 |
81 | releaseSurfaceTexture();
82 | mSurfaceTexture = surfaceTexture;
83 | if (surfaceTexture == null) {
84 | super.setSurface(null);
85 | } else {
86 | super.setSurface(new Surface(surfaceTexture));
87 | }
88 | }
89 |
90 | @Override
91 | public SurfaceTexture getSurfaceTexture() {
92 | return mSurfaceTexture;
93 | }
94 |
95 | @Override
96 | public void setSurfaceTextureHost(ISurfaceTextureHost surfaceTextureHost) {
97 | mSurfaceTextureHost = surfaceTextureHost;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/update/DownloadAppUtils.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay.update;
2 |
3 | import android.app.DownloadManager;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.IntentFilter;
7 | import android.net.Uri;
8 | import android.os.Environment;
9 | import android.text.TextUtils;
10 | import android.util.Log;
11 |
12 | import com.gxf.liveplay.LiveActivityRel;
13 |
14 | import java.io.File;
15 |
16 |
17 |
18 | public class DownloadAppUtils {
19 | private static final String TAG = DownloadAppUtils.class.getSimpleName();
20 | public static long downloadUpdateApkId = -1;//下载更新Apk 下载任务对应的Id
21 | public static String downloadUpdateApkFilePath;//下载更新Apk 文件路径
22 |
23 | /**
24 | * 通过浏览器下载APK包
25 | * @param context
26 | * @param url
27 | */
28 | public static void downloadForWebView(Context context, String url) {
29 | Uri uri = Uri.parse(url);
30 | Intent intent = new Intent(Intent.ACTION_VIEW, uri);
31 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
32 | context.startActivity(intent);
33 | }
34 |
35 |
36 | /**
37 | * 下载更新apk包
38 | * 权限:1,
39 | * @param context
40 | * @param url
41 | */
42 | public static void downloadForAutoInstall(Context context, String url, String fileName, String title) {
43 | if (TextUtils.isEmpty(url)) {
44 | return;
45 | }
46 | try {
47 | Uri uri = Uri.parse(url);
48 | DownloadManager downloadManager = (DownloadManager) context
49 | .getSystemService(Context.DOWNLOAD_SERVICE);
50 | DownloadManager.Request request = new DownloadManager.Request(uri);
51 | //在通知栏中显示
52 | request.setVisibleInDownloadsUi(true);
53 | request.setTitle(title);
54 |
55 | // VISIBILITY_VISIBLE: 下载过程中可见, 下载完后自动消失 (默认)
56 | // VISIBILITY_VISIBLE_NOTIFY_COMPLETED: 下载过程中和下载完成后均可见
57 | // VISIBILITY_HIDDEN: 始终不显示通知
58 | if (!UpdateAppUtils.showNotification)
59 | request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
60 |
61 |
62 |
63 | String filePath = null;
64 | if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {//外部存储卡
65 | filePath = Environment.getExternalStorageDirectory().getAbsolutePath();
66 | } else {
67 | Log.i(TAG,"没有SD卡");
68 | return;
69 | }
70 |
71 | downloadUpdateApkFilePath = filePath + File.separator + fileName;
72 | deleteFile(downloadUpdateApkFilePath);// 若存在,则删除
73 | Uri fileUri = Uri.fromFile(new File(downloadUpdateApkFilePath));
74 | request.setDestinationUri(fileUri);
75 | downloadUpdateApkId = downloadManager.enqueue(request);
76 |
77 | } catch (Exception e) {
78 | e.printStackTrace();
79 | downloadForWebView(context, url);
80 | }finally {
81 |
82 | }
83 | }
84 |
85 |
86 | private static boolean deleteFile(String fileStr) {
87 | File file = new File(fileStr);
88 | return file.delete();
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/layout/activity_play_rel.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
17 |
18 |
24 |
25 |
30 |
31 |
40 |
41 |
50 |
51 |
52 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
25 |
31 |
41 |
42 |
43 |
44 |
50 |
51 |
64 |
65 |
66 |
79 |
89 |
90 |
100 |
101 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/AbstractMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | public abstract class AbstractMediaPlayer implements IMediaPlayer {
20 | private OnPreparedListener mOnPreparedListener;
21 | private OnCompletionListener mOnCompletionListener;
22 | private OnBufferingUpdateListener mOnBufferingUpdateListener;
23 | private OnSeekCompleteListener mOnSeekCompleteListener;
24 | private OnVideoSizeChangedListener mOnVideoSizeChangedListener;
25 | private OnErrorListener mOnErrorListener;
26 | private OnInfoListener mOnInfoListener;
27 |
28 | public final void setOnPreparedListener(OnPreparedListener listener) {
29 | mOnPreparedListener = listener;
30 | }
31 |
32 | public final void setOnCompletionListener(OnCompletionListener listener) {
33 | mOnCompletionListener = listener;
34 | }
35 |
36 | public final void setOnBufferingUpdateListener(
37 | OnBufferingUpdateListener listener) {
38 | mOnBufferingUpdateListener = listener;
39 | }
40 |
41 | public final void setOnSeekCompleteListener(OnSeekCompleteListener listener) {
42 | mOnSeekCompleteListener = listener;
43 | }
44 |
45 | public final void setOnVideoSizeChangedListener(
46 | OnVideoSizeChangedListener listener) {
47 | mOnVideoSizeChangedListener = listener;
48 | }
49 |
50 | public final void setOnErrorListener(OnErrorListener listener) {
51 | mOnErrorListener = listener;
52 | }
53 |
54 | public final void setOnInfoListener(OnInfoListener listener) {
55 | mOnInfoListener = listener;
56 | }
57 |
58 | public void resetListeners() {
59 | mOnPreparedListener = null;
60 | mOnBufferingUpdateListener = null;
61 | mOnCompletionListener = null;
62 | mOnSeekCompleteListener = null;
63 | mOnVideoSizeChangedListener = null;
64 | mOnErrorListener = null;
65 | mOnInfoListener = null;
66 | }
67 |
68 | protected final void notifyOnPrepared() {
69 | if (mOnPreparedListener != null)
70 | mOnPreparedListener.onPrepared(this);
71 | }
72 |
73 | protected final void notifyOnCompletion() {
74 | if (mOnCompletionListener != null)
75 | mOnCompletionListener.onCompletion(this);
76 | }
77 |
78 | protected final void notifyOnBufferingUpdate(int percent) {
79 | if (mOnBufferingUpdateListener != null)
80 | mOnBufferingUpdateListener.onBufferingUpdate(this, percent);
81 | }
82 |
83 | protected final void notifyOnSeekComplete() {
84 | if (mOnSeekCompleteListener != null)
85 | mOnSeekCompleteListener.onSeekComplete(this);
86 | }
87 |
88 | protected final void notifyOnVideoSizeChanged(int width, int height,
89 | int sarNum, int sarDen) {
90 | if (mOnVideoSizeChangedListener != null)
91 | mOnVideoSizeChangedListener.onVideoSizeChanged(this, width, height,
92 | sarNum, sarDen);
93 | }
94 |
95 | protected final boolean notifyOnError(int what, int extra) {
96 | if (mOnErrorListener != null)
97 | return mOnErrorListener.onError(this, what, extra);
98 | return false;
99 | }
100 |
101 | protected final boolean notifyOnInfo(int what, int extra) {
102 | if (mOnInfoListener != null)
103 | return mOnInfoListener.onInfo(this, what, extra);
104 | return false;
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/res/values/strings_pref.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | General
5 |
6 | pref.enable_background_play
7 | Enable background play
8 | need Android 4.0+
9 |
10 | pref.using_android_player
11 | Using system player
12 |
13 |
14 | pref.player
15 | Choose Player
16 |
17 | - Auto Select
18 | - AndroidMediaPlayer
19 | - IjkMediaPlayer
20 | - IjkExoMediaPlayer
21 |
22 |
23 | - 0
24 | - 1
25 | - 2
26 | - 3
27 |
28 |
29 | - Auto Select
30 | - AndroidMediaPlayer
31 | - IjkMediaPlayer
32 | - IjkExoMediaPlayer
33 |
34 |
35 |
36 | Video: ijkplayer
37 |
38 | pref.using_media_codec
39 | Using MediaCodec
40 |
41 |
42 | pref.using_media_codec_auto_rotate
43 | Using MediaCodec auto rotate
44 |
45 |
46 | pref.pixel_format
47 | Pixel Format
48 |
49 | - Auto Select
50 | - RGB 565
51 | - RGB 888X
52 | - YV12
53 |
54 |
55 |
56 | - fcc-rv16
57 | - fcc-rv32
58 | - fcc-yv12
59 |
60 |
61 | - Auto Select
62 | - RGB 565
63 | - RGB 888X
64 | - YV12
65 |
66 |
67 |
68 | Audio: ijkplayer
69 |
70 | pref.using_opensl_es
71 | Using OpenSL ES
72 |
73 |
74 |
75 | RenderView
76 |
77 | pref.enable_no_view
78 | Enable NoView
79 |
80 |
81 | pref.enable_surface_view
82 | Enable SurfaceView
83 |
84 |
85 | pref.enable_texture_view
86 | Enable TextureView
87 |
88 |
89 | pref.enable_detached_surface_texture
90 | Enable detached SurfaceTexture
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/ijkplayer/Settings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
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 com.gxf.liveplay.ijkplayer;
18 |
19 | import android.content.Context;
20 | import android.content.SharedPreferences;
21 | import android.preference.PreferenceManager;
22 |
23 | import com.gxf.liveplay.R;
24 |
25 | public class Settings {
26 | private Context mAppContext;
27 | private SharedPreferences mSharedPreferences;
28 |
29 | public static final int PV_PLAYER__Auto = 0;
30 | public static final int PV_PLAYER__AndroidMediaPlayer = 1;
31 | public static final int PV_PLAYER__IjkMediaPlayer = 2;
32 | public static final int PV_PLAYER__IjkExoMediaPlayer = 3;
33 |
34 | public Settings(Context context) {
35 | mAppContext = context.getApplicationContext();
36 | mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mAppContext);
37 | }
38 |
39 | public boolean getEnableBackgroundPlay() {
40 | String key = mAppContext.getString(R.string.pref_key_enable_background_play);
41 | return mSharedPreferences.getBoolean(key, false);
42 | }
43 |
44 | public int getPlayer() {
45 | String key = mAppContext.getString(R.string.pref_key_player);
46 | String value = mSharedPreferences.getString(key, "2");
47 | try {
48 | return Integer.valueOf(value).intValue();
49 | } catch (NumberFormatException e) {
50 | return 2;
51 | }
52 | }
53 |
54 | public boolean getUsingMediaCodec() {
55 | String key = mAppContext.getString(R.string.pref_key_using_media_codec);
56 | return mSharedPreferences.getBoolean(key, false);
57 | }
58 |
59 | public boolean getUsingMediaCodecAutoRotate() {
60 | String key = mAppContext.getString(R.string.pref_key_using_media_codec_auto_rotate);
61 | return mSharedPreferences.getBoolean(key, false);
62 | }
63 |
64 | public boolean getUsingOpenSLES() {
65 | String key = mAppContext.getString(R.string.pref_key_using_opensl_es);
66 | return mSharedPreferences.getBoolean(key, false);
67 | }
68 |
69 | public String getPixelFormat() {
70 | String key = mAppContext.getString(R.string.pref_key_pixel_format);
71 | return mSharedPreferences.getString(key, "");
72 | }
73 |
74 | public boolean getEnableNoView() {
75 | String key = mAppContext.getString(R.string.pref_key_enable_no_view);
76 | return mSharedPreferences.getBoolean(key, false);
77 | }
78 |
79 | public boolean getEnableSurfaceView() {
80 | String key = mAppContext.getString(R.string.pref_key_enable_surface_view);
81 | return mSharedPreferences.getBoolean(key, false);
82 | }
83 |
84 | public boolean getEnableTextureView() {
85 | String key = mAppContext.getString(R.string.pref_key_enable_texture_view);
86 | return mSharedPreferences.getBoolean(key, false);
87 | }
88 |
89 | public boolean getEnableDetachedSurfaceTextureView() {
90 | String key = mAppContext.getString(R.string.pref_key_enable_detached_surface_texture);
91 | return mSharedPreferences.getBoolean(key, false);
92 | }
93 |
94 | public String getLastDirectory() {
95 | String key = mAppContext.getString(R.string.pref_key_last_directory);
96 | return mSharedPreferences.getString(key, "/");
97 | }
98 |
99 | public void setLastDirectory(String path) {
100 | String key = mAppContext.getString(R.string.pref_key_last_directory);
101 | mSharedPreferences.edit().putString(key, path).commit();
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/ijkplayer/media/InfoHudViewHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 hejunlin
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | package com.gxf.liveplay.ijkplayer.media;
17 |
18 | import android.content.Context;
19 | import android.os.Handler;
20 | import android.os.Message;
21 | import android.view.View;
22 | import android.widget.TableLayout;
23 |
24 | import com.gxf.liveplay.R;
25 |
26 | import java.util.HashMap;
27 | import java.util.Locale;
28 |
29 | import tv.danmaku.ijk.media.player.IMediaPlayer;
30 | import tv.danmaku.ijk.media.player.IjkMediaPlayer;
31 | import tv.danmaku.ijk.media.player.MediaPlayerProxy;
32 |
33 | public class InfoHudViewHolder {
34 | private TableLayoutBinder mTableLayoutBinder;
35 | private HashMap mRowMap = new HashMap();
36 | private IMediaPlayer mMediaPlayer;
37 |
38 | public InfoHudViewHolder(Context context, TableLayout tableLayout) {
39 | mTableLayoutBinder = new TableLayoutBinder(context, tableLayout);
40 |
41 | appendRow(R.string.fps_decode);
42 | appendRow(R.string.fps_output);
43 | }
44 |
45 | private void appendSection(int nameId) {
46 | mTableLayoutBinder.appendSection(nameId);
47 | }
48 |
49 | private void appendRow(int nameId) {
50 | View rowView = mTableLayoutBinder.appendRow2(nameId, null);
51 | mRowMap.put(nameId, rowView);
52 | }
53 |
54 | private void setRowValue(int id, String value) {
55 | View rowView = mRowMap.get(id);
56 | if (rowView == null) {
57 | rowView = mTableLayoutBinder.appendRow2(id, value);
58 | mRowMap.put(id, rowView);
59 | } else {
60 | mTableLayoutBinder.setValueText(rowView, value);
61 | }
62 | }
63 |
64 | public void setMediaPlayer(IMediaPlayer mp) {
65 | mMediaPlayer = mp;
66 | if (mMediaPlayer != null) {
67 | mHandler.sendEmptyMessageDelayed(MSG_UPDATE_HUD, 500);
68 | } else {
69 | mHandler.removeMessages(MSG_UPDATE_HUD);
70 | }
71 | }
72 |
73 | private static final int MSG_UPDATE_HUD = 1;
74 | private Handler mHandler = new Handler() {
75 | @Override
76 | public void handleMessage(Message msg) {
77 | switch (msg.what) {
78 | case MSG_UPDATE_HUD: {
79 | InfoHudViewHolder holder = InfoHudViewHolder.this;
80 | IjkMediaPlayer mp = null;
81 | if (mMediaPlayer == null)
82 | break;
83 | if (mMediaPlayer instanceof IjkMediaPlayer) {
84 | mp = (IjkMediaPlayer) mMediaPlayer;
85 | } else if (mMediaPlayer instanceof MediaPlayerProxy) {
86 | MediaPlayerProxy proxy = (MediaPlayerProxy) mMediaPlayer;
87 | IMediaPlayer internal = proxy.getInternalMediaPlayer();
88 | if (internal != null && internal instanceof IjkMediaPlayer)
89 | mp = (IjkMediaPlayer) internal;
90 | }
91 | if (mp == null)
92 | break;
93 |
94 | float fpsOutput = mp.getVideoOutputFramesPerSecond();
95 | float fpsDecode = mp.getVideoDecodeFramesPerSecond();
96 | setRowValue(R.string.fps_decode, String.format(Locale.US, "%.2f", fpsDecode));
97 | setRowValue(R.string.fps_output, String.format(Locale.US, "%.2f", fpsOutput));
98 |
99 | mHandler.removeMessages(MSG_UPDATE_HUD);
100 | mHandler.sendEmptyMessageDelayed(MSG_UPDATE_HUD, 500);
101 | }
102 | }
103 | }
104 | };
105 | }
106 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/SimpleMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
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 | @Deprecated
20 | public abstract class SimpleMediaPlayer extends BaseMediaPlayer implements
21 | IMediaPlayer {
22 | private OnPreparedListener mOnPreparedListener;
23 | private OnCompletionListener mOnCompletionListener;
24 | private OnBufferingUpdateListener mOnBufferingUpdateListener;
25 | private OnSeekCompleteListener mOnSeekCompleteListener;
26 | private OnVideoSizeChangedListener mOnVideoSizeChangedListener;
27 | private OnErrorListener mOnErrorListener;
28 | private OnInfoListener mOnInfoListener;
29 |
30 | public final void setOnPreparedListener(OnPreparedListener listener) {
31 | mOnPreparedListener = listener;
32 | }
33 |
34 | public final void setOnCompletionListener(OnCompletionListener listener) {
35 | mOnCompletionListener = listener;
36 | }
37 |
38 | public final void setOnBufferingUpdateListener(
39 | OnBufferingUpdateListener listener) {
40 | mOnBufferingUpdateListener = listener;
41 | }
42 |
43 | public final void setOnSeekCompleteListener(OnSeekCompleteListener listener) {
44 | mOnSeekCompleteListener = listener;
45 | }
46 |
47 | public final void setOnVideoSizeChangedListener(
48 | OnVideoSizeChangedListener listener) {
49 | mOnVideoSizeChangedListener = listener;
50 | }
51 |
52 | public final void setOnErrorListener(OnErrorListener listener) {
53 | mOnErrorListener = listener;
54 | }
55 |
56 | public final void setOnInfoListener(OnInfoListener listener) {
57 | mOnInfoListener = listener;
58 | }
59 |
60 | public void resetListeners() {
61 | mOnPreparedListener = null;
62 | mOnBufferingUpdateListener = null;
63 | mOnCompletionListener = null;
64 | mOnSeekCompleteListener = null;
65 | mOnVideoSizeChangedListener = null;
66 | mOnErrorListener = null;
67 | mOnInfoListener = null;
68 | }
69 |
70 | public void attachListeners(IMediaPlayer mp) {
71 | mp.setOnPreparedListener(mOnPreparedListener);
72 | mp.setOnBufferingUpdateListener(mOnBufferingUpdateListener);
73 | mp.setOnCompletionListener(mOnCompletionListener);
74 | mp.setOnSeekCompleteListener(mOnSeekCompleteListener);
75 | mp.setOnVideoSizeChangedListener(mOnVideoSizeChangedListener);
76 | mp.setOnErrorListener(mOnErrorListener);
77 | mp.setOnInfoListener(mOnInfoListener);
78 | }
79 |
80 | protected final void notifyOnPrepared() {
81 | if (mOnPreparedListener != null)
82 | mOnPreparedListener.onPrepared(this);
83 | }
84 |
85 | protected final void notifyOnCompletion() {
86 | if (mOnCompletionListener != null)
87 | mOnCompletionListener.onCompletion(this);
88 | }
89 |
90 | protected final void notifyOnBufferingUpdate(int percent) {
91 | if (mOnBufferingUpdateListener != null)
92 | mOnBufferingUpdateListener.onBufferingUpdate(this, percent);
93 | }
94 |
95 | protected final void notifyOnSeekComplete() {
96 | if (mOnSeekCompleteListener != null)
97 | mOnSeekCompleteListener.onSeekComplete(this);
98 | }
99 |
100 | protected final void notifyOnVideoSizeChanged(int width, int height,
101 | int sarNum, int sarDen) {
102 | if (mOnVideoSizeChangedListener != null)
103 | mOnVideoSizeChangedListener.onVideoSizeChanged(this, width, height,
104 | sarNum, sarDen);
105 | }
106 |
107 | protected final boolean notifyOnError(int what, int extra) {
108 | if (mOnErrorListener != null)
109 | return mOnErrorListener.onError(this, what, extra);
110 | return false;
111 | }
112 |
113 | protected final boolean notifyOnInfo(int what, int extra) {
114 | if (mOnInfoListener != null)
115 | return mOnInfoListener.onInfo(this, what, extra);
116 | return false;
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/ijkplayer/media/TableLayoutBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
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 com.gxf.liveplay.ijkplayer.media;
18 |
19 | import android.content.Context;
20 | import android.support.v7.app.AlertDialog;
21 | import android.view.LayoutInflater;
22 | import android.view.View;
23 | import android.view.ViewGroup;
24 | import android.widget.TableLayout;
25 | import android.widget.TextView;
26 |
27 | import com.gxf.liveplay.R;
28 |
29 | public class TableLayoutBinder {
30 | private Context mContext;
31 | public ViewGroup mTableView;
32 | public TableLayout mTableLayout;
33 |
34 | public TableLayoutBinder(Context context) {
35 | this(context, R.layout.table_media_info);
36 | }
37 |
38 | public TableLayoutBinder(Context context, int layoutResourceId) {
39 | mContext = context;
40 | mTableView = (ViewGroup) LayoutInflater.from(mContext).inflate(layoutResourceId, null);
41 | mTableLayout = (TableLayout) mTableView.findViewById(R.id.table);
42 | }
43 |
44 | public TableLayoutBinder(Context context, TableLayout tableLayout) {
45 | mContext = context;
46 | mTableView = tableLayout;
47 | mTableLayout = tableLayout;
48 | }
49 |
50 | public View appendRow1(String name, String value) {
51 | return appendRow(R.layout.table_media_info_row1, name, value);
52 | }
53 |
54 | public View appendRow1(int nameId, String value) {
55 | return appendRow1(mContext.getString(nameId), value);
56 | }
57 |
58 | public View appendRow2(String name, String value) {
59 | return appendRow(R.layout.table_media_info_row2, name, value);
60 | }
61 |
62 | public View appendRow2(int nameId, String value) {
63 | return appendRow2(mContext.getString(nameId), value);
64 | }
65 |
66 | public View appendSection(String name) {
67 | return appendRow(R.layout.table_media_info_section, name, null);
68 | }
69 |
70 | public View appendSection(int nameId) {
71 | return appendSection(mContext.getString(nameId));
72 | }
73 |
74 | public View appendRow(int layoutId, String name, String value) {
75 | ViewGroup rowView = (ViewGroup) LayoutInflater.from(mContext).inflate(layoutId, mTableLayout, false);
76 | setNameValueText(rowView, name, value);
77 |
78 | mTableLayout.addView(rowView);
79 | return rowView;
80 | }
81 |
82 | public ViewHolder obtainViewHolder(View rowView) {
83 | ViewHolder viewHolder = (ViewHolder) rowView.getTag();
84 | if (viewHolder == null) {
85 | viewHolder = new ViewHolder();
86 | viewHolder.mNameTextView = (TextView) rowView.findViewById(R.id.name);
87 | viewHolder.mValueTextView = (TextView) rowView.findViewById(R.id.value);
88 | rowView.setTag(viewHolder);
89 | }
90 | return viewHolder;
91 | }
92 |
93 | public void setNameValueText(View rowView, String name, String value) {
94 | ViewHolder viewHolder = obtainViewHolder(rowView);
95 | viewHolder.setName(name);
96 | viewHolder.setValue(value);
97 | }
98 |
99 | public void setValueText(View rowView, String value) {
100 | ViewHolder viewHolder = obtainViewHolder(rowView);
101 | viewHolder.setValue(value);
102 | }
103 |
104 | public ViewGroup buildLayout() {
105 | return mTableView;
106 | }
107 |
108 | public AlertDialog.Builder buildAlertDialogBuilder() {
109 | AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(mContext);
110 | dlgBuilder.setView(buildLayout());
111 | return dlgBuilder;
112 | }
113 |
114 | private static class ViewHolder {
115 | public TextView mNameTextView;
116 | public TextView mValueTextView;
117 |
118 | public void setName(String name) {
119 | if (mNameTextView != null) {
120 | mNameTextView.setText(name);
121 | }
122 | }
123 |
124 | public void setValue(String value) {
125 | if (mValueTextView != null) {
126 | mValueTextView.setText(value);
127 | }
128 | }
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/pragma/DebugLog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.pragma;
18 |
19 | import java.util.Locale;
20 |
21 |
22 | import android.util.Log;
23 |
24 | public class DebugLog {
25 | public static final boolean ENABLE_ERROR = Pragma.ENABLE_VERBOSE;
26 | public static final boolean ENABLE_INFO = Pragma.ENABLE_VERBOSE;
27 | public static final boolean ENABLE_WARN = Pragma.ENABLE_VERBOSE;
28 | public static final boolean ENABLE_DEBUG = Pragma.ENABLE_VERBOSE;
29 | public static final boolean ENABLE_VERBOSE = Pragma.ENABLE_VERBOSE;
30 |
31 | public static int e(String tag, String msg) {
32 | if (ENABLE_ERROR) {
33 | return Log.e(tag, msg);
34 | }
35 |
36 | return 0;
37 | }
38 |
39 | public static int e(String tag, String msg, Throwable tr) {
40 | if (ENABLE_ERROR) {
41 | return Log.e(tag, msg, tr);
42 | }
43 |
44 | return 0;
45 | }
46 |
47 | public static int efmt(String tag, String fmt, Object... args) {
48 | if (ENABLE_ERROR) {
49 | String msg = String.format(Locale.US, fmt, args);
50 | return Log.e(tag, msg);
51 | }
52 |
53 | return 0;
54 | }
55 |
56 | public static int i(String tag, String msg) {
57 | if (ENABLE_INFO) {
58 | return Log.i(tag, msg);
59 | }
60 |
61 | return 0;
62 | }
63 |
64 | public static int i(String tag, String msg, Throwable tr) {
65 | if (ENABLE_INFO) {
66 | return Log.i(tag, msg, tr);
67 | }
68 |
69 | return 0;
70 | }
71 |
72 | public static int ifmt(String tag, String fmt, Object... args) {
73 | if (ENABLE_INFO) {
74 | String msg = String.format(Locale.US, fmt, args);
75 | return Log.i(tag, msg);
76 | }
77 |
78 | return 0;
79 | }
80 |
81 | public static int w(String tag, String msg) {
82 | if (ENABLE_WARN) {
83 | return Log.w(tag, msg);
84 | }
85 |
86 | return 0;
87 | }
88 |
89 | public static int w(String tag, String msg, Throwable tr) {
90 | if (ENABLE_WARN) {
91 | return Log.w(tag, msg, tr);
92 | }
93 |
94 | return 0;
95 | }
96 |
97 | public static int wfmt(String tag, String fmt, Object... args) {
98 | if (ENABLE_WARN) {
99 | String msg = String.format(Locale.US, fmt, args);
100 | return Log.w(tag, msg);
101 | }
102 |
103 | return 0;
104 | }
105 |
106 | public static int d(String tag, String msg) {
107 | if (ENABLE_DEBUG) {
108 | return Log.d(tag, msg);
109 | }
110 |
111 | return 0;
112 | }
113 |
114 | public static int d(String tag, String msg, Throwable tr) {
115 | if (ENABLE_DEBUG) {
116 | return Log.d(tag, msg, tr);
117 | }
118 |
119 | return 0;
120 | }
121 |
122 | public static int dfmt(String tag, String fmt, Object... args) {
123 | if (ENABLE_DEBUG) {
124 | String msg = String.format(Locale.US, fmt, args);
125 | return Log.d(tag, msg);
126 | }
127 |
128 | return 0;
129 | }
130 |
131 | public static int v(String tag, String msg) {
132 | if (ENABLE_VERBOSE) {
133 | return Log.v(tag, msg);
134 | }
135 |
136 | return 0;
137 | }
138 |
139 | public static int v(String tag, String msg, Throwable tr) {
140 | if (ENABLE_VERBOSE) {
141 | return Log.v(tag, msg, tr);
142 | }
143 |
144 | return 0;
145 | }
146 |
147 | public static int vfmt(String tag, String fmt, Object... args) {
148 | if (ENABLE_VERBOSE) {
149 | String msg = String.format(Locale.US, fmt, args);
150 | return Log.v(tag, msg);
151 | }
152 |
153 | return 0;
154 | }
155 |
156 | public static void printStackTrace(Throwable e) {
157 | if (ENABLE_WARN) {
158 | e.printStackTrace();
159 | }
160 | }
161 |
162 | public static void printCause(Throwable e) {
163 | if (ENABLE_WARN) {
164 | Throwable cause = e.getCause();
165 | if (cause != null)
166 | e = cause;
167 |
168 | printStackTrace(e);
169 | }
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/IMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.annotation.TargetApi;
20 | import android.content.Context;
21 | import android.net.Uri;
22 | import android.os.Build;
23 | import android.view.Surface;
24 | import android.view.SurfaceHolder;
25 |
26 | import java.io.FileDescriptor;
27 | import java.io.IOException;
28 | import java.util.Map;
29 |
30 | import tv.danmaku.ijk.media.player.misc.ITrackInfo;
31 |
32 | public interface IMediaPlayer {
33 | /*
34 | * Do not change these values without updating their counterparts in native
35 | */
36 | int MEDIA_INFO_UNKNOWN = 1;
37 | int MEDIA_INFO_STARTED_AS_NEXT = 2;
38 | int MEDIA_INFO_VIDEO_RENDERING_START = 3;
39 | int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700;
40 | int MEDIA_INFO_BUFFERING_START = 701;
41 | int MEDIA_INFO_BUFFERING_END = 702;
42 | int MEDIA_INFO_NETWORK_BANDWIDTH = 703;
43 | int MEDIA_INFO_BAD_INTERLEAVING = 800;
44 | int MEDIA_INFO_NOT_SEEKABLE = 801;
45 | int MEDIA_INFO_METADATA_UPDATE = 802;
46 | int MEDIA_INFO_TIMED_TEXT_ERROR = 900;
47 | int MEDIA_INFO_UNSUPPORTED_SUBTITLE = 901;
48 | int MEDIA_INFO_SUBTITLE_TIMED_OUT = 902;
49 |
50 | int MEDIA_INFO_VIDEO_ROTATION_CHANGED = 10001;
51 | int MEDIA_INFO_AUDIO_RENDERING_START = 10002;
52 |
53 | int MEDIA_ERROR_UNKNOWN = 1;
54 | int MEDIA_ERROR_SERVER_DIED = 100;
55 | int MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200;
56 | int MEDIA_ERROR_IO = -1004;
57 | int MEDIA_ERROR_MALFORMED = -1007;
58 | int MEDIA_ERROR_UNSUPPORTED = -1010;
59 | int MEDIA_ERROR_TIMED_OUT = -110;
60 |
61 | void setDisplay(SurfaceHolder sh);
62 |
63 | void setDataSource(Context context, Uri uri)
64 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
65 |
66 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
67 | void setDataSource(Context context, Uri uri, Map headers)
68 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
69 |
70 | void setDataSource(FileDescriptor fd)
71 | throws IOException, IllegalArgumentException, IllegalStateException;
72 |
73 | void setDataSource(String path)
74 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
75 |
76 | String getDataSource();
77 |
78 | void prepareAsync() throws IllegalStateException;
79 |
80 | void start() throws IllegalStateException;
81 |
82 | void stop() throws IllegalStateException;
83 |
84 | void pause() throws IllegalStateException;
85 |
86 | void setScreenOnWhilePlaying(boolean screenOn);
87 |
88 | int getVideoWidth();
89 |
90 | int getVideoHeight();
91 |
92 | boolean isPlaying();
93 |
94 | void seekTo(long msec) throws IllegalStateException;
95 |
96 | long getCurrentPosition();
97 |
98 | long getDuration();
99 |
100 | void release();
101 |
102 | void reset();
103 |
104 | void setVolume(float leftVolume, float rightVolume);
105 |
106 | int getAudioSessionId();
107 |
108 | MediaInfo getMediaInfo();
109 |
110 | @Deprecated
111 | void setLogEnabled(boolean enable);
112 |
113 | @Deprecated
114 | boolean isPlayable();
115 |
116 | void setOnPreparedListener(OnPreparedListener listener);
117 |
118 | void setOnCompletionListener(OnCompletionListener listener);
119 |
120 | void setOnBufferingUpdateListener(
121 | OnBufferingUpdateListener listener);
122 |
123 | void setOnSeekCompleteListener(
124 | OnSeekCompleteListener listener);
125 |
126 | void setOnVideoSizeChangedListener(
127 | OnVideoSizeChangedListener listener);
128 |
129 | void setOnErrorListener(OnErrorListener listener);
130 |
131 | void setOnInfoListener(OnInfoListener listener);
132 |
133 | /*--------------------
134 | * Listeners
135 | */
136 | interface OnPreparedListener {
137 | void onPrepared(IMediaPlayer mp);
138 | }
139 |
140 | interface OnCompletionListener {
141 | void onCompletion(IMediaPlayer mp);
142 | }
143 |
144 | interface OnBufferingUpdateListener {
145 | void onBufferingUpdate(IMediaPlayer mp, int percent);
146 | }
147 |
148 | interface OnSeekCompleteListener {
149 | void onSeekComplete(IMediaPlayer mp);
150 | }
151 |
152 | interface OnVideoSizeChangedListener {
153 | void onVideoSizeChanged(IMediaPlayer mp, int width, int height,
154 | int sar_num, int sar_den);
155 | }
156 |
157 | interface OnErrorListener {
158 | boolean onError(IMediaPlayer mp, int what, int extra);
159 | }
160 |
161 | interface OnInfoListener {
162 | boolean onInfo(IMediaPlayer mp, int what, int extra);
163 | }
164 |
165 | /*--------------------
166 | * Optional
167 | */
168 | void setAudioStreamType(int streamtype);
169 |
170 | @Deprecated
171 | void setKeepInBackground(boolean keepInBackground);
172 |
173 | int getVideoSarNum();
174 |
175 | int getVideoSarDen();
176 |
177 | @Deprecated
178 | void setWakeMode(Context context, int mode);
179 |
180 | void setLooping(boolean looping);
181 |
182 | boolean isLooping();
183 |
184 | /*--------------------
185 | * AndroidMediaPlayer: ICE_CREAM_SANDWICH:
186 | */
187 | void setSurface(Surface surface);
188 |
189 | /*--------------------
190 | * AndroidMediaPlayer: JELLY_BEAN
191 | */
192 | ITrackInfo[] getTrackInfo();
193 | }
194 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/DeviceUtils.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay;
2 |
3 | import android.content.Context;
4 | import android.net.wifi.WifiInfo;
5 | import android.net.wifi.WifiManager;
6 | import android.util.Log;
7 |
8 | import java.io.BufferedReader;
9 | import java.io.File;
10 | import java.io.FileInputStream;
11 | import java.io.IOException;
12 | import java.io.InputStream;
13 | import java.io.InputStreamReader;
14 | import java.io.Reader;
15 | import java.io.StringWriter;
16 | import java.io.Writer;
17 | import java.net.Inet4Address;
18 | import java.net.InetAddress;
19 | import java.net.NetworkInterface;
20 | import java.net.SocketException;
21 | import java.util.Collections;
22 | import java.util.Enumeration;
23 | import java.util.List;
24 |
25 | /**
26 | * Created by gongxufan on 2017/9/7.
27 | */
28 |
29 | public class DeviceUtils {
30 | private static final String marshmallowMacAddress = "02:00:00:00:00:00";
31 | private static final String fileAddressMac = "/sys/class/net/wlan0/address";
32 |
33 |
34 | private static String parseByte(byte b) {
35 | String s = "00" + Integer.toHexString(b) + ":";
36 | return s.substring(s.length() - 3);
37 | }
38 |
39 | /**
40 | * 获取当前系统连接网络的网卡的mac地址
41 | *
42 | * @return
43 | */
44 | public static final String getMac() {
45 | byte[] mac = null;
46 | StringBuffer sb = new StringBuffer();
47 | try {
48 | Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces();
49 | while (netInterfaces.hasMoreElements()) {
50 | NetworkInterface ni = netInterfaces.nextElement();
51 | Enumeration address = ni.getInetAddresses();
52 |
53 | while (address.hasMoreElements()) {
54 | InetAddress ip = address.nextElement();
55 | if (ip.isAnyLocalAddress() || !(ip instanceof Inet4Address) || ip.isLoopbackAddress())
56 | continue;
57 | if (ip.isSiteLocalAddress())
58 | mac = ni.getHardwareAddress();
59 | else if (!ip.isLinkLocalAddress()) {
60 | mac = ni.getHardwareAddress();
61 | break;
62 | }
63 | }
64 | }
65 | } catch (SocketException e) {
66 | e.printStackTrace();
67 | }
68 |
69 | if (mac != null) {
70 | for (int i = 0; i < mac.length; i++) {
71 | sb.append(parseByte(mac[i]));
72 | }
73 | }else{
74 | return "";
75 | }
76 | return sb.substring(0, sb.length() - 1);
77 | }
78 |
79 | public static String getAdresseMAC(Context context) {
80 | WifiManager wifiMan = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
81 | WifiInfo wifiInf = wifiMan.getConnectionInfo();
82 |
83 | if (wifiInf != null && marshmallowMacAddress.equals(wifiInf.getMacAddress())) {
84 | String result = null;
85 | try {
86 | result = getAdressMacByInterface();
87 | if (result != null) {
88 | return result;
89 | } else {
90 | result = getAddressMacByFile(wifiMan);
91 | return result;
92 | }
93 | } catch (IOException e) {
94 | Log.e("MobileAccess", "Erreur lecture propriete Adresse MAC");
95 | } catch (Exception e) {
96 | Log.e("MobileAcces", "Erreur lecture propriete Adresse MAC ");
97 | }
98 | } else {
99 | if (wifiInf != null && wifiInf.getMacAddress() != null) {
100 | return wifiInf.getMacAddress();
101 | } else {
102 | return "";
103 | }
104 | }
105 | return marshmallowMacAddress;
106 | }
107 |
108 | private static String getAdressMacByInterface() {
109 | try {
110 | List all = Collections.list(NetworkInterface.getNetworkInterfaces());
111 | for (NetworkInterface nif : all) {
112 | if (nif.getName().equalsIgnoreCase("wlan0")) {
113 | byte[] macBytes = nif.getHardwareAddress();
114 | if (macBytes == null) {
115 | return "";
116 | }
117 |
118 | StringBuilder res1 = new StringBuilder();
119 | for (byte b : macBytes) {
120 | res1.append(String.format("%02X:", b));
121 | }
122 |
123 | if (res1.length() > 0) {
124 | res1.deleteCharAt(res1.length() - 1);
125 | }
126 | return res1.toString();
127 | }
128 | }
129 |
130 | } catch (Exception e) {
131 | Log.e("MobileAcces", "Erreur lecture propriete Adresse MAC ");
132 | }
133 | return null;
134 | }
135 |
136 | private static String getAddressMacByFile(WifiManager wifiMan) throws Exception {
137 | String ret;
138 | int wifiState = wifiMan.getWifiState();
139 |
140 | wifiMan.setWifiEnabled(true);
141 | File fl = new File(fileAddressMac);
142 | FileInputStream fin = new FileInputStream(fl);
143 | ret = crunchifyGetStringFromStream(fin);
144 | fin.close();
145 |
146 | boolean enabled = WifiManager.WIFI_STATE_ENABLED == wifiState;
147 | wifiMan.setWifiEnabled(enabled);
148 | return ret;
149 | }
150 |
151 | private static String crunchifyGetStringFromStream(InputStream crunchifyStream) throws IOException {
152 | if (crunchifyStream != null) {
153 | Writer crunchifyWriter = new StringWriter();
154 |
155 | char[] crunchifyBuffer = new char[2048];
156 | try {
157 | Reader crunchifyReader = new BufferedReader(new InputStreamReader(crunchifyStream, "UTF-8"));
158 | int counter;
159 | while ((counter = crunchifyReader.read(crunchifyBuffer)) != -1) {
160 | crunchifyWriter.write(crunchifyBuffer, 0, counter);
161 | }
162 | } finally {
163 | crunchifyStream.close();
164 | }
165 | return crunchifyWriter.toString();
166 | } else {
167 | return "No Contents";
168 | }
169 | }
170 |
171 |
172 | }
173 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/update/UpdateAppUtils.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay.update;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.pm.PackageInfo;
6 | import android.content.pm.PackageManager;
7 | import android.net.ConnectivityManager;
8 | import android.net.NetworkInfo;
9 | import android.text.TextUtils;
10 | import android.util.Log;
11 |
12 | public class UpdateAppUtils {
13 |
14 | private final String TAG = "UpdateAppUtils";
15 | public static final int CHECK_BY_VERSION_NAME = 1001;
16 | public static final int CHECK_BY_VERSION_CODE = 1002;
17 | public static final int DOWNLOAD_BY_APP = 1003;
18 | public static final int DOWNLOAD_BY_BROWSER = 1004;
19 |
20 | private Activity activity;
21 | private int checkBy = CHECK_BY_VERSION_CODE;
22 | private int downloadBy = DOWNLOAD_BY_APP;
23 | private int serverVersionCode = 0;
24 | private String apkPath = "";
25 | private String serverVersionName = "";
26 | private boolean isForce = false; //是否强制更新
27 | private int localVersionCode = 0;
28 | private String localVersionName = "";
29 | public static boolean showNotification = true;
30 | private String updateInfo = "";
31 |
32 |
33 | private UpdateAppUtils(Activity activity) {
34 | this.activity = activity;
35 | getAPPLocalVersion(activity);
36 | }
37 |
38 | public static UpdateAppUtils from(Activity activity) {
39 | return new UpdateAppUtils(activity);
40 | }
41 |
42 | public UpdateAppUtils checkBy(int checkBy) {
43 | this.checkBy = checkBy;
44 | return this;
45 | }
46 |
47 | public UpdateAppUtils apkPath(String apkPath) {
48 | this.apkPath = apkPath;
49 | return this;
50 | }
51 |
52 | public UpdateAppUtils downloadBy(int downloadBy) {
53 | this.downloadBy = downloadBy;
54 | return this;
55 | }
56 |
57 | public UpdateAppUtils showNotification(boolean showNotification) {
58 | this.showNotification = showNotification;
59 | return this;
60 | }
61 |
62 | public UpdateAppUtils updateInfo(String updateInfo) {
63 | this.updateInfo = updateInfo;
64 | return this;
65 | }
66 |
67 |
68 | public UpdateAppUtils serverVersionCode(int serverVersionCode) {
69 | this.serverVersionCode = serverVersionCode;
70 | return this;
71 | }
72 |
73 | public UpdateAppUtils serverVersionName(String serverVersionName) {
74 | this.serverVersionName = serverVersionName;
75 | return this;
76 | }
77 |
78 | public UpdateAppUtils isForce(boolean isForce) {
79 | this.isForce = isForce;
80 | return this;
81 | }
82 |
83 | //获取apk的版本号 currentVersionCode
84 | private void getAPPLocalVersion(Context ctx) {
85 | PackageManager manager = ctx.getPackageManager();
86 | try {
87 | PackageInfo info = manager.getPackageInfo(ctx.getPackageName(), 0);
88 | localVersionName = info.versionName; // 版本名
89 | localVersionCode = info.versionCode; // 版本号
90 | } catch (PackageManager.NameNotFoundException e) {
91 | e.printStackTrace();
92 | }
93 | }
94 |
95 | public void update() {
96 |
97 | switch (checkBy) {
98 | case CHECK_BY_VERSION_CODE:
99 | if (serverVersionCode > localVersionCode) {
100 | toUpdate();
101 | } else {
102 | Log.i(TAG, "当前版本是最新版本" + serverVersionCode + "/" + serverVersionName);
103 | }
104 | break;
105 |
106 | case CHECK_BY_VERSION_NAME:
107 | if (serverVersionName.compareTo(localVersionName) > 0) {
108 | toUpdate();
109 | } else {
110 | Log.i(TAG, "当前版本是最新版本" + serverVersionCode + "/" + serverVersionName);
111 | }
112 | break;
113 | }
114 |
115 | }
116 |
117 | private void toUpdate() {
118 |
119 | realUpdate();
120 |
121 | //尝试在内部适配6.0
122 | // if (ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)
123 | // == PackageManager.PERMISSION_GRANTED){
124 | // realUpdate();
125 | // }else {//申请权限
126 | // ActivityCompat.requestPermissions(activity,
127 | // new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},1);
128 | // }
129 |
130 | }
131 |
132 | private void realUpdate() {
133 | ConfirmDialog dialog = new ConfirmDialog(activity, new CallBack() {
134 | @Override
135 | public void callback(int position) {
136 | switch (position) {
137 | case 0: //cancle
138 | if (isForce) activity.finish();
139 | break;
140 |
141 | case 1: //sure
142 | if (downloadBy == DOWNLOAD_BY_APP) {
143 | if (isWifiConnected(activity)) {
144 | DownloadAppUtils.downloadForAutoInstall(activity, apkPath, "demo.apk", serverVersionName);
145 | } else {
146 | new ConfirmDialog(activity, new CallBack() {
147 | @Override
148 | public void callback(int position) {
149 | if (position == 1) {
150 | DownloadAppUtils.downloadForAutoInstall(activity, apkPath, "demo.apk", serverVersionName);
151 | } else {
152 | if (isForce) activity.finish();
153 | }
154 | }
155 | }).setContent("目前您的设备不是WiFi状态\n确认是否继续下载更新?").show();
156 | }
157 |
158 | } else if (downloadBy == DOWNLOAD_BY_BROWSER) {
159 | DownloadAppUtils.downloadForWebView(activity, apkPath);
160 | }
161 | break;
162 | }
163 | }
164 | });
165 |
166 | String content = "发现新版本:" + serverVersionName + "\n是否下载更新?";
167 | if (!TextUtils.isEmpty(updateInfo)) {
168 | content = "发现新版本:" + serverVersionName + "是否下载更新?\n\n" + updateInfo;
169 | }
170 | dialog.setContent(content);
171 | dialog.setCancelable(false);
172 | dialog.show();
173 | }
174 |
175 |
176 | //尝试在内部适配6.0 可能会引起内存泄露
177 | // public static void onRequestPermissionsResult(int requestCode,
178 | // @NonNull String[] permissions,
179 | // @NonNull int[] grantResults){
180 | // switch (requestCode){
181 | // case 1:
182 | // if (grantResults[0] == PackageManager.PERMISSION_GRANTED){
183 | //// realUpdate();
184 | // mHandler.sendEmptyMessage(1);
185 | // }else {
186 | // //提示用户没有授予权限
187 | // }
188 | // break;
189 | // }
190 | // }
191 |
192 |
193 | /**
194 | * 检测wifi是否连接
195 | */
196 | public static boolean isWifiConnected(Context context) {
197 | ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
198 | if (cm != null) {
199 | NetworkInfo networkInfo = cm.getActiveNetworkInfo();
200 | if (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
201 | return true;
202 | }
203 | }
204 | return false;
205 | }
206 |
207 | }
208 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.gxf.liveplay;
2 |
3 | import android.content.Context;
4 | import android.content.DialogInterface;
5 | import android.content.Intent;
6 | import android.content.SharedPreferences;
7 | import android.os.AsyncTask;
8 | import android.os.Bundle;
9 | import android.support.v7.app.AlertDialog;
10 | import android.support.v7.app.AppCompatActivity;
11 | import android.view.View;
12 | import android.view.View.OnClickListener;
13 | import android.view.Window;
14 | import android.widget.Button;
15 | import android.widget.EditText;
16 | import android.widget.ImageButton;
17 | import android.widget.TextView;
18 | import android.widget.Toast;
19 |
20 | /**
21 | * A login screen that offers login via email/password.
22 | */
23 | public class LoginActivity extends AppCompatActivity {
24 |
25 | private static UserLoginTask mAuthTask = null;
26 | public static int state;
27 | private EditText userName;
28 | private EditText password;
29 | private Button loginBtn;
30 | private TextView promptText;
31 | private ImageButton settings;
32 | private int choice;
33 | @Override
34 | protected void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | getSupportActionBar().hide();
37 |
38 | setContentView(R.layout.activity_login);
39 | settings = (ImageButton) findViewById(R.id.settings);
40 | settings.setOnClickListener(new OnClickListener() {
41 | @Override
42 | public void onClick(View v) {
43 | Intent intent = new Intent(LoginActivity.this, ServiceSettings.class);
44 | LoginActivity.this.startActivity(intent);
45 | /* SharedPreferences userSettings = getSharedPreferences("auth", Context.MODE_PRIVATE);
46 | final SharedPreferences.Editor editor = userSettings.edit();
47 | //默认为公网服务器
48 | choice = userSettings.getInt("serviceType",0);
49 |
50 | AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
51 | builder.setIcon(R.drawable.ic_launcher);
52 | builder.setTitle("请选择服务器类型");
53 | final String[] serviceType = {"公网服务器", "内网服务器"};
54 | // 设置一个单项选择下拉框
55 | *//**
56 | * 第一个参数指定我们要显示的一组下拉单选框的数据集合
57 | * 第二个参数代表索引,指定默认哪一个单选框被勾选上,1表示默认'女' 会被勾选上
58 | * 第三个参数给每一个单选项绑定一个监听器
59 | *//*
60 | builder.setSingleChoiceItems(serviceType, choice, new DialogInterface.OnClickListener() {
61 | @Override
62 | public void onClick(DialogInterface dialog, int which) {
63 | choice = which;
64 | }
65 | });
66 | builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
67 | @Override
68 | public void onClick(DialogInterface dialog, int which) {
69 | editor.putInt("serviceType", choice);
70 | editor.commit();
71 | if(choice == 0)
72 | HttpUtils.apiPath = HttpUtils.apiPathOuter;
73 | if(choice == 1)
74 | HttpUtils.apiPath = HttpUtils.apiPathLocal;
75 | }
76 | });
77 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
78 | @Override
79 | public void onClick(DialogInterface dialog, int which) {
80 | dialog.dismiss();
81 | }
82 | });
83 | builder.show();*/
84 | }
85 | });
86 | userName = (EditText) findViewById(R.id.userName);
87 | password = (EditText) findViewById(R.id.password);
88 | loginBtn = (Button) findViewById(R.id.loginBtn);
89 | promptText = (TextView) findViewById(R.id.promptText);
90 | loginBtn.setOnClickListener(new OnClickListener() {
91 | @Override
92 | public void onClick(View view) {
93 | attemptLogin();
94 | }
95 | });
96 | }
97 |
98 | private void attemptLogin() {
99 | String name = userName.getText().toString();
100 | if (name == null || name.trim().length() == 0) {
101 | promptText.setText("用户名不能为空...");
102 | return;
103 | }
104 | String pwd = password.getText().toString();
105 |
106 | if (pwd == null || pwd.trim().length() == 0) {
107 | promptText.setText("密码不能为空...");
108 | return;
109 | }
110 | mAuthTask = new UserLoginTask(name, pwd);
111 | mAuthTask.execute((Void) null);
112 | }
113 |
114 |
115 | public class UserLoginTask extends AsyncTask {
116 |
117 | private final String mEmail;
118 | private final String mPassword;
119 |
120 | UserLoginTask(String email, String password) {
121 | mEmail = email;
122 | mPassword = password;
123 | }
124 |
125 | @Override
126 | protected Boolean doInBackground(Void... params) {
127 | try {
128 | return HttpUtils.login(mEmail, mPassword, LoginActivity.this);
129 | } catch (Exception e) {
130 | Toast.makeText(LoginActivity.this, "登录失败...", Toast.LENGTH_SHORT).show();
131 | return false;
132 | }
133 | }
134 |
135 | @Override
136 | protected void onPostExecute(final Boolean success) {
137 | mAuthTask = null;
138 | if (success) {
139 | //登录成功
140 | if (state == -1) {
141 | //保存登录状态
142 | SharedPreferences userSettings = getSharedPreferences("auth", Context.MODE_PRIVATE);
143 | SharedPreferences.Editor editor = userSettings.edit();
144 | editor.putString("userName", mEmail);
145 | editor.putString("password", mPassword);
146 | editor.commit();
147 | final String lastVedioUrl = userSettings.getString("lastVedioUrl", "none");
148 | //初始化节目列表
149 | new Thread(new Runnable() {
150 | @Override
151 | public void run() {
152 | try {
153 | PlayListCache.initPlayInfo(mEmail,mPassword);
154 | //启动播放器,传递播放地址
155 | String url = lastVedioUrl;
156 | if (url.equals("none"))
157 | url = PlayListCache.playListMap.get(PlayListCache.playListMap.keySet().iterator().next());
158 | LiveActivityRel.activityStart(LoginActivity.this, url);
159 | finish();
160 | } catch (Exception e) {
161 | promptText.setText("5:获取节目列表失败...");
162 | e.printStackTrace();
163 | }
164 | }
165 | }).start();
166 |
167 | } else if (state == 0) {
168 | promptText.setText("0:网络不通,请检查网络连接情况...");
169 | } else if (state == 1) {
170 | promptText.setText("1:帐号不存在...");
171 | } else if (state == 2) {
172 | promptText.setText("2:密码错误...");
173 | } else if (state == 3) {
174 | promptText.setText("3:帐号失效...");
175 | } else if (state == 5) {
176 | promptText.setText("5:获取设备uuid失败...");
177 | } else if (state == 6) {
178 | promptText.setText("6:该帐号已被其他设备绑定无法登录,如需解除请联系管理员...");
179 | } else if (state == 7) {
180 | promptText.setText("7:获取设备信息失败...");
181 | } else if (state == 8) {
182 | promptText.setText("8:该帐号已被其他设备绑定无法登录...");
183 | } else {
184 | promptText.setText("4:登录服务出现异常,请稍后重试...");
185 | }
186 | } else {
187 | promptText.setText("4:登录服务出现异常,请稍后重试...");
188 | }
189 | }
190 |
191 | @Override
192 | protected void onCancelled() {
193 | mAuthTask = null;
194 | }
195 | }
196 | }
197 |
198 |
--------------------------------------------------------------------------------
/Ijkplayer/src/main/java/tv/danmaku/ijk/media/player/misc/IjkMediaFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import android.annotation.TargetApi;
20 | import android.os.Build;
21 | import android.text.TextUtils;
22 |
23 | import java.util.HashMap;
24 | import java.util.Locale;
25 | import java.util.Map;
26 |
27 | import tv.danmaku.ijk.media.player.IjkMediaMeta;
28 |
29 | public class IjkMediaFormat implements IMediaFormat {
30 | // Common
31 | public static final String KEY_IJK_CODEC_LONG_NAME_UI = "ijk-codec-long-name-ui";
32 | public static final String KEY_IJK_BIT_RATE_UI = "ijk-bit-rate-ui";
33 |
34 | // Video
35 | public static final String KEY_IJK_CODEC_PROFILE_LEVEL_UI = "ijk-profile-level-ui";
36 | public static final String KEY_IJK_CODEC_PIXEL_FORMAT_UI = "ijk-pixel-format-ui";
37 | public static final String KEY_IJK_RESOLUTION_UI = "ijk-resolution-ui";
38 | public static final String KEY_IJK_FRAME_RATE_UI = "ijk-frame-rate-ui";
39 |
40 | // Audio
41 | public static final String KEY_IJK_SAMPLE_RATE_UI = "ijk-sample-rate-ui";
42 | public static final String KEY_IJK_CHANNEL_UI = "ijk-channel-ui";
43 |
44 | // Codec
45 | public static final String CODEC_NAME_H264 = "h264";
46 |
47 | public IjkMediaMeta.IjkStreamMeta mMediaFormat;
48 |
49 | public IjkMediaFormat(IjkMediaMeta.IjkStreamMeta streamMeta) {
50 | mMediaFormat = streamMeta;
51 | }
52 |
53 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
54 | @Override
55 | public int getInteger(String name) {
56 | if (mMediaFormat == null)
57 | return 0;
58 |
59 | return mMediaFormat.getInt(name);
60 | }
61 |
62 | @Override
63 | public String getString(String name) {
64 | if (mMediaFormat == null)
65 | return null;
66 |
67 | if (sFormatterMap.containsKey(name)) {
68 | Formatter formatter = sFormatterMap.get(name);
69 | return formatter.format(this);
70 | }
71 |
72 | return mMediaFormat.getString(name);
73 | }
74 |
75 | //-------------------------
76 | // Formatter
77 | //-------------------------
78 |
79 | private static abstract class Formatter {
80 | public String format(IjkMediaFormat mediaFormat) {
81 | String value = doFormat(mediaFormat);
82 | if (TextUtils.isEmpty(value))
83 | return getDefaultString();
84 | return value;
85 | }
86 |
87 | protected abstract String doFormat(IjkMediaFormat mediaFormat);
88 |
89 | protected String getDefaultString() {
90 | return "N/A";
91 | }
92 | }
93 |
94 | private static Map sFormatterMap = new HashMap();
95 |
96 | {
97 | sFormatterMap.put(KEY_IJK_CODEC_LONG_NAME_UI, new Formatter() {
98 | @Override
99 | public String doFormat(IjkMediaFormat mediaFormat) {
100 | return mMediaFormat.getString(IjkMediaMeta.IJKM_KEY_CODEC_LONG_NAME);
101 | }
102 | });
103 | sFormatterMap.put(KEY_IJK_BIT_RATE_UI, new Formatter() {
104 | @Override
105 | protected String doFormat(IjkMediaFormat mediaFormat) {
106 | int bitRate = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_BITRATE);
107 | if (bitRate <= 0) {
108 | return null;
109 | } else if (bitRate < 1000) {
110 | return String.format(Locale.US, "%d bit/s", bitRate);
111 | } else {
112 | return String.format(Locale.US, "%d kb/s", bitRate / 1000);
113 | }
114 | }
115 | });
116 | sFormatterMap.put(KEY_IJK_CODEC_PROFILE_LEVEL_UI, new Formatter() {
117 | @Override
118 | protected String doFormat(IjkMediaFormat mediaFormat) {
119 | String profile = mediaFormat.getString(IjkMediaMeta.IJKM_KEY_CODEC_PROFILE);
120 | if (TextUtils.isEmpty(profile))
121 | return null;
122 |
123 | StringBuilder sb = new StringBuilder();
124 | sb.append(profile);
125 |
126 | String codecName = mediaFormat.getString(IjkMediaMeta.IJKM_KEY_CODEC_NAME);
127 | if (TextUtils.isEmpty(codecName)) {
128 | } else if (codecName.equalsIgnoreCase(CODEC_NAME_H264)) {
129 | int level = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_CODEC_LEVEL);
130 | if (level < 10)
131 | return sb.toString();
132 |
133 | sb.append(" Profile Level ");
134 | sb.append((level / 10) % 10);
135 | if ((level % 10) != 0) {
136 | sb.append(".");
137 | sb.append(level % 10);
138 | }
139 | }
140 |
141 | return sb.toString();
142 | }
143 | });
144 | sFormatterMap.put(KEY_IJK_CODEC_PIXEL_FORMAT_UI, new Formatter() {
145 | @Override
146 | protected String doFormat(IjkMediaFormat mediaFormat) {
147 | return mediaFormat.getString(IjkMediaMeta.IJKM_KEY_CODEC_PIXEL_FORMAT);
148 | }
149 | });
150 | sFormatterMap.put(KEY_IJK_RESOLUTION_UI, new Formatter() {
151 | @Override
152 | protected String doFormat(IjkMediaFormat mediaFormat) {
153 | int width = mediaFormat.getInteger(KEY_WIDTH);
154 | int height = mediaFormat.getInteger(KEY_HEIGHT);
155 | int sarNum = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_SAR_NUM);
156 | int sarDen = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_SAR_DEN);
157 |
158 | if (width <= 0 || height <= 0) {
159 | return null;
160 | } else if (sarNum <= 0 || sarDen <= 0) {
161 | return String.format(Locale.US, "%d x %d", width, height);
162 | } else {
163 | return String.format(Locale.US, "%d x %d [SAR %d:%d]", width,
164 | height, sarNum, sarDen);
165 | }
166 | }
167 | });
168 | sFormatterMap.put(KEY_IJK_FRAME_RATE_UI, new Formatter() {
169 | @Override
170 | protected String doFormat(IjkMediaFormat mediaFormat) {
171 | int fpsNum = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_FPS_NUM);
172 | int fpsDen = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_FPS_DEN);
173 | if (fpsNum <= 0 || fpsDen <= 0) {
174 | return null;
175 | } else {
176 | return String.valueOf(((float) (fpsNum)) / fpsDen);
177 | }
178 | }
179 | });
180 | sFormatterMap.put(KEY_IJK_SAMPLE_RATE_UI, new Formatter() {
181 | @Override
182 | protected String doFormat(IjkMediaFormat mediaFormat) {
183 | int sampleRate = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_SAMPLE_RATE);
184 | if (sampleRate <= 0) {
185 | return null;
186 | } else {
187 | return String.format(Locale.US, "%d Hz", sampleRate);
188 | }
189 | }
190 | });
191 | sFormatterMap.put(KEY_IJK_CHANNEL_UI, new Formatter() {
192 | @Override
193 | protected String doFormat(IjkMediaFormat mediaFormat) {
194 | int channelLayout = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_CHANNEL_LAYOUT);
195 | if (channelLayout <= 0) {
196 | return null;
197 | } else {
198 | if (channelLayout == IjkMediaMeta.AV_CH_LAYOUT_MONO) {
199 | return "mono";
200 | } else if (channelLayout == IjkMediaMeta.AV_CH_LAYOUT_STEREO) {
201 | return "stereo";
202 | } else {
203 | return String.format(Locale.US, "%x", channelLayout);
204 | }
205 | }
206 | }
207 | });
208 | }
209 | }
210 |
--------------------------------------------------------------------------------
/TvPlayer/src/main/java/com/gxf/liveplay/ijkplayer/media/SurfaceRenderView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | * Copyright (C) 2016 hejunlin
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 com.gxf.liveplay.ijkplayer.media;
18 |
19 | import android.annotation.TargetApi;
20 | import android.content.Context;
21 | import android.graphics.SurfaceTexture;
22 | import android.os.Build;
23 | import android.support.annotation.NonNull;
24 | import android.support.annotation.Nullable;
25 | import android.util.AttributeSet;
26 | import android.util.Log;
27 | import android.view.Surface;
28 | import android.view.SurfaceHolder;
29 | import android.view.SurfaceView;
30 | import android.view.View;
31 | import android.view.accessibility.AccessibilityEvent;
32 | import android.view.accessibility.AccessibilityNodeInfo;
33 |
34 | import java.lang.ref.WeakReference;
35 | import java.util.Map;
36 | import java.util.concurrent.ConcurrentHashMap;
37 |
38 | import tv.danmaku.ijk.media.player.IMediaPlayer;
39 | import tv.danmaku.ijk.media.player.ISurfaceTextureHolder;
40 |
41 | public class SurfaceRenderView extends SurfaceView implements IRenderView {
42 | private MeasureHelper mMeasureHelper;
43 |
44 | public SurfaceRenderView(Context context) {
45 | super(context);
46 | initView(context);
47 | }
48 |
49 | public SurfaceRenderView(Context context, AttributeSet attrs) {
50 | super(context, attrs);
51 | initView(context);
52 | }
53 |
54 | public SurfaceRenderView(Context context, AttributeSet attrs, int defStyleAttr) {
55 | super(context, attrs, defStyleAttr);
56 | initView(context);
57 | }
58 |
59 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
60 | public SurfaceRenderView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
61 | super(context, attrs, defStyleAttr, defStyleRes);
62 | initView(context);
63 | }
64 |
65 | private void initView(Context context) {
66 | mMeasureHelper = new MeasureHelper(this);
67 | mSurfaceCallback = new SurfaceCallback(this);
68 | getHolder().addCallback(mSurfaceCallback);
69 | //noinspection deprecation
70 | getHolder().setType(SurfaceHolder.SURFACE_TYPE_NORMAL);
71 | }
72 |
73 | @Override
74 | public View getView() {
75 | return this;
76 | }
77 |
78 | @Override
79 | public boolean shouldWaitForResize() {
80 | return true;
81 | }
82 |
83 | //--------------------
84 | // Layout & Measure
85 | //--------------------
86 | @Override
87 | public void setVideoSize(int videoWidth, int videoHeight) {
88 | if (videoWidth > 0 && videoHeight > 0) {
89 | mMeasureHelper.setVideoSize(videoWidth, videoHeight);
90 | getHolder().setFixedSize(videoWidth, videoHeight);
91 | requestLayout();
92 | }
93 | }
94 |
95 | @Override
96 | public void setVideoSampleAspectRatio(int videoSarNum, int videoSarDen) {
97 | if (videoSarNum > 0 && videoSarDen > 0) {
98 | mMeasureHelper.setVideoSampleAspectRatio(videoSarNum, videoSarDen);
99 | requestLayout();
100 | }
101 | }
102 |
103 | @Override
104 | public void setVideoRotation(int degree) {
105 | Log.e("", "SurfaceView doesn't support rotation (" + degree + ")!\n");
106 | }
107 |
108 | @Override
109 | public void setAspectRatio(int aspectRatio) {
110 | mMeasureHelper.setAspectRatio(aspectRatio);
111 | requestLayout();
112 | }
113 |
114 | @Override
115 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
116 | mMeasureHelper.doMeasure(widthMeasureSpec, heightMeasureSpec);
117 | setMeasuredDimension(mMeasureHelper.getMeasuredWidth(), mMeasureHelper.getMeasuredHeight());
118 | }
119 |
120 | //--------------------
121 | // SurfaceViewHolder
122 | //--------------------
123 |
124 | private static final class InternalSurfaceHolder implements IRenderView.ISurfaceHolder {
125 | private SurfaceRenderView mSurfaceView;
126 | private SurfaceHolder mSurfaceHolder;
127 |
128 | public InternalSurfaceHolder(@NonNull SurfaceRenderView surfaceView,
129 | @Nullable SurfaceHolder surfaceHolder) {
130 | mSurfaceView = surfaceView;
131 | mSurfaceHolder = surfaceHolder;
132 | }
133 |
134 | public void bindToMediaPlayer(IMediaPlayer mp) {
135 | if (mp != null) {
136 | if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) &&
137 | (mp instanceof ISurfaceTextureHolder)) {
138 | ISurfaceTextureHolder textureHolder = (ISurfaceTextureHolder) mp;
139 | textureHolder.setSurfaceTexture(null);
140 | }
141 | mp.setDisplay(mSurfaceHolder);
142 | }
143 | }
144 |
145 | @NonNull
146 | @Override
147 | public IRenderView getRenderView() {
148 | return mSurfaceView;
149 | }
150 |
151 | @Nullable
152 | @Override
153 | public SurfaceHolder getSurfaceHolder() {
154 | return mSurfaceHolder;
155 | }
156 |
157 | @Nullable
158 | @Override
159 | public SurfaceTexture getSurfaceTexture() {
160 | return null;
161 | }
162 |
163 | @Nullable
164 | @Override
165 | public Surface openSurface() {
166 | if (mSurfaceHolder == null)
167 | return null;
168 | return mSurfaceHolder.getSurface();
169 | }
170 | }
171 |
172 | //-------------------------
173 | // SurfaceHolder.Callback
174 | //-------------------------
175 |
176 | @Override
177 | public void addRenderCallback(IRenderCallback callback) {
178 | mSurfaceCallback.addRenderCallback(callback);
179 | }
180 |
181 | @Override
182 | public void removeRenderCallback(IRenderCallback callback) {
183 | mSurfaceCallback.removeRenderCallback(callback);
184 | }
185 |
186 | private SurfaceCallback mSurfaceCallback;
187 |
188 | private static final class SurfaceCallback implements SurfaceHolder.Callback {
189 | private SurfaceHolder mSurfaceHolder;
190 | private boolean mIsFormatChanged;
191 | private int mFormat;
192 | private int mWidth;
193 | private int mHeight;
194 |
195 | private WeakReference mWeakSurfaceView;
196 | private Map mRenderCallbackMap = new ConcurrentHashMap();
197 |
198 | public SurfaceCallback(@NonNull SurfaceRenderView surfaceView) {
199 | mWeakSurfaceView = new WeakReference(surfaceView);
200 | }
201 |
202 | public void addRenderCallback(@NonNull IRenderCallback callback) {
203 | mRenderCallbackMap.put(callback, callback);
204 |
205 | ISurfaceHolder surfaceHolder = null;
206 | if (mSurfaceHolder != null) {
207 | if (surfaceHolder == null)
208 | surfaceHolder = new InternalSurfaceHolder(mWeakSurfaceView.get(), mSurfaceHolder);
209 | callback.onSurfaceCreated(surfaceHolder, mWidth, mHeight);
210 | }
211 |
212 | if (mIsFormatChanged) {
213 | if (surfaceHolder == null)
214 | surfaceHolder = new InternalSurfaceHolder(mWeakSurfaceView.get(), mSurfaceHolder);
215 | callback.onSurfaceChanged(surfaceHolder, mFormat, mWidth, mHeight);
216 | }
217 | }
218 |
219 | public void removeRenderCallback(@NonNull IRenderCallback callback) {
220 | mRenderCallbackMap.remove(callback);
221 | }
222 |
223 | @Override
224 | public void surfaceCreated(SurfaceHolder holder) {
225 | mSurfaceHolder = holder;
226 | mIsFormatChanged = false;
227 | mFormat = 0;
228 | mWidth = 0;
229 | mHeight = 0;
230 |
231 | ISurfaceHolder surfaceHolder = new InternalSurfaceHolder(mWeakSurfaceView.get(), mSurfaceHolder);
232 | for (IRenderCallback renderCallback : mRenderCallbackMap.keySet()) {
233 | renderCallback.onSurfaceCreated(surfaceHolder, 0, 0);
234 | }
235 | }
236 |
237 | @Override
238 | public void surfaceDestroyed(SurfaceHolder holder) {
239 | mSurfaceHolder = null;
240 | mIsFormatChanged = false;
241 | mFormat = 0;
242 | mWidth = 0;
243 | mHeight = 0;
244 |
245 | ISurfaceHolder surfaceHolder = new InternalSurfaceHolder(mWeakSurfaceView.get(), mSurfaceHolder);
246 | for (IRenderCallback renderCallback : mRenderCallbackMap.keySet()) {
247 | renderCallback.onSurfaceDestroyed(surfaceHolder);
248 | }
249 | }
250 |
251 | @Override
252 | public void surfaceChanged(SurfaceHolder holder, int format,
253 | int width, int height) {
254 | mSurfaceHolder = holder;
255 | mIsFormatChanged = true;
256 | mFormat = format;
257 | mWidth = width;
258 | mHeight = height;
259 |
260 | // mMeasureHelper.setVideoSize(width, height);
261 |
262 | ISurfaceHolder surfaceHolder = new InternalSurfaceHolder(mWeakSurfaceView.get(), mSurfaceHolder);
263 | for (IRenderCallback renderCallback : mRenderCallbackMap.keySet()) {
264 | renderCallback.onSurfaceChanged(surfaceHolder, format, width, height);
265 | }
266 | }
267 | }
268 |
269 | //--------------------
270 | // Accessibility
271 | //--------------------
272 |
273 | @Override
274 | public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
275 | super.onInitializeAccessibilityEvent(event);
276 | event.setClassName(SurfaceRenderView.class.getName());
277 | }
278 |
279 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
280 | @Override
281 | public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
282 | super.onInitializeAccessibilityNodeInfo(info);
283 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
284 | info.setClassName(SurfaceRenderView.class.getName());
285 | }
286 | }
287 | }
288 |
--------------------------------------------------------------------------------