├── .gitignore ├── .gitmodules ├── README.md ├── assets ├── licenses │ ├── android-googletv-license │ ├── android-sdk-license │ ├── android-sdk-preview-license │ ├── google-gdk-license │ ├── intel-android-extra-license │ └── mips-android-sysimage-license ├── publish.sh └── sdk-android.pom ├── build.gradle ├── googlemediaframework ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── google │ └── android │ └── libraries │ └── mediaframework │ └── layeredvideo │ └── PlaybackControlLayer.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── keystore └── app-keystore.jks ├── sambaplayersdk ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── sambatech │ │ └── player │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── sambatech │ │ │ └── player │ │ │ ├── CustomTimeBar.java │ │ │ ├── PlayPauseState.java │ │ │ ├── SambaApi.java │ │ │ ├── SambaPlayer.java │ │ │ ├── SambaPlayerView.java │ │ │ ├── SambaSimplePlayerView.java │ │ │ ├── adapter │ │ │ ├── CaptionsSheetAdapter.java │ │ │ ├── CastCaptionsAdapter.java │ │ │ ├── OutputSheetAdapter.java │ │ │ └── SpeedSheetAdapter.java │ │ │ ├── cast │ │ │ ├── CastDRM.java │ │ │ ├── CastObject.java │ │ │ ├── CastOptionsMenu.java │ │ │ ├── CastOptionsProvider.java │ │ │ ├── CastPlayer.java │ │ │ ├── CastQuery.java │ │ │ ├── CastTimeline.java │ │ │ ├── CastTimelineTracker.java │ │ │ ├── CastUtils.java │ │ │ └── SambaCast.java │ │ │ ├── event │ │ │ ├── SambaApiCallback.java │ │ │ ├── SambaCastListener.java │ │ │ ├── SambaEvent.java │ │ │ ├── SambaEventBus.java │ │ │ ├── SambaEventType.java │ │ │ └── SambaPlayerListener.java │ │ │ ├── mediasource │ │ │ ├── PlayerInstanceDefault.java │ │ │ ├── PlayerMediaSource.java │ │ │ ├── PlayerMediaSourceDash.java │ │ │ ├── PlayerMediaSourceExtractor.java │ │ │ ├── PlayerMediaSourceHLS.java │ │ │ ├── PlayerMediaSourceInterface.java │ │ │ └── SambaDataSourceFactory.java │ │ │ ├── model │ │ │ ├── AdsSettings.java │ │ │ ├── SambaMedia.java │ │ │ ├── SambaMediaConfig.java │ │ │ ├── SambaMediaRequest.java │ │ │ └── SambaPlayerError.java │ │ │ ├── offline │ │ │ ├── CustomDrmCallback.java │ │ │ ├── OfflineUtils.java │ │ │ ├── SambaDownloadManager.java │ │ │ ├── SambaDownloadService.java │ │ │ ├── SambaDownloadTracker.java │ │ │ ├── SambaTrackNameProvider.java │ │ │ ├── StartDownloadHelper.java │ │ │ ├── listeners │ │ │ │ ├── LicenceDrmCallback.java │ │ │ │ ├── SambaDownloadListener.java │ │ │ │ └── SambaDownloadRequestListener.java │ │ │ └── model │ │ │ │ ├── DownloadData.java │ │ │ │ ├── DownloadState.java │ │ │ │ ├── ProgressMessageEvent.java │ │ │ │ ├── SambaDownloadRequest.java │ │ │ │ ├── SambaSubtitle.java │ │ │ │ └── SambaTrack.java │ │ │ ├── plugins │ │ │ ├── Captions.java │ │ │ ├── DrmRequest.java │ │ │ ├── ImaWrapper.java │ │ │ ├── Plugin.java │ │ │ ├── PluginManager.java │ │ │ ├── Tracking.java │ │ │ ├── TrackingFactory.java │ │ │ ├── TrackingLive.java │ │ │ └── TrackingVOD.java │ │ │ └── utils │ │ │ ├── CastLiveButtonListener.java │ │ │ ├── ColorCastUtil.java │ │ │ ├── Controls.java │ │ │ ├── Helpers.java │ │ │ ├── OptionsMenuController.java │ │ │ ├── OptionsMenuLayer.java │ │ │ ├── Orientation.java │ │ │ ├── SharedPrefsUtils.java │ │ │ └── Util.java │ └── res │ │ ├── drawable-hdpi │ │ ├── sambaplayer_ic_caption.png │ │ ├── sambaplayer_ic_close.png │ │ ├── sambaplayer_ic_hd_active.png │ │ ├── sambaplayer_ic_live.png │ │ ├── sambaplayer_ic_menu.png │ │ ├── sambaplayer_ic_retry.png │ │ └── sambaplayer_ic_speed.png │ │ ├── drawable-mdpi │ │ ├── sambaplayer_ic_caption.png │ │ ├── sambaplayer_ic_close.png │ │ ├── sambaplayer_ic_hd_active.png │ │ ├── sambaplayer_ic_live.png │ │ ├── sambaplayer_ic_menu.png │ │ ├── sambaplayer_ic_retry.png │ │ └── sambaplayer_ic_speed.png │ │ ├── drawable-xhdpi │ │ ├── sambaplayer_ic_caption.png │ │ ├── sambaplayer_ic_close.png │ │ ├── sambaplayer_ic_hd_active.png │ │ ├── sambaplayer_ic_live.png │ │ ├── sambaplayer_ic_menu.png │ │ ├── sambaplayer_ic_retry.png │ │ └── sambaplayer_ic_speed.png │ │ ├── drawable-xxhdpi │ │ ├── sambaplayer_ic_caption.png │ │ ├── sambaplayer_ic_close.png │ │ ├── sambaplayer_ic_hd_active.png │ │ ├── sambaplayer_ic_live.png │ │ ├── sambaplayer_ic_menu.png │ │ ├── sambaplayer_ic_retry.png │ │ └── sambaplayer_ic_speed.png │ │ ├── drawable-xxxhdpi │ │ ├── sambaplayer_ic_caption.png │ │ ├── sambaplayer_ic_close.png │ │ ├── sambaplayer_ic_hd_active.png │ │ ├── sambaplayer_ic_menu.png │ │ └── sambaplayer_ic_speed.png │ │ ├── drawable │ │ ├── controls_bottom_background.xml │ │ ├── controls_top_background.xml │ │ ├── exo_controls_pause.xml │ │ ├── exo_controls_play.xml │ │ ├── gradient_audio_thumb_mask.xml │ │ ├── sambaplayer_cast_connected.xml │ │ ├── sambaplayer_cast_unconnected.xml │ │ ├── sambaplayer_empty_divider.xml │ │ ├── sambaplayer_error_icon.xml │ │ ├── sambaplayer_ic_cast.xml │ │ ├── sambaplayer_ic_fullscreen.xml │ │ ├── sambaplayer_ic_fullscreen_exit.xml │ │ └── sambaplayer_ic_nosignal.xml │ │ ├── layout │ │ ├── action_sheet.xml │ │ ├── action_sheet_item.xml │ │ ├── cast_button.xml │ │ ├── custom_simple_exo_player_view.xml │ │ ├── error_screen.xml │ │ ├── exo_playback_control_view.xml │ │ ├── exo_simple_player_view.xml │ │ ├── menu_options_layer.xml │ │ └── start_download_dialog.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── sambatech │ └── playersdk │ └── ExampleUnitTest.java ├── sample ├── build.gradle ├── proguard-rules.txt └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_sambabee-web.png │ ├── java │ └── com │ │ └── sambatech │ │ └── sample │ │ ├── MainApplication.java │ │ ├── activities │ │ ├── AboutActivity.java │ │ ├── MainActivity.java │ │ ├── MediaItemActivity.java │ │ ├── OfflineActivity.java │ │ └── PrepareActivity.java │ │ ├── adapters │ │ ├── MediasAdapter.java │ │ └── MediasOfflineAdapter.java │ │ ├── model │ │ ├── EntitlementScheme.java │ │ ├── JSONMedia.java │ │ ├── LiquidMedia.java │ │ ├── MediaInfo.java │ │ └── OnMediaClickListener.java │ │ ├── rest │ │ ├── ILiquidApi.java │ │ └── LiquidApi.java │ │ └── utils │ │ ├── GsonRequest.java │ │ ├── Helpers.java │ │ ├── ItemClickEvent.java │ │ └── VolleySingleton.java │ └── res │ ├── drawable-hdpi │ ├── ic_abelha.png │ ├── ic_action_discard.png │ ├── ic_action_favorite.png │ ├── ic_action_share.png │ ├── ic_arrow.png │ ├── ic_audio.png │ ├── ic_dbclick.png │ ├── ic_dbclick_disable.png │ ├── ic_download.png │ ├── ic_download_done.png │ ├── ic_plus.png │ └── ic_plus_white.png │ ├── drawable-mdpi │ ├── ic_abelha.png │ ├── ic_action_discard.png │ ├── ic_action_favorite.png │ ├── ic_action_share.png │ ├── ic_arrow.png │ ├── ic_audio.png │ ├── ic_dbclick.png │ ├── ic_dbclick_disable.png │ ├── ic_download.png │ ├── ic_download_done.png │ ├── ic_plus.png │ └── ic_plus_white.png │ ├── drawable-xhdpi │ ├── ic_abelha.png │ ├── ic_action_discard.png │ ├── ic_action_favorite.png │ ├── ic_action_share.png │ ├── ic_arrow.png │ ├── ic_audio.png │ ├── ic_dbclick.png │ ├── ic_dbclick_disable.png │ ├── ic_download.png │ ├── ic_download_done.png │ ├── ic_plus.png │ └── ic_plus_white.png │ ├── drawable-xxhdpi │ ├── ic_abelha.png │ ├── ic_action_discard.png │ ├── ic_action_favorite.png │ ├── ic_action_share.png │ ├── ic_arrow.png │ ├── ic_audio.png │ ├── ic_dbclick.png │ ├── ic_dbclick_disable.png │ ├── ic_download.png │ ├── ic_download_done.png │ ├── ic_plus.png │ └── ic_plus_white.png │ ├── drawable-xxxhdpi │ ├── ic_download.png │ └── ic_download_done.png │ ├── layout │ ├── activity_about.xml │ ├── activity_main.xml │ ├── activity_media_item.xml │ ├── activity_offline.xml │ ├── media_list_item.xml │ └── media_offline_cell.xml │ ├── menu │ ├── main_menu.xml │ └── offline_menu.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ ├── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml │ └── xml │ └── network_security_config.xml ├── scripts └── publish-mavencentral.gradle ├── settings.gradle ├── sonar-project.properties └── tagging /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle/ 2 | .idea/ 3 | build/ 4 | demo/build/ 5 | *.iml 6 | gmf-android.iml 7 | googlemediaframework/build/ 8 | local.properties 9 | .DS_Store 10 | player/*.apk 11 | docs/JavaDoc* 12 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "docs/player_androidsdk.wiki"] 2 | path = docs/player_androidsdk.wiki 3 | url = https://github.com/sambatech/player_androidsdk.wiki.git 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Features 2 | 3 | - Reprodução vídeos VOD PROGRESSIVE e HLS 4 | - SambaPlayer API 5 | - Suporte ao Samba Player Analytics 6 | - Suporte a advertising DFP 7 | - Player nativo do Android 8 | - Download de videos para assistir offline 9 | 10 | # SambaPlayer SDK (Android) 11 | 12 | Instalação do Java, Android SDK 13 | 14 | 1) Faça o download e instalação do último [SDK Java](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) 15 | 16 | 2) Faça o download e instalação do último [Android SDK](http://developer.android.com/sdk/installing/index.html) 17 | 18 | ## Como rodar a APP: 19 | 20 | 1) Clone o projeto 21 | 22 | 2) Rode em seu Android SDK Studio 23 | 24 | ## Como instalar o SDK: 25 | 26 | 1) Adicionar o repositório Maven e a dependência (build.gradle): 27 | ```java 28 | repositories { 29 | mavenCentral() 30 | } 31 | ... 32 | dependencies { 33 | compile 'io.github.sambatech:player_sdk_android:0.15.0' 34 | } 35 | ``` 36 | _Para verificar todas as versões disponíveis, favor consultar nossa página de [releases](https://github.com/sambatech/player_sdk_android/releases)._ 37 | 38 | 2) Instanciar o SambaPlayer em um View: 39 | ```xml 40 | 42 | ``` 43 | 44 | 3) Habilitar permissão para internet (AndroidManifest.xml): 45 | ```xml 46 | 47 | ``` 48 | 49 | 4) Recuperar a instância do SambaPlayer, efetuar requisição da mídia, aguardar resposta da API (via callback) e reproduzir: 50 | ```java 51 | player = (SambaPlayer)findViewById(R.id.samba_player); 52 | SambaApi api = new SambaApi(this); 53 | api.requestMedia(new SambaMediaRequest("34f07cf52fd85ccfc41a39bcf499e83b", "0632f26a442ba9ba3bb9067a45e239e2"), new SambaApiCallback() { 54 | @Override 55 | public void onMediaResponse(SambaMedia media) { 56 | player.setMedia(media); 57 | player.play(); 58 | } 59 | }); 60 | ``` 61 | 62 | Para maiores informações, favor consultar nossa página [Wiki](https://github.com/sambatech/player_sdk_android/wiki). 63 | 64 | Para informações sobre o JavaDoc favor consultar a nossa página no [SambaDev](http://dev.sambatech.com/documentation/androidsdk/index.html) 65 | 66 | ## Deploy 67 | 68 | 1) Atualizar `PUBLISH_VERSION` no arquivo `sambaplayersdk/build.gradle` subindo a versão. 69 | 70 | 2) Colocar as credenciais e chaves gpg no local.properties (para saber mais do processo, acessar issue no repositório squadSambavideos ) 71 | 72 | 3) Após o merge em master,executar gradlew assembleRelease para gerar uma release com a nova versão. 73 | 74 | 4) Executar comando gradlew sambaplayersdk:publishReleasePublicationToSonatypeRepository para publicar no sonatype. 75 | 76 | 5) Se logar em https://s01.oss.sonatype.org/ e em Staging Repositores realizar fechamento e release -------------------------------------------------------------------------------- /assets/licenses/android-googletv-license: -------------------------------------------------------------------------------- 1 | 2 | 601085b94cd77f0b54ff86406957099ebe79c4d6 -------------------------------------------------------------------------------- /assets/licenses/android-sdk-license: -------------------------------------------------------------------------------- 1 | 2 | d56f5187479451eabf01fb78af6dfcb131a6481e -------------------------------------------------------------------------------- /assets/licenses/android-sdk-preview-license: -------------------------------------------------------------------------------- 1 | 2 | 84831b9409646a918e30573bab4c9c91346d8abd -------------------------------------------------------------------------------- /assets/licenses/google-gdk-license: -------------------------------------------------------------------------------- 1 | 2 | 33b6a2b64607f11b759f320ef9dff4ae5c47d97a -------------------------------------------------------------------------------- /assets/licenses/intel-android-extra-license: -------------------------------------------------------------------------------- 1 | 2 | d975f751698a77b662f1254ddbeed3901e976f5a -------------------------------------------------------------------------------- /assets/licenses/mips-android-sysimage-license: -------------------------------------------------------------------------------- 1 | 2 | e9acab5b5fbb560a72cfaecce8946896ff6aab9d -------------------------------------------------------------------------------- /assets/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # $1: Bintray user 4 | # $2: Bintray API key 5 | # $3 (optional): Version suffix 6 | 7 | repoUser=$1 8 | repoApiKey=$2 9 | versionSuffix=$([[ -z $3 ]] && echo 'beta' || echo $3) 10 | ret='' 11 | 12 | set -x 13 | 14 | publish() { 15 | # $1: module name 16 | # $2: artifact name 17 | # $n: dep name 18 | # $n+1: dep version 19 | 20 | # vars 21 | output="$1/build/outputs/aar" 22 | v="$(cat "$1/build.gradle" | grep 'versionName' | sed $'s/^[^"\']*[\'"v]*//' | sed $'s/[^0-9]*$//')-$versionSuffix" 23 | pomPath="$output/$2-$v.pom" 24 | pomPathTmp="$output/tmp.pom" 25 | args=($@) 26 | 27 | # artifacts 28 | mkdir -p "$output" 29 | cat "assets/$2.pom" | sed "/$2/,/aar/ s/version\>[^\<]*/version\>$v/" > $pomPath 30 | 31 | # update deps version 32 | for ((i=2; i<$#; i+=2)); do 33 | cat $pomPath | sed "/${args[i]}/,/compile/ s/version\>[^\<]*/version\>${args[i+1]}/" > $pomPathTmp 34 | mv $pomPathTmp $pomPath 35 | done 36 | 37 | mv $output/$1-release.aar $output/$2-$v.aar 38 | cp $output/* $CIRCLE_ARTIFACTS 39 | 40 | # JFrog docs: https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Bintray 41 | # configuring repo client tool 42 | ./jfrog bt c --user=$repoUser --key=$repoApiKey --licenses=MIT 43 | # uploading artifacts to repo 44 | ./jfrog bt u "$output/$2*" "sambatech/maven/sdk-android/beta4" "com/sambatech/player/$2/$v/" --publish=true --override=true 45 | 46 | ret=$v 47 | } 48 | 49 | publish sambaplayersdk sdk-android $ret -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright 2014 Google Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 19 | 20 | buildscript { 21 | repositories { 22 | 23 | maven { url "https://plugins.gradle.org/m2/" } 24 | 25 | mavenCentral() 26 | 27 | jcenter() 28 | 29 | google() 30 | } 31 | dependencies { 32 | classpath 'com.android.tools.build:gradle:4.0.0' 33 | classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5' 34 | classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.0" 35 | } 36 | } 37 | 38 | allprojects { 39 | repositories { 40 | 41 | google() 42 | 43 | mavenCentral() 44 | 45 | jcenter() 46 | } 47 | } 48 | 49 | apply plugin: 'io.codearte.nexus-staging' 50 | -------------------------------------------------------------------------------- /googlemediaframework/build.gradle: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright 2014 Google Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | apply plugin: 'com.android.library' 18 | 19 | android { 20 | compileSdkVersion 25 21 | buildToolsVersion '26.0.2' 22 | 23 | defaultConfig { 24 | minSdkVersion 17 25 | targetSdkVersion 25 26 | versionCode 15 27 | versionName 'v0.2.1-8' 28 | } 29 | buildTypes { 30 | release { 31 | minifyEnabled false 32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 33 | } 34 | } 35 | productFlavors { 36 | } 37 | compileOptions { 38 | sourceCompatibility JavaVersion.VERSION_1_7 39 | targetCompatibility JavaVersion.VERSION_1_7 40 | } 41 | } 42 | 43 | dependencies { 44 | compile 'com.android.support:design:25.4.0' 45 | compile 'com.google.android.exoplayer:exoplayer:r1.5.7' 46 | } 47 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Settings specified in this file will override any Gradle settings 5 | # configured through the IDE. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | GROUP=com.sambatech.player 21 | POM_ARTIFACT_ID=sambaplayer-android-sdk 22 | VERSION_NAME=1.0.0-alpha 23 | 24 | RELEASE_REPOSITORY_URL=http://arch2.sambatech.com.br:8081/nexus/content/repositories/sambaplayer-android-sdk 25 | #SNAPSHOT_REPOSITORY_URL= 26 | NEXUS_USERNAME=admin 27 | NEXUS_PASSWORD=F7Yhtxge6b 28 | 29 | POM_PACKAGING=aar 30 | POM_NAME=Samba Player Android SDK 31 | POM_DESCRIPTION=Samba Tech's video player SDK for Android 32 | POM_URL=http://sambatech.com 33 | POM_SCM_URL=https://github.com/sambatech/player_androidsdk 34 | POM_SCM_CONNECTION=scm:git@github.com:sambatech/player_androidsdk.git 35 | POM_SCM_DEV_CONNECTION=scm:git@github.com:sambatech/player_androidsdk.git 36 | POM_LICENCE_NAME=The MIT License (MIT) 37 | POM_LICENCE_URL=https://opensource.org/licenses/MIT 38 | POM_LICENCE_DIST=repo 39 | POM_DEVELOPER_ID=sambatech 40 | POM_DEVELOPER_NAME=SAMBA MOBILE MULTIMIDIA S/A 41 | 42 | ANDROID_BUILD_TARGET_SDK_VERSION=28 43 | ANDROID_BUILD_TOOLS_VERSION=26.0.2 44 | ANDROID_BUILD_SDK_VERSION=28 45 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /keystore/app-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/keystore/app-keystore.jks -------------------------------------------------------------------------------- /sambaplayersdk/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sambaplayersdk/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'org.sonarqube' 3 | 4 | android { 5 | compileSdkVersion 29 6 | buildToolsVersion '28.0.3' 7 | 8 | defaultConfig { 9 | minSdkVersion 17 10 | targetSdkVersion 29 11 | versionCode 42 12 | versionName "v0.15.0-beta" 13 | } 14 | 15 | compileOptions { 16 | sourceCompatibility JavaVersion.VERSION_1_8 17 | targetCompatibility JavaVersion.VERSION_1_8 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | 27 | lintOptions { 28 | warningsAsErrors false 29 | showAll true 30 | abortOnError false 31 | xmlReport true 32 | } 33 | } 34 | 35 | sonarqube { 36 | properties { 37 | property "sonar.projectName", "SambaPlayer Android SDK" 38 | property "sonar.projectKey", "sambaplayer-android-sdk" 39 | property "sonar.host.url", "http://ec2-34-203-40-94.compute-1.amazonaws.com/sonar/" 40 | property "sonar.language", "java" 41 | property "sonar.sources", "src/main/java/" 42 | property "sonar.login", "dev" 43 | property "sonar.password", "44a538ed1" 44 | } 45 | } 46 | 47 | dependencies { 48 | testCompile 'junit:junit:4.12' 49 | compile 'com.google.android.gms:play-services-cast-framework:16.0.1' 50 | compile 'com.android.support:appcompat-v7:28.0.0' 51 | compile 'com.android.support:mediarouter-v7:28.0.0' 52 | compile 'org.bitbucket.b_c:jose4j:0.6.3' 53 | compile 'com.google.android.exoplayer:exoplayer:2.9.1' 54 | compile 'com.google.android.exoplayer:extension-ima:2.9.1' 55 | compile 'com.google.android.exoplayer:exoplayer-core:2.9.1' 56 | compile 'com.google.android.exoplayer:exoplayer-dash:2.9.1' 57 | compile 'com.google.android.exoplayer:exoplayer-hls:2.9.1' 58 | compile 'com.google.android.exoplayer:exoplayer-ui:2.9.1' 59 | compile 'com.android.support:design:28.0.0' 60 | implementation 'com.sambatech.player.3rd.peer5:sdk:2.8.1@aar' 61 | implementation 'com.github.bumptech.glide:glide:4.7.1' 62 | implementation 'com.google.code.gson:gson:2.8.5' 63 | implementation 'org.greenrobot:eventbus:3.1.1' 64 | implementation 'org.apache.commons:commons-collections4:4.0' 65 | } 66 | 67 | ext { 68 | PUBLISH_GROUP_ID = 'io.github.sambatech' 69 | PUBLISH_ARTIFACT_ID = 'player_sdk_android' 70 | PUBLISH_VERSION = '0.15.0' // needs to increase on every publish 71 | } 72 | apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" 73 | -------------------------------------------------------------------------------- /sambaplayersdk/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 /Users/zanol/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /sambaplayersdk/src/androidTest/java/com/sambatech/player/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /sambaplayersdk/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 33 | 34 | 35 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/PlayPauseState.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player; 2 | 3 | /** 4 | * Created by luizbyrro on 31/01/2018. 5 | */ 6 | public enum PlayPauseState { 7 | Playing, Loading, Pause 8 | } 9 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/SambaPlayerView.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | 6 | /** 7 | * Alias for new player class. 8 | * @deprecated Please use SambaPlayer class instead. 9 | */ 10 | public class SambaPlayerView extends SambaPlayer { 11 | 12 | public SambaPlayerView(Context context, AttributeSet attrs) { 13 | super(context, attrs); 14 | } 15 | } -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/adapter/CaptionsSheetAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.RadioButton; 9 | import android.widget.TextView; 10 | 11 | import com.google.android.exoplayer2.source.TrackGroup; 12 | import com.google.android.exoplayer2.source.TrackGroupArray; 13 | import com.sambatech.player.R; 14 | import com.sambatech.player.model.SambaMedia; 15 | 16 | import java.util.List; 17 | 18 | /** 19 | * Created by luizbyrro on 07/11/17. 20 | */ 21 | 22 | public class CaptionsSheetAdapter extends BaseAdapter { 23 | 24 | public int currentIndex = -1; 25 | 26 | private Context cContext; 27 | private TrackGroupArray captions; 28 | 29 | public CaptionsSheetAdapter(Context context, TrackGroupArray trackGroupArray) { 30 | this.cContext = context; 31 | this.captions = trackGroupArray; 32 | } 33 | 34 | @Override 35 | public int getCount() { 36 | return captions.length; 37 | } 38 | 39 | @Override 40 | public Object getItem(int position) { 41 | return captions.get(position); 42 | } 43 | 44 | @Override 45 | public long getItemId(int position) { 46 | return 0; 47 | } 48 | 49 | @Override 50 | public View getView(int position, View convertView, ViewGroup parent) { 51 | CaptionItem holder; 52 | 53 | if (convertView == null) { 54 | convertView = ((LayoutInflater) cContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) 55 | .inflate(R.layout.action_sheet_item, parent, false); 56 | 57 | holder = new CaptionItem(convertView); 58 | convertView.setTag(holder); 59 | } 60 | else { 61 | holder = (CaptionItem) convertView.getTag(); 62 | } 63 | 64 | TrackGroup caption = (TrackGroup) getItem(position); 65 | 66 | if (caption.getFormat(0).language != null && caption.getFormat(0).language.length() > 0) { 67 | holder.label.setText(caption.getFormat(0).language); 68 | } else { 69 | holder.label.setText(R.string.no_caption); 70 | } 71 | 72 | 73 | holder.radio.setChecked(currentIndex == position); 74 | 75 | return convertView; 76 | } 77 | 78 | private static class CaptionItem { 79 | TextView label; 80 | RadioButton radio; 81 | 82 | CaptionItem(View view) { 83 | this.radio = (RadioButton) view.findViewById(R.id.sheet_output_radio); 84 | this.label = (TextView) view.findViewById(R.id.sheet_item_label); 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/adapter/CastCaptionsAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.RadioButton; 9 | import android.widget.TextView; 10 | 11 | import com.sambatech.player.R; 12 | import com.sambatech.player.model.SambaMedia; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * Created by luizbyrro on 20/02/2018. 18 | */ 19 | 20 | public class CastCaptionsAdapter extends BaseAdapter { 21 | 22 | public int currentIndex = -1; 23 | 24 | private List captionsList; 25 | private Context cContext; 26 | 27 | public CastCaptionsAdapter(List captionsList, Context cContext) { 28 | this.captionsList = captionsList; 29 | this.cContext = cContext; 30 | currentIndex = captionsList.size() - 1; 31 | } 32 | 33 | @Override 34 | public int getCount() { 35 | return captionsList.size(); 36 | } 37 | 38 | @Override 39 | public Object getItem(int i) { 40 | return captionsList.get(i); 41 | } 42 | 43 | @Override 44 | public long getItemId(int i) { 45 | return 0; 46 | } 47 | 48 | @Override 49 | public View getView(int position, View convertView, ViewGroup parent) { 50 | 51 | CastCaptionsAdapter.CaptionItem holder; 52 | 53 | if (convertView == null) { 54 | convertView = ((LayoutInflater) cContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) 55 | .inflate(R.layout.action_sheet_item, parent, false); 56 | 57 | holder = new CastCaptionsAdapter.CaptionItem(convertView); 58 | convertView.setTag(holder); 59 | } 60 | else { 61 | holder = (CastCaptionsAdapter.CaptionItem) convertView.getTag(); 62 | } 63 | 64 | SambaMedia.Caption caption = (SambaMedia.Caption) getItem(position); 65 | 66 | if (caption.label != null && caption.label.length() > 0) { 67 | holder.label.setText(caption.label); 68 | } else { 69 | holder.label.setText(caption.language); 70 | } 71 | 72 | 73 | holder.radio.setChecked(currentIndex == position); 74 | 75 | return convertView; 76 | } 77 | 78 | private static class CaptionItem { 79 | TextView label; 80 | RadioButton radio; 81 | 82 | CaptionItem(View view) { 83 | this.radio = (RadioButton) view.findViewById(R.id.sheet_output_radio); 84 | this.label = (TextView) view.findViewById(R.id.sheet_item_label); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/adapter/OutputSheetAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.adapter; 2 | 3 | import android.content.Context; 4 | import android.media.MediaFormat; 5 | import android.support.annotation.NonNull; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.BaseAdapter; 10 | import android.widget.RadioButton; 11 | import android.widget.TextView; 12 | 13 | import com.google.android.exoplayer2.Format; 14 | import com.google.android.exoplayer2.source.TrackGroup; 15 | import com.sambatech.player.R; 16 | import com.sambatech.player.SambaPlayer; 17 | 18 | /** 19 | * Created by luizbyrro on 07/11/17. 20 | */ 21 | 22 | public class OutputSheetAdapter extends BaseAdapter { 23 | 24 | public int currentIndex = -1; 25 | private int offset = 0; 26 | 27 | private final @NonNull 28 | Context context; 29 | private final @NonNull 30 | TrackGroup outputs; 31 | 32 | public OutputSheetAdapter(@NonNull Context context, @NonNull TrackGroup outputs, boolean abrEnabled) { 33 | this.context = context; 34 | this.outputs = outputs; 35 | this.offset = abrEnabled ? 1 : 0; 36 | } 37 | 38 | @Override 39 | public int getCount() { 40 | return outputs.length + offset; 41 | } 42 | 43 | @Override 44 | public Object getItem(int position) { 45 | if (offset == 1 && position == 0) return null; 46 | return outputs.getFormat(position - offset); 47 | } 48 | 49 | @Override 50 | public long getItemId(int position) { 51 | return 0; 52 | } 53 | 54 | //TODO melhorar a renderizacao para nao ser duplicada 55 | @Override 56 | public View getView(final int position, View convertView, ViewGroup parent) { 57 | LayoutInflater inflater = (LayoutInflater) context 58 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 59 | 60 | final Format output = (Format) getItem(position); 61 | OutputSheetAdapter.OutputItem holder; 62 | 63 | if (convertView == null) { 64 | convertView = inflater.inflate(R.layout.action_sheet_item, parent, false); 65 | holder = new OutputSheetAdapter.OutputItem(convertView); 66 | convertView.setTag(holder); 67 | } 68 | else holder = (OutputSheetAdapter.OutputItem) convertView.getTag(); 69 | 70 | if (output == null) 71 | holder.label.setText(R.string.qualitty_auto); 72 | else 73 | holder.label.setText(output.height > 0 ? output.height + "p" : Math.round(output.bitrate/1000f) + "k"); 74 | holder.radio.setChecked(currentIndex == position); 75 | 76 | return convertView; 77 | } 78 | 79 | private static class OutputItem { 80 | TextView label; 81 | RadioButton radio; 82 | 83 | OutputItem(View view) { 84 | this.radio = (RadioButton) view.findViewById(R.id.sheet_output_radio); 85 | this.label = (TextView) view.findViewById(R.id.sheet_item_label); 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/adapter/SpeedSheetAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.RadioButton; 9 | import android.widget.TextView; 10 | 11 | import com.sambatech.player.R; 12 | 13 | /** 14 | * Created by luizbyrro on 01/12/2017. 15 | */ 16 | 17 | public class SpeedSheetAdapter extends BaseAdapter { 18 | 19 | public int currentIndex = -1; 20 | 21 | private Context cContext; 22 | private float[] speeds; 23 | 24 | public SpeedSheetAdapter(Context cContext, float[] speeds) { 25 | this.cContext = cContext; 26 | this.speeds = speeds; 27 | } 28 | @Override 29 | public int getCount() { 30 | return speeds.length; 31 | } 32 | 33 | @Override 34 | public Object getItem(int position) { 35 | return speeds[position]; 36 | } 37 | 38 | @Override 39 | public long getItemId(int position) { 40 | return 0; 41 | } 42 | 43 | @Override 44 | public View getView(int position, View convertView, ViewGroup parent) { 45 | SpeedSheetAdapter.SpeedItem holder; 46 | 47 | if (convertView == null) { 48 | convertView = ((LayoutInflater) cContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) 49 | .inflate(R.layout.action_sheet_item, parent, false); 50 | 51 | holder = new SpeedSheetAdapter.SpeedItem(convertView); 52 | convertView.setTag(holder); 53 | } 54 | else { 55 | holder = (SpeedSheetAdapter.SpeedItem) convertView.getTag(); 56 | } 57 | 58 | float speed = (float) getItem(position); 59 | 60 | holder.label.setText(String.valueOf(speed) + "x"); 61 | 62 | holder.radio.setChecked(currentIndex == position); 63 | 64 | return convertView; 65 | } 66 | 67 | private static class SpeedItem { 68 | TextView label; 69 | RadioButton radio; 70 | 71 | SpeedItem(View view) { 72 | this.radio = (RadioButton) view.findViewById(R.id.sheet_output_radio); 73 | this.label = (TextView) view.findViewById(R.id.sheet_item_label); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/cast/CastDRM.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.cast; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class CastDRM { 6 | 7 | private String sessionId; 8 | private String ticket; 9 | private String token; 10 | 11 | 12 | public CastDRM () { 13 | 14 | } 15 | 16 | public CastDRM (JSONObject json) { 17 | 18 | this.sessionId = json.optString("SessionId"); 19 | this.ticket = json.optString("Ticket"); 20 | } 21 | 22 | public CastDRM(String sessionId, String ticket) { 23 | this.sessionId = sessionId; 24 | this.ticket = ticket; 25 | } 26 | 27 | public String getSessionId() { 28 | return sessionId; 29 | } 30 | 31 | public void setSessionId(String sessionId) { 32 | this.sessionId = sessionId; 33 | } 34 | 35 | public String getTicket() { 36 | return ticket; 37 | } 38 | 39 | public void setTicket(String ticket) { 40 | this.ticket = ticket; 41 | } 42 | 43 | public void setToken(String token) { 44 | this.token = token; 45 | } 46 | 47 | public String getToken() { 48 | return token; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "{" + 54 | "\"SessionId\":\"" + sessionId + '\"' + 55 | ", \"Ticket\":\"" + ticket + '\"' + 56 | (token != null ? ", \"Token\":\"" + token + '\"' : "") + 57 | '}'; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/cast/CastObject.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.cast; 2 | 3 | import com.sambatech.player.R; 4 | import com.sambatech.player.model.SambaMediaRequest; 5 | 6 | import org.json.*; 7 | 8 | 9 | public class CastObject { 10 | 11 | private String title; 12 | private String m; 13 | private String live; 14 | private long duration; 15 | private String theme; 16 | private String ph; 17 | private CastQuery qs; 18 | private String thumbURL; 19 | private String baseURL; 20 | private CastDRM drm; 21 | 22 | 23 | public CastObject () { 24 | 25 | } 26 | 27 | public CastObject (JSONObject json) { 28 | 29 | this.title = json.optString("title"); 30 | this.m = json.optString("m"); 31 | this.live = json.optString("live"); 32 | this.duration = json.optLong("duration"); 33 | this.theme = json.optString("theme"); 34 | this.ph = json.optString("ph"); 35 | this.qs = new CastQuery(json.optJSONObject("qs")); 36 | this.thumbURL = json.optString("thumbURL"); 37 | this.baseURL = json.optString("baseURL"); 38 | 39 | } 40 | 41 | public CastObject(String title, String m, long duration, String theme, String ph, CastQuery qs, String thumbURL, String baseURL) { 42 | this.title = title; 43 | this.m = m; 44 | this.duration = duration; 45 | this.theme = theme; 46 | this.ph = ph; 47 | this.qs = qs; 48 | this.thumbURL = thumbURL; 49 | this.baseURL = baseURL; 50 | } 51 | 52 | public String getTitle() { 53 | return this.title; 54 | } 55 | 56 | public void setTitle(String title) { 57 | this.title = title; 58 | } 59 | 60 | public String getM() { 61 | return this.m; 62 | } 63 | 64 | public void setM(String m) { 65 | this.m = m; 66 | } 67 | 68 | public long getDuration() { 69 | return this.duration; 70 | } 71 | 72 | public void setDuration(long duration) { 73 | this.duration = duration; 74 | } 75 | 76 | public String getTheme() { 77 | return this.theme; 78 | } 79 | 80 | public void setTheme(String theme) { 81 | this.theme = theme; 82 | } 83 | 84 | public String getPh() { 85 | return this.ph; 86 | } 87 | 88 | public void setPh(String ph) { 89 | this.ph = ph; 90 | } 91 | 92 | public CastQuery getQs() { 93 | return this.qs; 94 | } 95 | 96 | public void setQs(CastQuery qs) { 97 | this.qs = qs; 98 | } 99 | 100 | public String getThumbURL() { 101 | return this.thumbURL; 102 | } 103 | 104 | public void setThumbURL(String thumbURL) { 105 | this.thumbURL = thumbURL; 106 | } 107 | 108 | public String getBaseURL() { 109 | return this.baseURL; 110 | } 111 | 112 | public void setBaseURL(String baseURL) { 113 | this.baseURL = baseURL; 114 | } 115 | 116 | public void setDrm(CastDRM drm) { 117 | this.drm = drm; 118 | } 119 | 120 | public CastDRM getDrm() { 121 | return drm; 122 | } 123 | 124 | public String getLive() { 125 | return live; 126 | } 127 | 128 | public void setLive(String live) { 129 | this.live = live; 130 | } 131 | 132 | @Override 133 | public String toString() { 134 | return "{" + 135 | "\"title\":\"" + title + '\"' + 136 | ", \"m\":\"" + m + '\"' + 137 | (live != null && !live.isEmpty() ? ", \"live\":\"" + live + '\"' : "") + 138 | ", \"duration\":" + duration + 139 | ", \"theme\":\"" + theme + '\"' + 140 | ", \"ph\":\"" + ph + '\"' + 141 | ", \"qs\":" + qs + 142 | ", \"thumbURL\":\"" + thumbURL + '\"' + 143 | ", \"baseURL\":\"" + baseURL + '\"' + 144 | ", \"drm\":" + drm + 145 | '}'; 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/cast/CastOptionsProvider.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.cast; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.NonNull; 5 | 6 | import com.google.android.gms.cast.framework.CastOptions; 7 | import com.google.android.gms.cast.framework.OptionsProvider; 8 | import com.google.android.gms.cast.framework.SessionProvider; 9 | import com.sambatech.player.R; 10 | import com.sambatech.player.model.SambaMediaRequest; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * @author Leandro Zanol on 3/21/17. 16 | */ 17 | public final class CastOptionsProvider implements OptionsProvider { 18 | 19 | public static final String CUSTOM_NAMESPACE = "urn:x-cast:com.sambatech.player"; 20 | 21 | // It can be configured before instantiating "SambaCast" 22 | public static String appId; 23 | public static String playerUrl; 24 | public static SambaMediaRequest.Environment environment; 25 | 26 | public CastOptionsProvider() {} 27 | 28 | @Override 29 | public CastOptions getCastOptions(Context context) { 30 | configProfile(context, SambaMediaRequest.Environment.PROD, false); 31 | /*List supportedNamespaces = new ArrayList<>(); 32 | supportedNamespaces.add(CUSTOM_NAMESPACE);*/ 33 | 34 | return new CastOptions.Builder() 35 | //.setReceiverApplicationId(appId) 36 | .setReceiverApplicationId(appId) 37 | //.setCastMediaOptions(mediaOptions) 38 | .setResumeSavedSession(true) 39 | .setStopReceiverApplicationWhenEndingSession(true) 40 | .setEnableReconnectionService(true) 41 | //.setSupportedNamespaces(supportedNamespaces) 42 | .build(); 43 | } 44 | 45 | @Override 46 | public List getAdditionalSessionProviders(Context context) { 47 | return null; 48 | } 49 | 50 | /** 51 | * Configures cast params according to a predefined profile. 52 | * Must be called BEFORE SambaCast is initialized. 53 | * @param context The activity context 54 | * @param environment The environment to match the profile values 55 | */ 56 | public static void configProfile(@NonNull Context context, @NonNull SambaMediaRequest.Environment environment) { 57 | configProfile(context, environment, true); 58 | } 59 | 60 | /** 61 | * Configures cast params according to a predefined profile. 62 | * Must be called BEFORE SambaCast is initialized. 63 | * @param context The activity context 64 | * @param environment The environment to match the profile values 65 | * @param overwrite Overwrite existing configured values? 66 | */ 67 | public static void configProfile(@NonNull Context context, @NonNull SambaMediaRequest.Environment environment, boolean overwrite) { 68 | if (CastOptionsProvider.environment == null || overwrite) CastOptionsProvider.environment = environment; 69 | 70 | switch (environment) { 71 | case DEV: 72 | if (appId == null || overwrite) appId = context.getString(R.string.cast_app_id_dev); 73 | if (playerUrl == null || overwrite) playerUrl = context.getString(R.string.base_url_dev); 74 | break; 75 | case STAGING: 76 | if (appId == null || overwrite) appId = context.getString(R.string.cast_app_id_staging); 77 | if (playerUrl == null || overwrite) playerUrl = context.getString(R.string.base_url_staging); 78 | break; 79 | case PROD: 80 | if (appId == null || overwrite) appId = context.getString(R.string.cast_app_id_prod); 81 | if (playerUrl == null || overwrite) playerUrl = context.getString(R.string.base_url_prod); 82 | break; 83 | } 84 | } 85 | 86 | /*private static class ImagePickerImpl extends ImagePicker { 87 | 88 | @Override 89 | public WebImage onPickImage(MediaMetadata mediaMetadata, int type) { 90 | if ((mediaMetadata == null) || !mediaMetadata.hasImages()) { 91 | return null; 92 | } 93 | List images = mediaMetadata.getImages(); 94 | if (images.size() == 1) { 95 | return images.get(0); 96 | } else { 97 | if (type == ImagePicker.IMAGE_TYPE_MEDIA_ROUTE_CONTROLLER_DIALOG_BACKGROUND) { 98 | return images.get(0); 99 | } else { 100 | return images.get(1); 101 | } 102 | } 103 | } 104 | }*/ 105 | } 106 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/cast/CastQuery.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.cast; 2 | 3 | import org.json.JSONObject; 4 | 5 | 6 | public class CastQuery { 7 | 8 | private boolean html5; 9 | private String scriptURL; 10 | private String castApi; 11 | private String castAppId; 12 | private String logger; 13 | private long initialTime; 14 | private String captionTheme; 15 | 16 | 17 | public CastQuery() { 18 | 19 | } 20 | 21 | public CastQuery(JSONObject json) { 22 | 23 | this.html5 = json.optBoolean("html5"); 24 | this.scriptURL = json.optString("scriptURL"); 25 | this.castApi = json.optString("castApi"); 26 | this.castAppId = json.optString("castAppId"); 27 | this.logger = json.optString("logger"); 28 | this.initialTime = json.optLong("initialTime"); 29 | this.captionTheme = json.optString("captionTheme"); 30 | } 31 | 32 | public boolean getHtml5() { 33 | return this.html5; 34 | } 35 | 36 | public void setHtml5(boolean html5) { 37 | this.html5 = html5; 38 | } 39 | 40 | public String getScriptURL() { 41 | return this.scriptURL; 42 | } 43 | 44 | public void setScriptURL(String scriptURL) { 45 | this.scriptURL = scriptURL; 46 | } 47 | 48 | public String getCastApi() { 49 | return this.castApi; 50 | } 51 | 52 | public void setCastApi(String castApi) { 53 | this.castApi = castApi; 54 | } 55 | 56 | public String getCastAppId() { 57 | return this.castAppId; 58 | } 59 | 60 | public void setCastAppId(String castAppId) { 61 | this.castAppId = castAppId; 62 | } 63 | 64 | public String getLogger() { 65 | return this.logger; 66 | } 67 | 68 | public void setLogger(String logger) { 69 | this.logger = logger; 70 | } 71 | 72 | public long getInitialTime() { 73 | return this.initialTime; 74 | } 75 | 76 | public void setInitialTime(long initialTime) { 77 | this.initialTime = initialTime; 78 | } 79 | 80 | 81 | public String getCaptionTheme() { 82 | return captionTheme; 83 | } 84 | 85 | public void setCaptionTheme(String captionTheme) { 86 | this.captionTheme = captionTheme; 87 | } 88 | 89 | @Override 90 | public String toString() { 91 | return "{" + 92 | "\"html5\":" + html5 + 93 | /*",\"scriptURL\":\"" + scriptURL + '\"' +*/ 94 | ",\"castApi\":\"" + castApi + '\"' + 95 | ",\"castAppId\":\"" + castAppId + '\"' + 96 | ",\"captionTheme\":\"" + captionTheme + '\"' + 97 | ",\"initialTime\":" + initialTime + 98 | '}'; 99 | } 100 | 101 | public CastQuery(boolean html5, /*String scriptURL,*/ String castApi, String castAppId, long initialTime, String captionTheme) { 102 | this.html5 = html5; 103 | //this.scriptURL = scriptURL; 104 | this.castApi = castApi; 105 | this.castAppId = castAppId; 106 | this.initialTime = initialTime; 107 | this.captionTheme = captionTheme; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/cast/CastTimelineTracker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sambatech.player.cast; 17 | 18 | import com.google.android.gms.cast.MediaInfo; 19 | import com.google.android.gms.cast.MediaQueueItem; 20 | import com.google.android.gms.cast.MediaStatus; 21 | import java.util.HashMap; 22 | import java.util.HashSet; 23 | import java.util.List; 24 | 25 | /** 26 | * Creates {@link CastTimeline}s from cast receiver app media status. 27 | * 28 | *

This class keeps track of the duration reported by the current item to fill any missing 29 | * durations in the media queue items [See internal: b/65152553]. 30 | */ 31 | /* package */ final class CastTimelineTracker { 32 | 33 | private final HashMap contentIdToDurationUsMap; 34 | private final HashSet scratchContentIdSet; 35 | 36 | public CastTimelineTracker() { 37 | contentIdToDurationUsMap = new HashMap<>(); 38 | scratchContentIdSet = new HashSet<>(); 39 | } 40 | 41 | 42 | public CastTimeline getCastTimeline(List items, String contentId, long durationUs) { 43 | removeUnusedDurationEntries(items); 44 | contentIdToDurationUsMap.put(contentId, durationUs); 45 | return new CastTimeline(items, contentIdToDurationUsMap); 46 | } 47 | 48 | private void removeUnusedDurationEntries(List items) { 49 | scratchContentIdSet.clear(); 50 | for (MediaQueueItem item : items) { 51 | scratchContentIdSet.add(item.getMedia().getContentId()); 52 | } 53 | contentIdToDurationUsMap.keySet().retainAll(scratchContentIdSet); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/event/SambaApiCallback.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.event; 2 | 3 | import com.sambatech.player.model.SambaMedia; 4 | import com.sambatech.player.model.SambaMediaRequest; 5 | 6 | /** 7 | * Listeners representing server responses. 8 | * 9 | * @author Leandro Zanol - 4/12/15 10 | */ 11 | public abstract class SambaApiCallback { 12 | 13 | /** 14 | * Fired up after a unique success response from the server. 15 | * @param media SambaMedia 16 | */ 17 | public void onMediaResponse(SambaMedia media) {} 18 | 19 | /** 20 | * Fired up after a set of success responses from the server. 21 | * @param mediaList SambaMedia 22 | */ 23 | public void onMediaListResponse(SambaMedia[] mediaList) {} 24 | 25 | /** 26 | * 27 | * Fired up after an error response from the server. 28 | * @param e The raised exception 29 | * @param request Original request 30 | */ 31 | public void onMediaResponseError(Exception e, SambaMediaRequest request) {} 32 | } 33 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/event/SambaCastListener.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.event; 2 | 3 | import com.google.android.gms.cast.framework.CastSession; 4 | 5 | /** 6 | * @author Leandro Zanol on 3/24/17 7 | */ 8 | 9 | public interface SambaCastListener { 10 | 11 | /** 12 | * Dispatched when a connection is established with Chromecast. 13 | */ 14 | void onConnected(CastSession castSession); 15 | 16 | void onConnected(); 17 | 18 | /** 19 | * Dispatched when a connection is close with Chromecast. 20 | */ 21 | void onDisconnected(); 22 | } 23 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/event/SambaEvent.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.event; 2 | 3 | /** 4 | * @author tmiranda - 9/12/15 5 | */ 6 | public class SambaEvent { 7 | 8 | private final SambaEventType type; 9 | private final Object data; 10 | private final Object[] dataAll; 11 | 12 | /** 13 | * SambaEvent default constructor 14 | * @param type {@link SambaPlayerListener.EventType} 15 | */ 16 | public SambaEvent(SambaEventType type) { 17 | this(type, new Object[]{}); 18 | } 19 | 20 | /** 21 | * SambaEvent constructor 22 | * @param type {@link SambaPlayerListener.EventType} 23 | * @param data An data that can be passed in the event 24 | */ 25 | public SambaEvent(SambaEventType type, Object ... data) { 26 | this.type = type; 27 | this.data = data.length > 0 ? data[0] : null; 28 | this.dataAll = data; 29 | } 30 | 31 | 32 | /** 33 | * Get the current event type 34 | * @return {@link SambaPlayerListener.EventType} 35 | */ 36 | public SambaEventType getType() { 37 | return type; 38 | } 39 | 40 | /** 41 | * Get the current data 42 | * @return Object 43 | */ 44 | public Object getData() { 45 | return data; 46 | } 47 | 48 | /** 49 | * Get all the data 50 | * @return array of objects 51 | */ 52 | public Object[] getDataAll() { 53 | return dataAll; 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/event/SambaEventBus.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.event; 2 | 3 | import android.util.Log; 4 | 5 | import java.lang.reflect.Method; 6 | import java.lang.reflect.Modifier; 7 | import java.util.ArrayList; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | import java.util.ListIterator; 11 | 12 | /** 13 | * @author Leandro Zanol - 10/12/15 14 | */ 15 | public class SambaEventBus { 16 | 17 | private static EventBus _eventBus = new EventBus(); 18 | 19 | private SambaEventBus() {} 20 | 21 | /** 22 | * Registers an event. 23 | * @param listener listener object 24 | */ 25 | public static void subscribe(Object listener) { 26 | _eventBus.subscribe(listener); 27 | } 28 | 29 | /** 30 | * Unregisters an event. 31 | * @param listener listener object 32 | */ 33 | public static void unsubscribe(Object listener) { 34 | _eventBus.unsubscribe(listener); 35 | } 36 | 37 | /** 38 | * Triggers an event. 39 | * @param e a particular event 40 | */ 41 | public static void post(SambaEvent e) { 42 | _eventBus.post(e); 43 | } 44 | 45 | private static class EventBus { 46 | private HashMap> listeners = new HashMap<>(); 47 | private List postponedUnsubscribes; 48 | 49 | public void subscribe(Object listener) { 50 | String type = listener.getClass().getSuperclass().getSimpleName(); 51 | String k; 52 | 53 | for (Method m : listener.getClass().getDeclaredMethods()) { 54 | if (!Modifier.isPublic(m.getModifiers())) 55 | continue; 56 | 57 | k = String.format("%s:%s", type, m.getName().substring(2)); // rm "on" 58 | 59 | if (!listeners.containsKey(k)) 60 | listeners.put(k, new ArrayList<>()); 61 | 62 | listeners.get(k).add(listener); 63 | } 64 | } 65 | 66 | public void unsubscribe(Object listener) { 67 | if (postponedUnsubscribes != null) { 68 | postponedUnsubscribes.add(listener); 69 | return; 70 | } 71 | 72 | String type = listener.getClass().getSuperclass().getSimpleName(); 73 | String k; 74 | List ltnList; 75 | 76 | for (Method m : listener.getClass().getDeclaredMethods()) { 77 | k = String.format("%s:%s", type, m.getName().substring(2)); 78 | 79 | if (listeners.containsKey(k)) { 80 | ltnList = listeners.get(k); 81 | 82 | if (ltnList.contains(listener)) 83 | ltnList.remove(listener); 84 | 85 | if (ltnList.size() == 0) 86 | listeners.remove(k); 87 | } 88 | } 89 | } 90 | 91 | public void post(SambaEvent e) { 92 | final String[] types = e.getType().toString().toLowerCase().split("_"); 93 | String t = ""; 94 | 95 | for (String type : types) 96 | t += type.substring(0, 1).toUpperCase() + type.substring(1); 97 | 98 | final String k = String.format("%s:%s", e.getType().getClass().getEnclosingClass().getSimpleName(), t); 99 | 100 | if (!listeners.containsKey(k)) 101 | return; 102 | 103 | try { 104 | // postpone call for lock purposes 105 | postponedUnsubscribes = new ArrayList<>(); 106 | 107 | Object listener; 108 | Method m; 109 | 110 | for (ListIterator iterator = listeners.get(k).listIterator(); iterator.hasNext();) { 111 | listener = iterator.next(); 112 | m = listener.getClass().getDeclaredMethod("on" + t, SambaEvent.class); 113 | 114 | if (m != null) 115 | m.invoke(listener, e); 116 | } 117 | 118 | List unsubs = postponedUnsubscribes; 119 | 120 | // release locker 121 | postponedUnsubscribes = null; 122 | 123 | if (unsubs != null && unsubs.size() > 0) { 124 | for (Object ltn : unsubs) 125 | unsubscribe(ltn); 126 | 127 | unsubs.clear(); 128 | } 129 | } 130 | catch (Exception exp) { 131 | // it's okay not finding the methods in current class instance (getDeclaredMethod()) 132 | Log.i(getClass().getSimpleName(), "Error trying to lookup or invoke method.", exp); 133 | } 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/event/SambaEventType.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.event; 2 | 3 | /** 4 | * @author tmiranda - 9/12/15 5 | */ 6 | public interface SambaEventType {} 7 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/event/SambaPlayerListener.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.event; 2 | 3 | /** 4 | * Listener for player events. 5 | * 6 | * @author Leandro Zanol - 9/12/15 7 | */ 8 | public abstract class SambaPlayerListener { 9 | 10 | /** 11 | * Events type 12 | */ 13 | public enum EventType implements SambaEventType { 14 | LOAD, 15 | DESTROY, 16 | START, 17 | PLAY, 18 | PAUSE, 19 | STOP, 20 | PROGRESS, 21 | FULLSCREEN, 22 | FULLSCREEN_EXIT, 23 | FINISH, 24 | RESIZE, 25 | CLICK, 26 | ERROR, 27 | PORTRAIT, 28 | LANDSCAPE, 29 | CAST_CONNECT, 30 | CAST_DISCONNECT, 31 | CAST_PLAY, 32 | CAST_PAUSE, 33 | CAST_FINISH 34 | } 35 | 36 | /** 37 | * OnLoad player fired when the player is initialized. 38 | * @param event LOAD EventType.event 39 | */ 40 | public void onLoad(SambaEvent event) {} 41 | 42 | /** 43 | * onDestroy player fired when the player is destroyed. 44 | * @param event DESTROY EventType.event 45 | */ 46 | public void onDestroy(SambaEvent event) {} 47 | 48 | /** 49 | * OnStart player fired when the media starts to play for the first time. 50 | * @param event START EventType.event 51 | */ 52 | public void onStart(SambaEvent event) {} 53 | 54 | /** 55 | * OnPlay player fired when the player is resumed ( it's fired after the start event ). 56 | * @param event PLAY EventType.event 57 | */ 58 | public void onPlay(SambaEvent event) {} 59 | 60 | /** 61 | * OnPause player fired when the user pauses the player. 62 | * @param event PAUSE EventType.event 63 | */ 64 | public void onPause(SambaEvent event) {} 65 | 66 | /** 67 | * OnStop player fired when the player is stopped. 68 | * @param event STOP EventType.event 69 | */ 70 | public void onStop(SambaEvent event) {} 71 | 72 | /** 73 | * OnProgress player fired as the player is watched. 74 | * @param event PROGRESS EventType.event 75 | */ 76 | public void onProgress(SambaEvent event) {} 77 | 78 | /** 79 | * OnFullscreen player fired when the player enters the fullscreen mode. 80 | * @param event FULLSCREEN EventType.event 81 | */ 82 | public void onFullscreen(SambaEvent event) {} 83 | 84 | /** 85 | * OnFullscreenExit player fired when the player exit the fullscreen mode. 86 | * @param event FULLSCREEN_EXIT EventType.event 87 | */ 88 | public void onFullscreenExit(SambaEvent event) {} 89 | 90 | /** 91 | * OnFinish player fired when the player is finished. 92 | * @param event FINISH EventType.event 93 | */ 94 | public void onFinish(SambaEvent event) {} 95 | 96 | /** 97 | * OnResize player fired when the player is resized. 98 | * @param event RESIZE EventType.event 99 | */ 100 | public void onResize(SambaEvent event) {} 101 | 102 | /** 103 | * OnLoad OnClick fired whenever the player view is clicked 104 | * @param event CLICK EventType.event 105 | */ 106 | public void onClick(SambaEvent event) {} 107 | 108 | /** 109 | * OnError player fired when the player has an error 110 | * @param event ERROR EventType.event 111 | */ 112 | public void onError(SambaEvent event) {} 113 | 114 | /** 115 | * OnPortrait player fired when the user puts the cellphone in portrait mode 116 | * @param event PORTRAIT EventType.event 117 | */ 118 | public void onPortrait(SambaEvent event) {} 119 | 120 | /** 121 | * OnLandscape player fired when the user puts the cellphone in landscape mode 122 | * @param event LANDSCAPE EventType.event 123 | */ 124 | public void onLandscape(SambaEvent event) {} 125 | 126 | public void onCastConnect(SambaEvent event) {} 127 | 128 | public void onCastDisconnect(SambaEvent event) {} 129 | 130 | public void onCastPlay(SambaEvent event) {} 131 | 132 | public void onCastPause(SambaEvent event) {} 133 | 134 | public void onCastFinish(SambaEvent event) {} 135 | 136 | } 137 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/mediasource/PlayerMediaSourceDash.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.mediasource; 2 | 3 | import android.net.Uri; 4 | 5 | import com.google.android.exoplayer2.offline.FilteringManifestParser; 6 | import com.google.android.exoplayer2.source.MediaSource; 7 | import com.google.android.exoplayer2.source.dash.DashChunkSource; 8 | import com.google.android.exoplayer2.source.dash.DashMediaSource; 9 | import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource; 10 | import com.google.android.exoplayer2.source.dash.manifest.DashManifestParser; 11 | import com.sambatech.player.offline.SambaDownloadManager; 12 | 13 | /** 14 | * Created by luizbyrro on 28/11/2017. 15 | */ 16 | 17 | public class PlayerMediaSourceDash extends PlayerMediaSource implements PlayerMediaSourceInterface { 18 | 19 | private DashChunkSource.Factory dashChunkSourceFactory; 20 | 21 | public PlayerMediaSourceDash(PlayerInstanceDefault playerInstanceDefault, String url) { 22 | super(playerInstanceDefault); 23 | dashChunkSourceFactory = new DefaultDashChunkSource.Factory(playerInstanceDefault.mediaDataSourceFactory); 24 | setUrl(url); 25 | } 26 | 27 | @Override 28 | public void setUrl(String url) { 29 | super.setUrl(url); 30 | Uri uri = Uri.parse(url); 31 | 32 | MediaSource mediaSource; 33 | 34 | if (SambaDownloadManager.getInstance().isConfigured()) { 35 | mediaSource = new DashMediaSource.Factory(SambaDownloadManager.getInstance().buildDataSourceFactory()) 36 | .setManifestParser( 37 | new FilteringManifestParser<>(new DashManifestParser(), SambaDownloadManager.getInstance().getOfflineStreamKeys(uri))) 38 | .createMediaSource(uri); 39 | } else { 40 | mediaSource = new DashMediaSource.Factory(dashChunkSourceFactory, 41 | playerInstanceDefault.mediaDataSourceFactory) 42 | .createMediaSource(Uri.parse(url)); 43 | } 44 | 45 | setMediaSource(mediaSource); 46 | } 47 | 48 | @Override 49 | public void destroy() { 50 | super.destroy(); 51 | dashChunkSourceFactory = null; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/mediasource/PlayerMediaSourceExtractor.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.mediasource; 2 | 3 | import android.net.Uri; 4 | 5 | import com.google.android.exoplayer2.source.ExtractorMediaSource; 6 | import com.google.android.exoplayer2.upstream.DataSource; 7 | import com.sambatech.player.offline.SambaDownloadManager; 8 | 9 | /** 10 | * Created by luizbyrro on 28/11/2017. 11 | */ 12 | 13 | public class PlayerMediaSourceExtractor extends PlayerMediaSource implements PlayerMediaSourceInterface { 14 | 15 | public PlayerMediaSourceExtractor(PlayerInstanceDefault playerInstanceDefault, String url) { 16 | super(playerInstanceDefault); 17 | this.setUrl(url); 18 | } 19 | 20 | @Override 21 | public void setUrl(String url) { 22 | super.setUrl(url); 23 | Uri uri = Uri.parse(url); 24 | 25 | DataSource.Factory dataSourceFactory = SambaDownloadManager.getInstance().isConfigured() ? SambaDownloadManager.getInstance().buildDataSourceFactory() : this.playerInstanceDefault.mediaDataSourceFactory; 26 | 27 | setMediaSource(new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(uri)); 28 | } 29 | 30 | @Override 31 | public void destroy() { 32 | super.destroy(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/mediasource/PlayerMediaSourceHLS.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.mediasource; 2 | 3 | import android.net.Uri; 4 | 5 | import com.google.android.exoplayer2.source.MediaSource; 6 | import com.google.android.exoplayer2.source.hls.HlsMediaSource; 7 | import com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistParserFactory; 8 | import com.sambatech.player.offline.SambaDownloadManager; 9 | import com.peer5.sdk.Peer5Sdk; 10 | 11 | public class PlayerMediaSourceHLS extends PlayerMediaSource implements PlayerMediaSourceInterface { 12 | 13 | public PlayerMediaSourceHLS(PlayerInstanceDefault playerInstanceDefault, String url, Boolean enablePeer5, boolean isLive) { 14 | super(playerInstanceDefault); 15 | this.setEnablePeer5(enablePeer5); 16 | this.setIsLive(isLive); 17 | this.setUrl(url); 18 | } 19 | 20 | @Override 21 | public void setUrl(String url) { 22 | super.setUrl(url); 23 | Uri uri = Uri.parse(url); 24 | MediaSource mediaSource; 25 | boolean hasDrm = url.contains("/vodd-sd/"); 26 | 27 | if(this.getEnablePeer5() && !hasDrm) { 28 | String peer5Url = Peer5Sdk.getPeer5StreamUrl(url); 29 | Uri peer5Uri = Uri.parse(peer5Url); 30 | 31 | uri = peer5Uri; 32 | } 33 | 34 | if (!this.getIsLive() && SambaDownloadManager.getInstance().isConfigured()) { 35 | mediaSource = new HlsMediaSource.Factory(SambaDownloadManager.getInstance() 36 | .buildDataSourceFactory()) 37 | .setPlaylistParserFactory( 38 | new DefaultHlsPlaylistParserFactory(SambaDownloadManager.getInstance() 39 | .getOfflineStreamKeys(uri))) 40 | .createMediaSource(uri); 41 | } else { 42 | mediaSource = new HlsMediaSource.Factory(playerInstanceDefault.mediaDataSourceFactory) 43 | .createMediaSource(uri); 44 | } 45 | 46 | setMediaSource(mediaSource); 47 | } 48 | 49 | @Override 50 | public void destroy() { 51 | super.destroy(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/mediasource/PlayerMediaSourceInterface.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.mediasource; 2 | 3 | import android.widget.FrameLayout; 4 | 5 | import com.google.android.exoplayer2.Format; 6 | import com.google.android.exoplayer2.source.MediaSource; 7 | import com.google.android.exoplayer2.source.TrackGroup; 8 | import com.google.android.exoplayer2.source.TrackGroupArray; 9 | import com.google.android.exoplayer2.trackselection.TrackSelectionArray; 10 | import com.sambatech.player.model.SambaMedia; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * Created by luizbyrro on 28/11/2017. 16 | */ 17 | 18 | public interface PlayerMediaSourceInterface { 19 | void setUrl(String url); 20 | 21 | MediaSource getMediaSource(); 22 | 23 | TrackGroup getVideoOutputsTracks(); 24 | 25 | void setVideoOutputTrack(Format format); 26 | 27 | void addSubtitles(List captions); 28 | 29 | TrackGroupArray getSubtitles(); 30 | 31 | void setSubtitle(TrackGroup trackGroup); 32 | 33 | void addAds(String url, FrameLayout frame); 34 | 35 | void forceOutuputTrackTo(int index, boolean isAbrEnabled); 36 | 37 | int getCurrentOutputTrackIndex(TrackSelectionArray trackSelections, boolean isAbrEnabled); 38 | 39 | Format getOutputByIndex(int index, boolean isAbrEnabled); 40 | 41 | void forceCaptionTrackTo(int index); 42 | 43 | int getCurrentCaptionTrackIndex(TrackSelectionArray trackSelections); 44 | 45 | TrackGroup getCaptionByIndex(int index); 46 | 47 | void destroy(); 48 | } 49 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/mediasource/SambaDataSourceFactory.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.mediasource; 2 | 3 | import android.content.Context; 4 | 5 | import com.google.android.exoplayer2.upstream.DataSource; 6 | import com.google.android.exoplayer2.upstream.DefaultDataSource; 7 | import com.google.android.exoplayer2.upstream.DefaultHttpDataSource; 8 | import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; 9 | import com.google.android.exoplayer2.upstream.TransferListener; 10 | import com.google.android.exoplayer2.util.Util; 11 | 12 | public class SambaDataSourceFactory implements DataSource.Factory { 13 | 14 | private final TransferListener bandwidthMeter; 15 | private DefaultHttpDataSourceFactory defaultHttpDataSourceFactory; 16 | private Context context; 17 | 18 | public SambaDataSourceFactory(Context context, String agent, TransferListener bandwidthMeter) { 19 | this.context = context; 20 | this.bandwidthMeter = bandwidthMeter; 21 | this.defaultHttpDataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(context, "mediaPlayerSample"), bandwidthMeter); 22 | } 23 | 24 | @Override 25 | public DataSource createDataSource() { 26 | 27 | DefaultHttpDataSource defaultHttpDataSource = (DefaultHttpDataSource) defaultHttpDataSourceFactory.createDataSource(); 28 | defaultHttpDataSource.setRequestProperty("teste-header", "value-test"); 29 | 30 | return new DefaultDataSource(context, bandwidthMeter, defaultHttpDataSource); 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/model/AdsSettings.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.model; 2 | 3 | import com.google.ads.interactivemedia.v3.api.AdsRenderingSettings; 4 | import com.google.ads.interactivemedia.v3.api.ImaSdkFactory; 5 | import com.google.ads.interactivemedia.v3.api.ImaSdkSettings; 6 | 7 | /** 8 | * @author Leandro Zanol - 7/19/17 9 | */ 10 | public final class AdsSettings { 11 | 12 | public final AdsRenderingSettings rendering = ImaSdkFactory.getInstance().createAdsRenderingSettings(); 13 | public final int maxRedirects; 14 | public final float vastLoadTimeout; // ms 15 | public boolean debugMode; 16 | 17 | public AdsSettings() { 18 | this(8000f); 19 | } 20 | 21 | public AdsSettings(float vastLoadTimeout) { 22 | this(vastLoadTimeout, ImaSdkSettings.DEFAULT_MAX_REDIRECTS); 23 | } 24 | 25 | public AdsSettings(float vastLoadTimeout, int maxRedirects) { 26 | this.vastLoadTimeout = vastLoadTimeout; 27 | this.maxRedirects = maxRedirects; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/model/SambaMedia.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.model; 2 | 3 | import android.graphics.drawable.Drawable; 4 | import android.support.annotation.NonNull; 5 | 6 | import com.google.gson.annotations.Expose; 7 | 8 | import java.util.ArrayList; 9 | 10 | /** 11 | * Data entity representing a media. 12 | * 13 | * @author Thiago Miranda, Leandro Zanol - 02/12/15 14 | */ 15 | public class SambaMedia { 16 | 17 | public String title = ""; 18 | public String url; 19 | public String type = ""; 20 | public String adUrl; 21 | @Expose 22 | public @NonNull transient AdsSettings adsSettings = new AdsSettings(); 23 | @Expose 24 | public transient Drawable thumb; 25 | public float initialTime = 0f; 26 | public float duration = 0f; 27 | public boolean isLive; 28 | public boolean isAudioOnly; 29 | public boolean isDvr; 30 | public @NonNull String[] backupUrls = new String[]{}; 31 | public ArrayList outputs; 32 | public ArrayList captions; 33 | public @NonNull CaptionsConfig captionsConfig = new CaptionsConfig(); 34 | public String drmToken; 35 | public String thumbAudioURL; 36 | 37 | public SambaMedia() {} 38 | 39 | public SambaMedia(SambaMedia media) { 40 | type = media.type; 41 | title = media.title; 42 | url = media.url; 43 | adUrl = media.adUrl; 44 | adsSettings = media.adsSettings; 45 | thumb = media.thumb; 46 | initialTime = media.initialTime; 47 | duration = media.duration; 48 | isLive = media.isLive; 49 | isAudioOnly = media.isAudioOnly; 50 | isDvr = media.isDvr; 51 | backupUrls = media.backupUrls; 52 | outputs = media.outputs; 53 | captions = media.captions; 54 | captionsConfig = media.captionsConfig; 55 | drmToken = media.drmToken; 56 | thumbAudioURL = media.thumbAudioURL; 57 | } 58 | 59 | public static class Output { 60 | public String url; 61 | public String label; 62 | public boolean isDefault = false; 63 | public int position; 64 | } 65 | 66 | public static class Caption { 67 | public final String url; 68 | public final String label; 69 | public final String language; 70 | public final boolean cc; 71 | public final boolean isDefault; 72 | 73 | public Caption(String url, String label, String language, boolean cc, boolean isDefault) { 74 | this.url = url; 75 | this.label = label; 76 | this.language = language; 77 | this.cc = cc; 78 | this.isDefault = isDefault; 79 | } 80 | } 81 | 82 | public static class CaptionsConfig { 83 | public final int color; 84 | public final float size; 85 | public final String language; 86 | 87 | public CaptionsConfig(int color, float size, String language) { 88 | this.color = color; 89 | this.size = size; 90 | this.language = language; 91 | } 92 | 93 | public CaptionsConfig(int color, float size) { 94 | this(color, size, null); 95 | } 96 | 97 | public CaptionsConfig(int color) { 98 | this(color, 20f); 99 | } 100 | 101 | public CaptionsConfig() { 102 | this(0xFFFFCC00); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/model/SambaMediaConfig.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.model; 2 | 3 | 4 | import com.google.android.exoplayer2.util.UriUtil; 5 | import com.sambatech.player.plugins.DrmRequest; 6 | import com.sambatech.player.utils.Helpers; 7 | 8 | import java.lang.reflect.Field; 9 | 10 | /** 11 | * Internal extension of the media entity for player/plugins config purposes. 12 | * 13 | * @author Leandro Zanol - 2/12/15 14 | */ 15 | public class SambaMediaConfig extends SambaMedia { 16 | 17 | public String id; 18 | public String projectHash; 19 | public String downloadUrl; 20 | public String qualifier; 21 | public int projectId; 22 | public int clientId; 23 | public int categoryId; 24 | public String sessionId = Helpers.getSessionId(); 25 | public int themeColor = 0xFF72BE44; 26 | public String themeColorHex = "#72BE44"; 27 | public String sttmUrl; 28 | public String sttmKey; 29 | public String sttm2Url; 30 | public String sttm2Key; 31 | public SambaMediaRequest request; 32 | public DrmRequest drmRequest; 33 | public boolean blockIfRooted; 34 | public int retriesTotal = 3; 35 | public int defaultOutputIndex = 0; 36 | public boolean isOffline; 37 | public boolean isSubtitlesOffline; 38 | public long bitrate; 39 | 40 | public SambaMediaConfig() {} 41 | 42 | public SambaMediaConfig(SambaMedia media) { 43 | super(media); 44 | 45 | if (media instanceof SambaMediaConfig) { 46 | SambaMediaConfig m = (SambaMediaConfig)media; 47 | id = m.id; 48 | projectHash = m.projectHash; 49 | qualifier = m.qualifier; 50 | projectId = m.projectId; 51 | clientId = m.clientId; 52 | categoryId = m.categoryId; 53 | sessionId = m.sessionId; 54 | themeColor = m.themeColor; 55 | themeColorHex = m.themeColorHex; 56 | sttmUrl = m.sttmUrl; 57 | sttmKey = m.sttmKey; 58 | sttm2Url = m.sttm2Url; 59 | sttm2Key = m.sttm2Key; 60 | request = m.request; 61 | drmRequest = m.drmRequest; 62 | // TODO: Reabilitar após correção (https://github.com/sambatech-desenv/player/issues/589) 63 | //blockIfRooted = m.blockIfRooted; 64 | retriesTotal = m.retriesTotal; 65 | downloadUrl = m.downloadUrl; 66 | isOffline = m.isOffline; 67 | isSubtitlesOffline = m.isSubtitlesOffline; 68 | bitrate = m.bitrate; 69 | } 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | String desc = ""; 75 | Field[] fields = getClass().getSuperclass().getDeclaredFields(); 76 | 77 | try { 78 | for (Field field : fields) 79 | desc += field.getName() + ": " + field.get(this) + '\n'; 80 | } 81 | catch (IllegalAccessException e) { 82 | e.printStackTrace(); 83 | } 84 | 85 | return desc; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/offline/listeners/LicenceDrmCallback.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.offline.listeners; 2 | 3 | public interface LicenceDrmCallback { 4 | public void onLicencePrepared(byte[] licencePayload); 5 | public void onLicenceError(Error error); 6 | } 7 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/offline/listeners/SambaDownloadListener.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.offline.listeners; 2 | 3 | import com.sambatech.player.offline.model.DownloadState; 4 | 5 | public interface SambaDownloadListener { 6 | void onDownloadStateChanged(DownloadState downloadState); 7 | } 8 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/offline/listeners/SambaDownloadRequestListener.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.offline.listeners; 2 | 3 | import com.sambatech.player.offline.model.SambaDownloadRequest; 4 | 5 | public interface SambaDownloadRequestListener { 6 | void onDownloadRequestPrepared(SambaDownloadRequest sambaDownloadRequest); 7 | void onDownloadRequestFailed(Error error, String msg); 8 | } 9 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/offline/model/DownloadData.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.offline.model; 2 | 3 | import com.sambatech.player.model.SambaMediaConfig; 4 | 5 | public class DownloadData { 6 | 7 | private String mediaId; 8 | private String mediaTitle; 9 | private Double totalDownloadSizeInMB; 10 | private SambaMediaConfig sambaMedia; 11 | private SambaSubtitle sambaSubtitle; 12 | 13 | 14 | public DownloadData(String mediaId, String mediaTitle, Double totalDownloadSizeInMB, SambaMediaConfig sambaMedia) { 15 | this.mediaId = mediaId; 16 | this.mediaTitle = mediaTitle; 17 | this.totalDownloadSizeInMB = totalDownloadSizeInMB; 18 | this.sambaMedia = sambaMedia; 19 | } 20 | 21 | public String getMediaTitle() { 22 | return mediaTitle; 23 | } 24 | 25 | public void setMediaTitle(String mediaTitle) { 26 | this.mediaTitle = mediaTitle; 27 | } 28 | 29 | public Double getTotalDownloadSizeInMB() { 30 | return totalDownloadSizeInMB; 31 | } 32 | 33 | public void setTotalDownloadSizeInMB(Double totalDownloadSizeInMB) { 34 | this.totalDownloadSizeInMB = totalDownloadSizeInMB; 35 | } 36 | 37 | public String getMediaId() { 38 | return mediaId; 39 | } 40 | 41 | public void setMediaId(String mediaId) { 42 | this.mediaId = mediaId; 43 | } 44 | 45 | public SambaMediaConfig getSambaMedia() { 46 | return sambaMedia; 47 | } 48 | 49 | public void setSambaMedia(SambaMediaConfig sambaMedia) { 50 | this.sambaMedia = sambaMedia; 51 | } 52 | 53 | public SambaSubtitle getSambaSubtitle() { 54 | return sambaSubtitle; 55 | } 56 | 57 | public void setSambaSubtitle(SambaSubtitle sambaSubtitle) { 58 | this.sambaSubtitle = sambaSubtitle; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/offline/model/DownloadState.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.offline.model; 2 | 3 | import com.sambatech.player.model.SambaMedia; 4 | 5 | public class DownloadState { 6 | 7 | public float downloadPercentage; 8 | public DownloadData downloadData; 9 | public State state; 10 | 11 | 12 | public DownloadState(float downloadPercentage, DownloadData downloadData, State state) { 13 | this.downloadPercentage = downloadPercentage; 14 | this.downloadData = downloadData; 15 | this.state = state; 16 | } 17 | 18 | public enum State { 19 | WAITING, 20 | COMPLETED, 21 | CANCELED, 22 | IN_PROGRESS, 23 | FAILED, 24 | DELETED 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/offline/model/ProgressMessageEvent.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.offline.model; 2 | 3 | import com.google.android.exoplayer2.offline.DownloadManager; 4 | 5 | public class ProgressMessageEvent { 6 | 7 | private DownloadManager.TaskState taskState; 8 | 9 | public ProgressMessageEvent(DownloadManager.TaskState taskState) { 10 | this.taskState = taskState; 11 | } 12 | 13 | public DownloadManager.TaskState getTaskState() { 14 | return taskState; 15 | } 16 | 17 | public void setTaskState(DownloadManager.TaskState taskState) { 18 | this.taskState = taskState; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/offline/model/SambaDownloadRequest.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.offline.model; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import com.google.android.exoplayer2.offline.DownloadHelper; 6 | import com.sambatech.player.model.SambaMedia; 7 | 8 | import java.util.List; 9 | 10 | public class SambaDownloadRequest { 11 | 12 | private String mediaId; 13 | private String projectHash; 14 | private String drmToken; 15 | private Double totalDownloadSize; 16 | 17 | private SambaMedia sambaMedia; 18 | 19 | private List sambaVideoTracks; 20 | private List sambaAudioTracks; 21 | private List sambaSubtitles; 22 | 23 | private List sambaTracksForDownload; 24 | private List sambaSubtitlesForDownload; 25 | 26 | private DownloadHelper downloadHelper; 27 | 28 | 29 | public SambaDownloadRequest(@NonNull String projectHash,@NonNull String mediaId) { 30 | this.mediaId = mediaId; 31 | this.projectHash = projectHash; 32 | } 33 | 34 | public String getMediaId() { 35 | return mediaId; 36 | } 37 | 38 | public void setMediaId(String mediaId) { 39 | this.mediaId = mediaId; 40 | } 41 | 42 | public String getProjectHash() { 43 | return projectHash; 44 | } 45 | 46 | public void setProjectHash(String projectHash) { 47 | this.projectHash = projectHash; 48 | } 49 | 50 | public String getDrmToken() { 51 | return drmToken; 52 | } 53 | 54 | public void setDrmToken(String drmToken) { 55 | this.drmToken = drmToken; 56 | } 57 | 58 | public List getSambaVideoTracks() { 59 | return sambaVideoTracks; 60 | } 61 | 62 | public void setSambaVideoTracks(List sambaVideoTracks) { 63 | this.sambaVideoTracks = sambaVideoTracks; 64 | } 65 | 66 | public SambaMedia getSambaMedia() { 67 | return sambaMedia; 68 | } 69 | 70 | public void setSambaMedia(SambaMedia sambaMedia) { 71 | this.sambaMedia = sambaMedia; 72 | } 73 | 74 | public List getSambaAudioTracks() { 75 | return sambaAudioTracks; 76 | } 77 | 78 | public void setSambaAudioTracks(List sambaAudioTracks) { 79 | this.sambaAudioTracks = sambaAudioTracks; 80 | } 81 | 82 | public List getSambaTracksForDownload() { 83 | return sambaTracksForDownload; 84 | } 85 | 86 | public void setSambaTracksForDownload(List sambaTracksForDownload) { 87 | this.sambaTracksForDownload = sambaTracksForDownload; 88 | } 89 | 90 | public DownloadHelper getDownloadHelper() { 91 | return downloadHelper; 92 | } 93 | 94 | public void setDownloadHelper(DownloadHelper downloadHelper) { 95 | this.downloadHelper = downloadHelper; 96 | } 97 | 98 | public Double getTotalDownloadSize() { 99 | return totalDownloadSize; 100 | } 101 | 102 | public void setTotalDownloadSize(Double totalDownloadSize) { 103 | this.totalDownloadSize = totalDownloadSize; 104 | } 105 | 106 | public List getSambaSubtitles() { 107 | return sambaSubtitles; 108 | } 109 | 110 | public void setSambaSubtitles(List sambaSubtitles) { 111 | this.sambaSubtitles = sambaSubtitles; 112 | } 113 | 114 | public List getSambaSubtitlesForDownload() { 115 | return sambaSubtitlesForDownload; 116 | } 117 | 118 | public void setSambaSubtitlesForDownload(List sambaSubtitlesForDownload) { 119 | this.sambaSubtitlesForDownload = sambaSubtitlesForDownload; 120 | } 121 | 122 | public void enableAllSubtitlesForDownload() { 123 | this.sambaSubtitlesForDownload = sambaSubtitles; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/offline/model/SambaSubtitle.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.offline.model; 2 | 3 | import com.sambatech.player.model.SambaMedia; 4 | 5 | public class SambaSubtitle { 6 | 7 | private String title; 8 | private SambaMedia.Caption caption; 9 | 10 | public SambaSubtitle(String title, SambaMedia.Caption caption) { 11 | this.title = title; 12 | this.caption = caption; 13 | } 14 | 15 | public String getTitle() { 16 | return title; 17 | } 18 | 19 | public SambaMedia.Caption getCaption() { 20 | return caption; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/offline/model/SambaTrack.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.offline.model; 2 | 3 | import com.google.android.exoplayer2.offline.TrackKey; 4 | 5 | public class SambaTrack { 6 | 7 | private String title; 8 | private Double sizeInMB; 9 | private TrackKey trackKey; 10 | private int width; 11 | private int height; 12 | private boolean isAudio; 13 | 14 | 15 | 16 | public SambaTrack(String title, Double sizeInMB, TrackKey trackKey, int width, int height) { 17 | this.title = title; 18 | this.sizeInMB = sizeInMB; 19 | this.trackKey = trackKey; 20 | this.width = width; 21 | this.height = height; 22 | } 23 | 24 | public SambaTrack(String title, Double sizeInMB) { 25 | this.title = title; 26 | this.sizeInMB = sizeInMB; 27 | } 28 | 29 | public String getTitle() { 30 | return title; 31 | } 32 | 33 | public void setTitle(String title) { 34 | this.title = title; 35 | } 36 | 37 | public Double getSizeInMB() { 38 | return sizeInMB; 39 | } 40 | 41 | public void setSizeInMB(Double sizeInMB) { 42 | this.sizeInMB = sizeInMB; 43 | } 44 | 45 | public TrackKey getTrackKey() { 46 | return trackKey; 47 | } 48 | 49 | public void setTrackKey(TrackKey trackKey) { 50 | this.trackKey = trackKey; 51 | } 52 | 53 | public boolean isAudio() { 54 | return isAudio; 55 | } 56 | 57 | public void setAudio(boolean audio) { 58 | isAudio = audio; 59 | } 60 | 61 | 62 | public int getWidth() { 63 | return width; 64 | } 65 | 66 | public void setWidth(int width) { 67 | this.width = width; 68 | } 69 | 70 | public int getHeight() { 71 | return height; 72 | } 73 | 74 | public void setHeight(int height) { 75 | this.height = height; 76 | } 77 | 78 | @Override 79 | public String toString() { 80 | return String.format("%s - %.2f MB", title, sizeInMB); 81 | } 82 | 83 | @Override 84 | public boolean equals(Object o) { 85 | if (this == o) return true; 86 | if (!(o instanceof SambaTrack)) return false; 87 | 88 | SambaTrack that = (SambaTrack) o; 89 | 90 | if (width != that.width) return false; 91 | if (height != that.height) return false; 92 | if (isAudio != that.isAudio) return false; 93 | if (title != null ? !title.equals(that.title) : that.title != null) return false; 94 | if (sizeInMB != null ? !sizeInMB.equals(that.sizeInMB) : that.sizeInMB != null) 95 | return false; 96 | 97 | if (trackKey != null) { 98 | if (that.trackKey != null) { 99 | return trackKey.groupIndex == that.trackKey.groupIndex 100 | && trackKey.periodIndex == that.trackKey.periodIndex 101 | && trackKey.trackIndex == that.trackKey.trackIndex; 102 | } else { 103 | return false; 104 | } 105 | } else { 106 | return that.trackKey == null; 107 | } 108 | 109 | } 110 | 111 | @Override 112 | public int hashCode() { 113 | int result = title != null ? title.hashCode() : 0; 114 | result = 31 * result + (sizeInMB != null ? sizeInMB.hashCode() : 0); 115 | result = 31 * result + (trackKey != null ? trackKey.hashCode() : 0); 116 | result = 31 * result + width; 117 | result = 31 * result + height; 118 | result = 31 * result + (isAudio ? 1 : 0); 119 | return result; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/plugins/DrmRequest.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.plugins; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class DrmRequest { 7 | 8 | private String licenseUrl; 9 | private HashMap urlParams = new HashMap<>(); 10 | private HashMap headerParams = new HashMap<>(); 11 | private String token; 12 | private String provider; 13 | private String drmOfflinePayload; 14 | 15 | /** 16 | * @param licenseUrl The URL for the license server. 17 | */ 18 | public DrmRequest(String licenseUrl) { 19 | this.licenseUrl = licenseUrl; 20 | } 21 | 22 | public String getLicenseUrl() { 23 | String params = licenseUrl.contains("?") ? "" : "?"; 24 | String sep = ""; 25 | 26 | for (Map.Entry kv : urlParams.entrySet()) { 27 | params += sep + kv.getKey() + "=" + kv.getValue(); 28 | sep = "&"; 29 | } 30 | 31 | if (token != null && !token.isEmpty()) { 32 | params += "&ls_session=" + token; 33 | } 34 | 35 | return licenseUrl + params; 36 | } 37 | 38 | public HashMap getHeaderParams() { 39 | return headerParams; 40 | } 41 | 42 | public void addLicenseParam(String k, String v) { 43 | urlParams.put(k, v); 44 | } 45 | 46 | public void addHeaderParam(String k, String v) { 47 | headerParams.put(k, v); 48 | } 49 | 50 | public String getLicenseParam(String k) { 51 | return urlParams.get(k); 52 | } 53 | 54 | public String getToken() { 55 | return token; 56 | } 57 | 58 | public void setToken(String token) { 59 | this.token = token; 60 | } 61 | 62 | public String getProvider() { 63 | return provider; 64 | } 65 | 66 | public void setProvider(String provider) { 67 | this.provider = provider; 68 | } 69 | 70 | public String getDrmOfflinePayload() { 71 | return drmOfflinePayload; 72 | } 73 | 74 | public void setDrmOfflinePayload(String drmOfflinePayload) { 75 | this.drmOfflinePayload = drmOfflinePayload; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/plugins/Plugin.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.plugins; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import com.google.android.exoplayer2.ui.SimpleExoPlayerView; 6 | import com.sambatech.player.SambaPlayer; 7 | 8 | /** 9 | * Represents a SambaPlayer plugin. 10 | * 11 | * @author Leandro Zanol - 12/01/2016 12 | */ 13 | interface Plugin { 14 | 15 | /** 16 | * Dispatched when player gets loaded. 17 | * 18 | * @param player Instance of SambaPlayer 19 | */ 20 | void onLoad(@NonNull SambaPlayer player); 21 | 22 | /** 23 | * Dispatched when internal player (GMF) is created. 24 | * 25 | * @param internalPlayer Instance of internal player (GMF) 26 | */ 27 | void onInternalPlayerCreated(@NonNull SimpleExoPlayerView internalPlayer); 28 | 29 | /** 30 | * Dispatched when player gets destroyed. 31 | */ 32 | void onDestroy(); 33 | } 34 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/plugins/PluginManager.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.plugins; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import com.google.android.exoplayer2.ui.SimpleExoPlayerView; 6 | import com.sambatech.player.SambaPlayer; 7 | 8 | /** 9 | * Responsible for managing plugins lifecycle. 10 | * 11 | * @author Leandro Zanol - 12/01/2016 12 | */ 13 | public class PluginManager implements Plugin { 14 | 15 | private static PluginManager instance = new PluginManager(); 16 | 17 | private Plugin[] plugins; 18 | private SambaPlayer player; 19 | private int pluginsLoaded; 20 | private boolean isLoaded; 21 | private boolean pendingPlay; 22 | 23 | private PluginManager() { 24 | } 25 | 26 | public static PluginManager getInstance() { 27 | return instance; 28 | } 29 | 30 | public void onLoad(@NonNull SambaPlayer player) { 31 | this.player = player; 32 | pluginsLoaded = 0; 33 | 34 | plugins = new Plugin[]{ 35 | TrackingFactory.getInstance(this.player.getMedia().isLive), 36 | new Captions() 37 | }; 38 | 39 | for (Plugin plugin : plugins) 40 | plugin.onLoad(player); 41 | } 42 | 43 | public void onInternalPlayerCreated(@NonNull SimpleExoPlayerView internalPlayer) { 44 | if (plugins == null) return; 45 | 46 | for (Plugin plugin : plugins) 47 | plugin.onInternalPlayerCreated(internalPlayer); 48 | } 49 | 50 | public void onDestroy() { 51 | if (plugins == null) return; 52 | 53 | for (Plugin plugin : plugins) 54 | plugin.onDestroy(); 55 | 56 | plugins = null; 57 | } 58 | 59 | public boolean isLoaded() { 60 | return isLoaded; 61 | } 62 | 63 | public void setPendingPlay(boolean value) { 64 | pendingPlay = value; 65 | } 66 | 67 | public Plugin getPlugin(Class PluginRef) { 68 | for (Plugin plugin : plugins) 69 | if (plugin.getClass() == PluginRef) 70 | return plugin; 71 | 72 | return null; 73 | } 74 | 75 | /** 76 | * Notifies plugin load to player. 77 | */ 78 | void notifyPluginLoaded(Plugin plugin) { 79 | if (++pluginsLoaded >= plugins.length) { 80 | isLoaded = true; 81 | 82 | if (pendingPlay) { 83 | pendingPlay = false; 84 | player.play(); 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/plugins/Tracking.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.plugins; 2 | 3 | public interface Tracking extends Plugin { 4 | } 5 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/plugins/TrackingFactory.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.plugins; 2 | 3 | class TrackingFactory { 4 | 5 | public static Tracking getInstance(boolean isLive) { 6 | if (isLive) { 7 | return new TrackingLive(); 8 | } else { 9 | return new TrackingVOD(); 10 | } 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/utils/CastLiveButtonListener.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.utils; 2 | 3 | import android.view.View; 4 | 5 | public interface CastLiveButtonListener { 6 | void onLiveButtonClicked(View view); 7 | } 8 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/utils/ColorCastUtil.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.utils; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.drawable.Drawable; 6 | import android.view.ContextThemeWrapper; 7 | 8 | /** 9 | * Created by andrei on 30/09/16. 10 | */ 11 | 12 | public class ColorCastUtil { 13 | 14 | public static Drawable getMediaRouteButtonDrawable(Context context) { 15 | Context castContext = new ContextThemeWrapper(context, android.support.v7.mediarouter.R.style.Theme_MediaRouter); 16 | 17 | Drawable drawable = null; 18 | TypedArray a = castContext.obtainStyledAttributes(null, 19 | android.support.v7.mediarouter.R.styleable.MediaRouteButton, android.support.v7.mediarouter.R.attr.mediaRouteButtonStyle, 0); 20 | drawable = a.getDrawable( 21 | android.support.v7.mediarouter.R.styleable.MediaRouteButton_externalRouteEnabledDrawable); 22 | a.recycle(); 23 | 24 | return drawable; 25 | } 26 | } -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/utils/Controls.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.utils; 2 | 3 | /** 4 | * Represents all available controls. 5 | * 6 | * NOTE: It could not be an enum because it's needed for aliasing through inheritance. 7 | * 8 | * @author Leandro Zanol - 17/10/17 9 | */ 10 | public class Controls { 11 | public static final String PLAY = "play"; 12 | public static final String PLAY_LARGE = "playLarge"; 13 | public static final String FULLSCREEN = "fullscreen"; 14 | public static final String MENU = "menu"; 15 | public static final String SEEKBAR = "seekbar"; 16 | public static final String TOP_CHROME = "topChrome"; 17 | public static final String BOTTOM_CHROME = "bottomChrome"; 18 | public static final String TIME = "time"; 19 | } 20 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/utils/OptionsMenuController.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.utils; 2 | 3 | public interface OptionsMenuController { 4 | void setHdButtonVisibility(Boolean visibility); 5 | 6 | void setCaptionsButtonVisibility(Boolean visibility); 7 | 8 | void setSpeedButtonVisibility(Boolean visibility); 9 | 10 | void showMenu(); 11 | 12 | void hideMenu(); 13 | 14 | OptionsMenuLayer.OptionsMenuCallback getCallback(); 15 | 16 | void setCallback(OptionsMenuLayer.OptionsMenuCallback callback); 17 | 18 | void bringToFront(); 19 | 20 | boolean isVisible(); 21 | } 22 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/utils/OptionsMenuLayer.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.utils; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.FrameLayout; 9 | import android.widget.ImageButton; 10 | import android.widget.LinearLayout; 11 | 12 | import com.sambatech.player.R; 13 | 14 | /** 15 | * Created by luizbyrro on 08/11/17. 16 | */ 17 | 18 | public class OptionsMenuLayer extends FrameLayout implements View.OnClickListener, OptionsMenuController{ 19 | 20 | private LinearLayout hdButton; 21 | private LinearLayout captionsButton; 22 | private LinearLayout speedButton; 23 | private ImageButton closeButton; 24 | private ViewGroup parentView; 25 | private OptionsMenuCallback callback; 26 | 27 | 28 | public OptionsMenuLayer(Context context, ViewGroup parentView) { 29 | this(context, parentView, null); 30 | } 31 | 32 | public OptionsMenuLayer(Context context, ViewGroup parentView, AttributeSet attrs) { 33 | this(context, parentView, attrs, 0); 34 | } 35 | 36 | public OptionsMenuLayer(Context context, ViewGroup parentView, AttributeSet attrs, int defStyleAttr) { 37 | super(context, attrs, defStyleAttr); 38 | LayoutInflater.from(context).inflate(R.layout.menu_options_layer, this); 39 | this.parentView = parentView; 40 | hdButton = (LinearLayout) findViewById(R.id.quality_button); 41 | captionsButton = (LinearLayout) findViewById(R.id.subtitle_button); 42 | speedButton = (LinearLayout) findViewById(R.id.speed_button); 43 | closeButton = (ImageButton) findViewById(R.id.close_menu_button); 44 | hdButton.setOnClickListener(this); 45 | captionsButton.setOnClickListener(this); 46 | speedButton.setOnClickListener(this); 47 | closeButton.setOnClickListener(this); 48 | setVisibility(View.GONE); 49 | } 50 | 51 | @Override 52 | public void onClick(View v) { 53 | if (callback == null) return; 54 | int i = v.getId(); 55 | if (i == R.id.quality_button) { 56 | callback.onTouchHD(); 57 | } else if (i == R.id.subtitle_button) { 58 | callback.onTouchCaptions(); 59 | } else if (i == R.id.speed_button) { 60 | callback.onTouchSpeed(); 61 | } else if (i == R.id.close_menu_button) { 62 | hideMenu(); 63 | callback.onMenuDismiss(); 64 | } 65 | } 66 | 67 | @Override 68 | public void setHdButtonVisibility(Boolean visibility){ 69 | if (hdButton == null) return; 70 | hdButton.setVisibility(visibility ? View.VISIBLE : View.GONE); 71 | } 72 | 73 | @Override 74 | public void setCaptionsButtonVisibility(Boolean visibility){ 75 | if (captionsButton == null) return; 76 | captionsButton.setVisibility(visibility ? View.VISIBLE : View.GONE); 77 | } 78 | 79 | @Override 80 | public void setSpeedButtonVisibility(Boolean visibility){ 81 | if (speedButton == null) return; 82 | speedButton.setVisibility(visibility ? View.VISIBLE : View.GONE); 83 | } 84 | 85 | @Override 86 | public void showMenu() { 87 | setVisibility(View.VISIBLE); 88 | bringToFront(); 89 | } 90 | 91 | @Override 92 | public void hideMenu() { 93 | setVisibility(View.GONE); 94 | } 95 | 96 | @Override 97 | public OptionsMenuCallback getCallback() { 98 | return callback; 99 | } 100 | 101 | @Override 102 | public void setCallback(OptionsMenuCallback callback) { 103 | this.callback = callback; 104 | } 105 | 106 | @Override 107 | public void bringToFront() { 108 | parentView.bringChildToFront(this); 109 | } 110 | 111 | @Override 112 | public boolean isVisible() { 113 | return getVisibility() == View.VISIBLE; 114 | } 115 | 116 | public interface OptionsMenuCallback { 117 | void onTouchHD(); 118 | void onTouchCaptions(); 119 | void onTouchSpeed(); 120 | void onMenuDismiss(); 121 | } 122 | } 123 | 124 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/utils/Orientation.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.utils; 2 | 3 | /** 4 | * Created by luizbyrro on 05/12/2017. 5 | */ 6 | 7 | public class Orientation { 8 | 9 | public static final int INVALID = -1; 10 | public static final int PORTRAIT = 0; 11 | public static final int LANDSCAPE = 270; 12 | public static final int REVERSE_PORTRAIT = 180; 13 | public static final int REVERSE_LANDSCAPE = 90; 14 | private static final int DEFAULT_THRESHOLD = 40; 15 | 16 | private int treshold; 17 | 18 | public Orientation() { 19 | this(DEFAULT_THRESHOLD); 20 | } 21 | 22 | public Orientation(int treshold) { 23 | this.treshold = treshold; 24 | } 25 | 26 | public int getMeasuredOrientation(int orientation) { 27 | if(orientation >= 360 + PORTRAIT - treshold && orientation < 360 || orientation >= 0 && orientation <= PORTRAIT + treshold) 28 | return PORTRAIT; 29 | else if(orientation >= LANDSCAPE - treshold && orientation <= LANDSCAPE + treshold) 30 | return LANDSCAPE; 31 | else if(orientation >= REVERSE_PORTRAIT - treshold && orientation <= REVERSE_PORTRAIT + treshold) 32 | return REVERSE_PORTRAIT; 33 | else if(orientation >= REVERSE_LANDSCAPE - treshold && orientation <= REVERSE_LANDSCAPE + treshold) 34 | return REVERSE_LANDSCAPE; 35 | else return INVALID; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/utils/SharedPrefsUtils.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player.utils; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.preference.PreferenceManager; 6 | import android.text.TextUtils; 7 | 8 | final public class SharedPrefsUtils { 9 | 10 | public class SharedPrefsKeys { 11 | public static final String MEDIA_CASTING_KEY = "MEDIA_CASTING_KEY"; 12 | public static final String PLAYER_STATUS = "PLAYER_STATUS"; 13 | } 14 | 15 | private SharedPrefsUtils() {} 16 | 17 | public static String getStringPreference(Context context, String key) { 18 | String value = null; 19 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); 20 | if (preferences != null) { 21 | value = preferences.getString(key, null); 22 | } 23 | return value; 24 | } 25 | 26 | public static boolean setStringPreference(Context context, String key, String value) { 27 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); 28 | if (preferences != null && !TextUtils.isEmpty(key)) { 29 | SharedPreferences.Editor editor = preferences.edit(); 30 | editor.putString(key, value); 31 | return editor.commit(); 32 | } 33 | return false; 34 | } 35 | 36 | 37 | public static void clearPreferenceByKey(Context context, String key) { 38 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); 39 | if (preferences != null) { 40 | SharedPreferences.Editor editor = preferences.edit(); 41 | editor.remove(key); 42 | editor.commit(); 43 | } 44 | } 45 | 46 | public static boolean setBooleanPreference(Context context, String key, boolean value) { 47 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); 48 | if (preferences != null && !TextUtils.isEmpty(key)) { 49 | SharedPreferences.Editor editor = preferences.edit(); 50 | editor.putBoolean(key, value); 51 | return editor.commit(); 52 | } 53 | return false; 54 | } 55 | 56 | public static boolean getBooleanPreference(Context context, String key) { 57 | boolean value = false; 58 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); 59 | if (preferences != null) { 60 | value = preferences.getBoolean(key, false); 61 | } 62 | return value; 63 | } 64 | } -------------------------------------------------------------------------------- /sambaplayersdk/src/main/java/com/sambatech/player/utils/Util.java: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright 2014 Google Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.sambatech.player.utils; 18 | 19 | import android.view.View; 20 | import android.view.ViewGroup; 21 | import android.view.ViewParent; 22 | import android.widget.FrameLayout; 23 | import android.widget.LinearLayout; 24 | import android.widget.RelativeLayout; 25 | 26 | 27 | /** 28 | * Contains utility functions which are used by a number of other classes. 29 | */ 30 | public class Util { 31 | 32 | /** 33 | * Create a LayoutParams object for the given view which enforces a given width and height. 34 | * 35 | *

This method is a bit complicated because the TYPE of the LayoutParams that a view must 36 | * receive (ex. LinearLayout.LayoutParams, RelativeLayout.LayoutParams) depends on the type of its 37 | * PARENT view. 38 | * 39 | *

Thus, in this method, we look at the parent view of the given view, determine its type, 40 | * and create the appropriate LayoutParams for that type. 41 | * 42 | *

This method only supports views which are nested inside a FrameLayout, LinearLayout, or 43 | * GridLayout. 44 | */ 45 | public static ViewGroup.LayoutParams getLayoutParamsBasedOnParent(View view, int width, int height) 46 | throws IllegalArgumentException { 47 | 48 | // Get the parent of the given view. 49 | ViewParent parent = view.getParent(); 50 | 51 | // Determine what is the parent's type and return the appropriate type of LayoutParams. 52 | if (parent instanceof FrameLayout) { 53 | return new FrameLayout.LayoutParams(width, height); 54 | } 55 | if (parent instanceof RelativeLayout) { 56 | return new RelativeLayout.LayoutParams(width, height); 57 | } 58 | if (parent instanceof LinearLayout) { 59 | return new LinearLayout.LayoutParams(width, height); 60 | } 61 | 62 | // Throw this exception if the parent is not the correct type. 63 | IllegalArgumentException exception = new IllegalArgumentException("The PARENT of a " + 64 | "FrameLayout container used by the GoogleMediaFramework must be a LinearLayout, " + 65 | "FrameLayout, or RelativeLayout. Please ensure that the container is inside one of these " + 66 | "three supported view groups."); 67 | 68 | // If the parent is not one of the supported types, throw our exception. 69 | throw exception; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_caption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_caption.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_close.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_hd_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_hd_active.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_live.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_live.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_menu.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_retry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_retry.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_speed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-hdpi/sambaplayer_ic_speed.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_caption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_caption.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_close.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_hd_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_hd_active.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_live.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_live.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_menu.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_retry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_retry.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_speed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-mdpi/sambaplayer_ic_speed.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_caption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_caption.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_close.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_hd_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_hd_active.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_live.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_live.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_menu.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_retry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_retry.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_speed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xhdpi/sambaplayer_ic_speed.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_caption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_caption.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_close.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_hd_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_hd_active.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_live.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_live.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_menu.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_retry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_retry.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_speed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xxhdpi/sambaplayer_ic_speed.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xxxhdpi/sambaplayer_ic_caption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xxxhdpi/sambaplayer_ic_caption.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xxxhdpi/sambaplayer_ic_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xxxhdpi/sambaplayer_ic_close.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xxxhdpi/sambaplayer_ic_hd_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xxxhdpi/sambaplayer_ic_hd_active.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xxxhdpi/sambaplayer_ic_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xxxhdpi/sambaplayer_ic_menu.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable-xxxhdpi/sambaplayer_ic_speed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sambaplayersdk/src/main/res/drawable-xxxhdpi/sambaplayer_ic_speed.png -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/controls_bottom_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/controls_top_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/exo_controls_pause.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/exo_controls_play.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/gradient_audio_thumb_mask.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/sambaplayer_cast_connected.xml: -------------------------------------------------------------------------------- 1 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/sambaplayer_cast_unconnected.xml: -------------------------------------------------------------------------------- 1 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/sambaplayer_empty_divider.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/sambaplayer_error_icon.xml: -------------------------------------------------------------------------------- 1 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/sambaplayer_ic_cast.xml: -------------------------------------------------------------------------------- 1 | 3 | 5 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/sambaplayer_ic_fullscreen.xml: -------------------------------------------------------------------------------- 1 | 6 | 43 | 44 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/sambaplayer_ic_fullscreen_exit.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/drawable/sambaplayer_ic_nosignal.xml: -------------------------------------------------------------------------------- 1 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/layout/action_sheet.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 19 | 20 | 30 | 31 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/layout/action_sheet_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 24 | 25 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/layout/cast_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/layout/custom_simple_exo_player_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/layout/error_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 17 | 18 | 28 | 29 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/layout/exo_simple_player_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 19 | 20 | 21 | 22 | 25 | 26 | 30 | 31 | 34 | 35 | 36 | 37 | 40 | 41 | 44 | 45 | 48 | 49 | 53 | 54 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/layout/menu_options_layer.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | 24 | 25 | 31 | 32 | 40 | 41 | 42 | 43 | 49 | 50 | 56 | 57 | 65 | 66 | 67 | 68 | 74 | 75 | 81 | 82 | 90 | 91 | 92 | 93 | 94 | 95 | 103 | 104 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/layout/start_download_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 20 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | #88000000 20 | #999999 21 | #FFFFFF 22 | #E6E6E6 23 | #88FFFFFF 24 | #80000000 25 | #8C000000 26 | #8C000000 27 | 28 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SambaPlayer SDK 3 | https://fast.player.liquidplatform.com/pApiv2/v1/ 4 | https://staging-player-api.sambavideos.sambatech.com/v3/v1/ 5 | http://web1.qa.sambatech.com:13000/v1/ 6 | http://192.168.0.127:8080/player-api/v1/ 7 | AO VIVO 8 | Legendas 9 | Velocidade 10 | 51DEA4E2 11 | 4D431E24 12 | E9CFA23D 13 | player.sambatech.com.br/v3_dev/ 14 | player.sambatech.com.br/v3_staging/ 15 | player.sambatech.com.br/v3/ 16 | qflr83g17rvhppsq01ka 17 | 18 | Select an action… 19 | Overflow 20 | Fullscreen 21 | Duration 22 | Seekbar 23 | Current time 24 | Pause 25 | Logo image 26 | / 27 | 00:00 28 | Qualidade 29 | 240p 30 | Português (Brasil) 31 | Cancelar 32 | Sem Legendas 33 | Auto 34 | 35 | -------------------------------------------------------------------------------- /sambaplayersdk/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 22 | 23 | 27 | 28 | 33 | 34 | 41 | 42 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /sambaplayersdk/src/test/java/com/sambatech/playersdk/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.player; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion '28.0.3' 6 | 7 | defaultConfig { 8 | minSdkVersion 17 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName '1.0' 12 | multiDexEnabled true 13 | } 14 | 15 | compileOptions { 16 | sourceCompatibility JavaVersion.VERSION_1_8 17 | targetCompatibility JavaVersion.VERSION_1_8 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 24 | } 25 | debug { 26 | minifyEnabled false 27 | } 28 | } 29 | productFlavors { 30 | } 31 | } 32 | 33 | repositories { 34 | mavenCentral() 35 | } 36 | 37 | dependencies { 38 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 39 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' 40 | 41 | //compile fileTree(dir: 'libs', include: ['*.jar']) 42 | 43 | // DEV 44 | // compile project(':sambaplayersdk') 45 | 46 | // PROD 47 | compile 'io.github.sambatech:player_sdk_android:0.15.0' 48 | 49 | implementation 'org.bitbucket.b_c:jose4j:0.6.3' 50 | implementation 'com.mcxiaoke.volley:library:1.0.19' 51 | implementation 'de.greenrobot:eventbus:2.4.0' 52 | implementation 'com.squareup.retrofit:retrofit:2.0.0-beta2' 53 | implementation 'com.squareup.retrofit:converter-gson:2.0.0-beta2' 54 | implementation 'com.squareup.okhttp:logging-interceptor:2.6.0' 55 | implementation 'com.jakewharton:butterknife:8.8.1' 56 | implementation 'com.android.support:multidex:1.0.3' 57 | } 58 | -------------------------------------------------------------------------------- /sample/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the ProGuard 5 | # include property in project.properties. 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 | #} -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 31 | 35 | 38 | 39 | 42 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /sample/src/main/ic_sambabee-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/ic_sambabee-web.png -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample; 2 | 3 | import android.content.Context; 4 | import android.support.multidex.MultiDexApplication; 5 | 6 | import com.sambatech.player.offline.SambaDownloadManager; 7 | import com.sambatech.sample.utils.Helpers; 8 | 9 | public class MainApplication extends MultiDexApplication { 10 | private static MainApplication _instance; 11 | private static String _externalIp = ""; 12 | 13 | @Override 14 | public void onCreate() { 15 | super.onCreate(); 16 | 17 | _instance = this; 18 | 19 | loadExternalIp(); 20 | 21 | SambaDownloadManager.getInstance().init(this); 22 | } 23 | 24 | public static Context getAppContext() { 25 | return _instance.getApplicationContext(); 26 | } 27 | 28 | public static String getExternalIp() { 29 | return _externalIp; 30 | } 31 | 32 | private void loadExternalIp() { 33 | Helpers.requestUrl("https://api.ipify.org", new Helpers.Callback() { 34 | @Override 35 | public void call(String response) { 36 | if (response == null) return; 37 | _externalIp = response.trim(); 38 | } 39 | }); 40 | } 41 | } -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/activities/AboutActivity.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample.activities; 2 | 3 | import android.os.Bundle; 4 | import android.app.Activity; 5 | 6 | import com.sambatech.sample.R; 7 | 8 | public class AboutActivity extends Activity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_about); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/activities/PrepareActivity.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample.activities; 2 | 3 | import android.app.Activity; 4 | import android.app.Dialog; 5 | import android.content.Intent; 6 | import android.util.Log; 7 | 8 | import com.google.android.gms.common.ConnectionResult; 9 | import com.google.android.gms.common.GoogleApiAvailability; 10 | 11 | /** 12 | * Activity to prepare the environment to run the app. 13 | * @author zanol on 5/23/17 14 | */ 15 | public final class PrepareActivity extends Activity { 16 | 17 | private static final String TAG = "PrepareActivity"; 18 | 19 | @Override 20 | protected void onResume() { 21 | super.onResume(); 22 | checkAndUpdateGPSIfNeeded(); 23 | } 24 | 25 | /** 26 | * Verify whether Google Play Services (GPS) is up-to-date or try to update it otherwise. 27 | */ 28 | private void checkAndUpdateGPSIfNeeded() { 29 | GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); 30 | int status = apiAvailability.isGooglePlayServicesAvailable(this); 31 | 32 | Log.i(TAG, "checkAndUpdateGPSIfNeeded: " + apiAvailability.getErrorString(status)); 33 | 34 | if (status == ConnectionResult.SUCCESS) { 35 | startActivity(new Intent(PrepareActivity.this, MainActivity.class)); 36 | finish(); 37 | return; 38 | } 39 | 40 | // update GPS to latest version 41 | Dialog errorDialog = apiAvailability.getErrorDialog(this, status, 0); 42 | errorDialog.setCancelable(false); 43 | errorDialog.show(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/adapters/MediasAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample.adapters; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.BaseAdapter; 9 | import android.widget.TextView; 10 | 11 | import com.android.volley.toolbox.ImageLoader; 12 | import com.android.volley.toolbox.NetworkImageView; 13 | import com.sambatech.sample.R; 14 | import com.sambatech.sample.model.MediaInfo; 15 | import com.sambatech.sample.utils.VolleySingleton; 16 | 17 | import java.util.List; 18 | 19 | import butterknife.BindView; 20 | import butterknife.ButterKnife; 21 | 22 | /** 23 | * Created by tmiranda on 11/01/16. 24 | * 25 | * Adapter class to list each media item 26 | */ 27 | public class MediasAdapter extends BaseAdapter { 28 | 29 | private List mediaList; 30 | private LayoutInflater inflater; 31 | 32 | public MediasAdapter(Context mContext, List mList) { 33 | mediaList = mList; 34 | inflater = (LayoutInflater) mContext 35 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 36 | } 37 | 38 | @Override 39 | public int getCount() { 40 | return mediaList.size(); 41 | } 42 | 43 | @Override 44 | public Object getItem(int position) { 45 | return mediaList.get(position); 46 | } 47 | 48 | @Override 49 | public long getItemId(int position) { 50 | return 0; 51 | } 52 | 53 | @Override 54 | public int getViewTypeCount() { 55 | return getCount() > 0 ? getCount() : 1; 56 | } 57 | 58 | @Override 59 | public int getItemViewType(int position) { 60 | return position; 61 | } 62 | 63 | @Override 64 | public View getView(final int position, View view, ViewGroup viewGroup) { 65 | if (view == null) { 66 | final View customView = inflater.inflate(R.layout.media_list_item, viewGroup, false); 67 | final MediaItem holder = new MediaItem(customView); 68 | final MediaInfo media = (MediaInfo) getItem(position); 69 | final ImageLoader mImageLoader = VolleySingleton.getInstance().getImageLoader(); 70 | 71 | // if there's any thumb 72 | if (media.getThumbnail() != null) 73 | holder.thumb.setImageUrl(media.getThumbnail(), mImageLoader); 74 | // audio 75 | else if ("audio".equalsIgnoreCase(media.getQualifier())) 76 | holder.thumb.setImageUrl("https://cdn3.iconfinder.com/data/icons/buttons-1/512/Notes.png", mImageLoader); 77 | 78 | holder.title.setText(media.getTitle() != null ? media.getTitle().split("\\.", 2)[0] : ""); 79 | holder.description.setText(media.getDescription() != null ? media.getDescription() : ""); 80 | 81 | final boolean odd = (position & 1) == 1; 82 | 83 | // colors 84 | switch (media.getEnvironment()) { 85 | case PROD: 86 | customView.setBackgroundColor(Color.parseColor(odd ? "#eeffee" : "#ddffdd")); 87 | break; 88 | case STAGING: 89 | customView.setBackgroundColor(Color.parseColor(odd ? "#ddeeff" : "#ccddff")); 90 | break; 91 | case DEV: 92 | customView.setBackgroundColor(Color.parseColor(odd ? "#ffeeee" : "#ffdddd")); 93 | break; 94 | case LOCAL: 95 | default: 96 | customView.setBackgroundColor(Color.parseColor(odd ? "#eeeeee" : "#ffffff")); 97 | break; 98 | } 99 | 100 | customView.setTag(holder); 101 | 102 | return customView; 103 | } 104 | 105 | return view; 106 | } 107 | 108 | static class MediaItem { 109 | @BindView(R.id.thumbPreview) 110 | NetworkImageView thumb; 111 | 112 | @BindView(R.id.titlePreview) 113 | TextView title; 114 | 115 | @BindView(R.id.description) 116 | TextView description; 117 | 118 | String mediaID; 119 | 120 | String drmToken; 121 | 122 | MediaItem(View view) { 123 | ButterKnife.bind(this, view); 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/model/EntitlementScheme.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample.model; 2 | 3 | /** 4 | * @author Leandro Zanol - 16/10/17 5 | */ 6 | public final class EntitlementScheme { 7 | 8 | /** 9 | * The DRM content ID 10 | */ 11 | public final String contentId; 12 | 13 | public EntitlementScheme() { 14 | this(null); 15 | } 16 | 17 | public EntitlementScheme(String contentId) { 18 | this.contentId = contentId; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/model/JSONMedia.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by tmiranda on 07/01/16. 7 | */ 8 | public class JSONMedia implements Serializable { 9 | 10 | public String projectHash; 11 | public String mediaId; 12 | public String thumbURL; 13 | public Long duration; 14 | public String title; 15 | 16 | public String getProjectHash() { 17 | return projectHash; 18 | } 19 | 20 | public void setProjectHash(String projectHash) { 21 | this.projectHash = projectHash; 22 | } 23 | 24 | public String getMediaId() { 25 | return mediaId; 26 | } 27 | 28 | public void setMediaId(String mediaId) { 29 | this.mediaId = mediaId; 30 | } 31 | 32 | public String getThumbURL() { 33 | return thumbURL; 34 | } 35 | 36 | public void setThumbURL(String thumbURL) { 37 | this.thumbURL = thumbURL; 38 | } 39 | 40 | public Long getDuration() { 41 | return duration; 42 | } 43 | 44 | public void setDuration(Long duration) { 45 | this.duration = duration; 46 | } 47 | 48 | public String getTitle() { 49 | return title; 50 | } 51 | 52 | public void setTitle(String title) { 53 | this.title = title; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/model/OnMediaClickListener.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample.model; 2 | 3 | import android.view.View; 4 | 5 | public interface OnMediaClickListener { 6 | 7 | public void onMediaClicked(MediaInfo mediaInfo, View ciew); 8 | public void onDownloadButtonClicked(MediaInfo mediaInfo, View view); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/rest/ILiquidApi.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample.rest; 2 | 3 | import com.sambatech.sample.model.LiquidMedia; 4 | 5 | import java.util.ArrayList; 6 | 7 | import retrofit.Call; 8 | import retrofit.http.GET; 9 | import retrofit.http.Headers; 10 | import retrofit.http.Query; 11 | 12 | 13 | /** 14 | * @author Thiago Miranda - 11/01/16 15 | */ 16 | public interface ILiquidApi { 17 | 18 | @Headers({ 19 | "Content-type: application/json" 20 | }) 21 | 22 | @GET("medias") 23 | Call> getMedias(@Query("cat_id") int categoryId); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/rest/LiquidApi.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample.rest; 2 | 3 | import com.squareup.okhttp.OkHttpClient; 4 | import com.squareup.okhttp.logging.HttpLoggingInterceptor; 5 | 6 | import retrofit.GsonConverterFactory; 7 | import retrofit.Retrofit; 8 | 9 | /** 10 | * Created by tmiranda on 11/01/16. 11 | */ 12 | public class LiquidApi { 13 | 14 | static public ILiquidApi getApi(String endpoint) { 15 | 16 | HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); 17 | logging.setLevel(HttpLoggingInterceptor.Level.HEADERS); 18 | 19 | OkHttpClient httpClient = new OkHttpClient(); 20 | 21 | httpClient.interceptors().add(logging); 22 | 23 | Retrofit retrofit = new Retrofit.Builder() 24 | .baseUrl(endpoint) 25 | .addConverterFactory(GsonConverterFactory.create()) 26 | .client(httpClient) 27 | .build(); 28 | 29 | return retrofit.create(ILiquidApi.class); 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/utils/GsonRequest.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample.utils; 2 | 3 | import android.util.Log; 4 | 5 | import com.android.volley.AuthFailureError; 6 | import com.android.volley.NetworkResponse; 7 | import com.android.volley.ParseError; 8 | import com.android.volley.Request; 9 | import com.android.volley.Response; 10 | import com.android.volley.toolbox.HttpHeaderParser; 11 | import com.google.gson.Gson; 12 | import com.google.gson.JsonSyntaxException; 13 | 14 | import java.io.UnsupportedEncodingException; 15 | import java.util.Map; 16 | 17 | public class GsonRequest extends Request { 18 | private final Gson gson = new Gson(); 19 | private final Class clazz; 20 | private final Map headers; 21 | private final Response.Listener listener; 22 | 23 | /** 24 | * Make a GET request and return a parsed object from JSON. 25 | * 26 | * @param url URL of the request to make 27 | * @param clazz Relevant class object, for Gson's reflection 28 | * @param headers Map of request headers 29 | */ 30 | public GsonRequest(String url, Class clazz, Map headers, 31 | Response.Listener listener, Response.ErrorListener errorListener) { 32 | super(Method.GET, url, errorListener); 33 | this.clazz = clazz; 34 | this.headers = headers; 35 | this.listener = listener; 36 | } 37 | 38 | @Override 39 | public Map getHeaders() throws AuthFailureError { 40 | return headers != null ? headers : super.getHeaders(); 41 | } 42 | 43 | @Override 44 | protected void deliverResponse(T response) { 45 | listener.onResponse(response); 46 | } 47 | 48 | @Override 49 | protected Response parseNetworkResponse(NetworkResponse response) { 50 | try { 51 | String json = new String( 52 | response.data, 53 | HttpHeaderParser.parseCharset(response.headers)); 54 | 55 | return Response.success( 56 | gson.fromJson(json, clazz), 57 | HttpHeaderParser.parseCacheHeaders(response)); 58 | } catch (UnsupportedEncodingException e) { 59 | return Response.error(new ParseError(e)); 60 | } catch (JsonSyntaxException e) { 61 | return Response.error(new ParseError(e)); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/utils/Helpers.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample.utils; 2 | 3 | import android.os.AsyncTask; 4 | 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.net.HttpURLConnection; 8 | import java.net.URL; 9 | import java.util.Scanner; 10 | 11 | /** 12 | * @author zanol - 11/8/16 13 | */ 14 | public class Helpers { 15 | 16 | public static void requestUrl(String url, Callback callback) { 17 | try { 18 | requestUrl((HttpURLConnection)new URL(url).openConnection(), callback); 19 | } 20 | catch (IOException e) { 21 | e.printStackTrace(); 22 | } 23 | } 24 | 25 | public static void requestUrl(HttpURLConnection con, final Callback callback) { 26 | new AsyncTask() { 27 | @Override 28 | protected String doInBackground(HttpURLConnection... params) { 29 | HttpURLConnection con = params[0]; 30 | InputStream inputStream = null; 31 | Scanner scanner = null; 32 | Scanner scannerDelimited = null; 33 | 34 | try { 35 | con.connect(); 36 | 37 | /*System.out.println("Request method: " + con.getRequestMethod()); 38 | System.out.println("Permission: " + con.getPermission()); 39 | System.out.println("Response code: " + con.getResponseCode()); 40 | System.out.println("Response msg: " + con.getResponseMessage()); 41 | 42 | s = ""; 43 | for (Map.Entry> kv : con.getHeaderFields().entrySet()) 44 | s += kv.getKey() + ": " + kv.getValue() + "\n"; 45 | System.out.println(s);*/ 46 | 47 | inputStream = con.getInputStream(); 48 | scanner = new Scanner(inputStream); 49 | scannerDelimited = scanner.useDelimiter("\\A"); 50 | 51 | return scannerDelimited.hasNext() ? scannerDelimited.next() : ""; 52 | } 53 | catch (Exception e) { 54 | e.printStackTrace(); 55 | } 56 | finally { 57 | try { 58 | if (con != null) con.disconnect(); 59 | if (inputStream != null) inputStream.close(); 60 | if (scanner != null) scanner.close(); 61 | if (scannerDelimited != null) scannerDelimited.close(); 62 | } 63 | catch (Exception e) { 64 | e.printStackTrace(); 65 | } 66 | } 67 | 68 | return null; 69 | } 70 | 71 | @Override 72 | protected void onPostExecute(String s) { 73 | callback.call(s); 74 | } 75 | }.execute(con); 76 | } 77 | 78 | public interface Callback { 79 | void call(String response); 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/utils/ItemClickEvent.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample.utils; 2 | 3 | import com.sambatech.sample.model.LiquidMedia; 4 | 5 | /** 6 | * Created by tmiranda on 19/04/16. 7 | */ 8 | public class ItemClickEvent { 9 | public final String type; 10 | public final LiquidMedia media; 11 | 12 | public ItemClickEvent(String type, LiquidMedia media) { 13 | this.type = type; 14 | this.media = media; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sample/src/main/java/com/sambatech/sample/utils/VolleySingleton.java: -------------------------------------------------------------------------------- 1 | package com.sambatech.sample.utils; 2 | 3 | import android.graphics.Bitmap; 4 | import android.support.v4.util.LruCache; 5 | 6 | import com.android.volley.RequestQueue; 7 | import com.android.volley.toolbox.ImageLoader; 8 | import com.android.volley.toolbox.Volley; 9 | import com.sambatech.sample.MainApplication; 10 | 11 | public class VolleySingleton { 12 | private static VolleySingleton mInstance = null; 13 | private RequestQueue mRequestQueue; 14 | private ImageLoader mImageLoader; 15 | 16 | private VolleySingleton(){ 17 | mRequestQueue = Volley.newRequestQueue(MainApplication.getAppContext()); 18 | mImageLoader = new ImageLoader(this.mRequestQueue, new ImageLoader.ImageCache() { 19 | private final LruCache mCache = new LruCache(10); 20 | public void putBitmap(String url, Bitmap bitmap) { 21 | mCache.put(url, bitmap); 22 | } 23 | public Bitmap getBitmap(String url) { 24 | return mCache.get(url); 25 | } 26 | }); 27 | } 28 | 29 | public static VolleySingleton getInstance(){ 30 | if(mInstance == null){ 31 | mInstance = new VolleySingleton(); 32 | } 33 | return mInstance; 34 | } 35 | 36 | public RequestQueue getRequestQueue(){ 37 | return this.mRequestQueue; 38 | } 39 | 40 | public ImageLoader getImageLoader(){ 41 | return this.mImageLoader; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_abelha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-hdpi/ic_abelha.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_action_discard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-hdpi/ic_action_discard.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_action_favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-hdpi/ic_action_favorite.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_action_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-hdpi/ic_action_share.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-hdpi/ic_arrow.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_audio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-hdpi/ic_audio.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_dbclick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-hdpi/ic_dbclick.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_dbclick_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-hdpi/ic_dbclick_disable.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-hdpi/ic_download.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_download_done.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-hdpi/ic_download_done.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-hdpi/ic_plus.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_plus_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-hdpi/ic_plus_white.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_abelha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-mdpi/ic_abelha.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_action_discard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-mdpi/ic_action_discard.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_action_favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-mdpi/ic_action_favorite.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_action_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-mdpi/ic_action_share.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-mdpi/ic_arrow.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_audio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-mdpi/ic_audio.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_dbclick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-mdpi/ic_dbclick.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_dbclick_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-mdpi/ic_dbclick_disable.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-mdpi/ic_download.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_download_done.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-mdpi/ic_download_done.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-mdpi/ic_plus.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_plus_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-mdpi/ic_plus_white.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_abelha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xhdpi/ic_abelha.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_action_discard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xhdpi/ic_action_discard.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_action_favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xhdpi/ic_action_favorite.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_action_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xhdpi/ic_action_share.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xhdpi/ic_arrow.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_audio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xhdpi/ic_audio.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_dbclick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xhdpi/ic_dbclick.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_dbclick_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xhdpi/ic_dbclick_disable.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xhdpi/ic_download.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_download_done.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xhdpi/ic_download_done.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xhdpi/ic_plus.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_plus_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xhdpi/ic_plus_white.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_abelha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxhdpi/ic_abelha.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_action_discard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxhdpi/ic_action_discard.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_action_favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxhdpi/ic_action_favorite.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_action_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxhdpi/ic_action_share.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxhdpi/ic_arrow.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_audio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxhdpi/ic_audio.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_dbclick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxhdpi/ic_dbclick.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_dbclick_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxhdpi/ic_dbclick_disable.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxhdpi/ic_download.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_download_done.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxhdpi/ic_download_done.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxhdpi/ic_plus.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_plus_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxhdpi/ic_plus_white.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxxhdpi/ic_download.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_download_done.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/drawable-xxxhdpi/ic_download_done.png -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 20 | 21 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 21 | 22 | 27 | 28 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_offline.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 16 | 17 | 18 | 25 | 26 | 33 | 34 | 39 | 40 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/media_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 15 | 16 | 20 | 21 | 32 | 33 | 43 | 44 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/media_offline_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 22 | 23 | 35 | 36 | 43 | 44 | 52 | 53 | 65 | 66 | 67 | 68 | 69 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /sample/src/main/res/menu/main_menu.xml: -------------------------------------------------------------------------------- 1 |

3 | 4 | 8 | 9 | 13 | 14 | 18 | 19 | 23 | 24 | 28 | 29 | 34 | 35 | 41 | -------------------------------------------------------------------------------- /sample/src/main/res/menu/offline_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 13 | 14 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sambatech/player_sdk_android/8d793637791e4163dddc123adace9f273a52513b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 22 | 64dp 23 | 24 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | #C83B5998 20 | #C800F000 21 | #000000 22 | #DDDDDD 23 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 16dp 21 | 16dp 22 | 23 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | SBPlayer 4 | 5 | http://api.sambavideos.sambatech.com/v1/ 6 | http://staging.sambavideos.sambatech.com/v1/ 7 | http://web1.qa.sambatech.com:10000/v1/ 8 | ec8f5393-8e54-4ef2-842e-3f6cf0ea6287 9 | 08008acb-c9b8-4452-af78-2d36d83db640 10 | http://sambatech.live.ott.irdeto.com/ 11 | http://playerground.sambatech.com/v1/liquid/medias 12 | Ad Tags 13 | VOD 14 | Live 15 | Sobre 16 | Media Item 17 | MainMenu 18 | SplashActivity 19 | AboutActivity 20 | Sample App criada pelo time do Player da Sambatech - Leandro Zanol, Priscila Magalhães e Thiago Miranda 21 | Carregando listagem… 22 | MenuActivity 23 | All 24 | Prod 25 | Staging 26 | QA 27 | Offline 28 | Pausar todos Downloads 29 | Reiniciar todos Downloads 30 | 31 | 32 | Aluguel 48h (p5) 33 | Ass. mensal (p6) 34 | Aluguel 48h/BR (p7) 35 | Ass. mensal/BR (p8) 36 | 37 | 38 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /sample/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | fast.player.liquidplatform.com 5 | sambatech.com 6 | sambatech.com.br 7 | akamaized.net 8 | 127.0.0.1 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /scripts/publish-mavencentral.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven-publish' 2 | apply plugin: 'signing' 3 | apply plugin: 'com.android.library' 4 | 5 | task androidSourcesJar(type: Jar) { 6 | archiveClassifier.set('sources') 7 | from android.sourceSets.main.java.srcDirs 8 | } 9 | 10 | artifacts { 11 | archives androidSourcesJar 12 | } 13 | 14 | group = PUBLISH_GROUP_ID 15 | version = PUBLISH_VERSION 16 | 17 | ext["signing.keyId"] = '' 18 | ext["signing.password"] = '' 19 | ext["signing.secretKeyRingFile"] = '' 20 | ext["ossrhUsername"] = '' 21 | ext["ossrhPassword"] = '' 22 | ext["sonatypeStagingProfileId"] = '' 23 | 24 | File secretPropsFile = project.rootProject.file('local.properties') 25 | if (secretPropsFile.exists()) { 26 | println "Found secret props file, loading props" 27 | Properties p = new Properties() 28 | p.load(new FileInputStream(secretPropsFile)) 29 | p.each { name, value -> 30 | ext[name] = value 31 | } 32 | } else { 33 | println "No props file, loading env vars" 34 | ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') 35 | ext["signing.password"] = System.getenv('SIGNING_PASSWORD') 36 | ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE') 37 | ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') 38 | ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') 39 | ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') 40 | } 41 | 42 | nexusStaging { 43 | packageGroup = PUBLISH_GROUP_ID 44 | stagingProfileId = sonatypeStagingProfileId 45 | username = ossrhUsername 46 | password = ossrhPassword 47 | } 48 | 49 | publishing { 50 | publications { 51 | release(MavenPublication) { 52 | groupId PUBLISH_GROUP_ID 53 | artifactId PUBLISH_ARTIFACT_ID 54 | version PUBLISH_VERSION 55 | artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") 56 | artifact androidSourcesJar 57 | 58 | pom { 59 | name = PUBLISH_ARTIFACT_ID 60 | description = 'Sambatech player' 61 | url = 'https://github.com/sambatech/player_sdk_android' 62 | licenses { 63 | license { 64 | name = 'The Apache License, Version 2.0' 65 | url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 66 | } 67 | } 68 | developers { 69 | developer { 70 | id = 'mariotolucas' 71 | name = 'Lucas Marioto' 72 | email = 'lucas.marioto@sambateh.com.br' 73 | } 74 | } 75 | scm { 76 | connection = 'scm:git:github.com/sambatech/player_sdk_android.git' 77 | developerConnection = 'scm:git:ssh://github.com/sambatech/player_sdk_android.git' 78 | url = 'https://github.com/sambatech/player_sdk_android' 79 | } 80 | withXml { 81 | def dependenciesNode = asNode().appendNode('dependencies') 82 | 83 | project.configurations.implementation.allDependencies.each { 84 | def dependencyNode = dependenciesNode.appendNode('dependency') 85 | dependencyNode.appendNode('groupId', it.group) 86 | dependencyNode.appendNode('artifactId', it.name) 87 | dependencyNode.appendNode('version', it.version) 88 | } 89 | } 90 | } 91 | } 92 | } 93 | repositories { 94 | maven { 95 | name = "sonatype" 96 | 97 | def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" 98 | url = releasesRepoUrl 99 | 100 | credentials { 101 | username ossrhUsername 102 | password ossrhPassword 103 | } 104 | } 105 | } 106 | } 107 | 108 | signing { 109 | sign publishing.publications 110 | } 111 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright 2014 Google Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | include ':sample', ':sambaplayersdk' -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | #sonar.exclusions=.gradle/** 2 | 3 | # Comma-separated paths to directories with sources (required) 4 | sonar.sources=sambaplayersdk/src/main/java/ 5 | 6 | # .class diretory 7 | sonar.java.binaries=sambaplayersdk/build/intermediates/classes/release 8 | 9 | # Encoding of the source files 10 | sonar.sourceEncoding=UTF-8 11 | 12 | # Android lint 13 | sonar.android.lint.report=app/build/reports/lint-results.xml 14 | sonar.profile=Android Lint -------------------------------------------------------------------------------- /tagging: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # if not installed yet 4 | if [[ ! -e '.git/hooks/pre-push' ]]; then 5 | echo 'Installing...' 6 | cp $(basename "$0") .git/hooks/pre-push 7 | echo 'Done' 8 | exit 9 | fi 10 | 11 | PROD_URL='git@github.com:sambatech/player_sdk_android.git' 12 | TEMP_REPO='_tmp' 13 | 14 | alreadyProd=$([[ $(git config --get remote.origin.url) == $PROD_URL ]] && echo 1) 15 | 16 | # if repo not public, switch to it and get tags 17 | # WARNING: assuming current branch is compatible with prod/master 18 | if [[ alreadyProd -ne 1 ]]; then 19 | git remote rename origin $TEMP_REPO 20 | git remote add origin $PROD_URL 2> /dev/null 21 | git pull origin master --tags 22 | fi 23 | 24 | v=$(cat sambaplayersdk/build.gradle | grep 'versionName' | sed $'s/^[^"\']*//' | sed 's/"*//g') 25 | # tags must be of annotated type otherwise git cannot get the latest correctly 26 | t=$(git describe --tags $(git rev-list --tags --max-count=1) 2> /dev/null) 27 | 28 | # if exists some tagged version 29 | if [[ ${#t} -gt 0 ]]; then 30 | echo "Current version: $t" 31 | else 32 | echo 'No tagged versions.' 33 | fi 34 | 35 | # if configured version differs from latest 36 | if [[ ${#v} -gt 0 && (${#t} -eq 0 || "$v" != "$t") ]]; then 37 | read -p "New version detected ($v). Create new release? (Y/n) " yn < /dev/tty 38 | case $yn in 39 | Y ) 40 | git tag -a $v -m "$(git log --oneline -n 1)" 41 | # TODO: update README.md 42 | git push origin $v --no-verify 43 | ;; 44 | esac 45 | else 46 | echo 'No versioning detected.' 47 | fi 48 | 49 | # switch back to current repo 50 | if [[ alreadyProd -ne 1 ]]; then 51 | git remote remove origin 52 | git remote rename $TEMP_REPO origin 53 | fi 54 | 55 | exit 0 56 | --------------------------------------------------------------------------------