@24i/smartapps-bigscreen-rnv-build-engine 5.0.0-alpha.25 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-freshness.js +158 -0
- package/dist/.build-freshness.json +1010 -0
- package/dist/templates/platforms/firetv/project/README.md +196 -0
- package/dist/templates/platforms/firetv/project/amazoniap/build.gradle +41 -0
- package/dist/templates/platforms/firetv/project/amazoniap/consumer-rules.pro +0 -0
- package/dist/templates/platforms/firetv/project/amazoniap/proguard-rules.pro +21 -0
- package/dist/templates/platforms/firetv/project/amazoniap/src/main/kotlin/com/twentyfouri/bridgetv/amazoniap/AmazonIapService.kt +91 -0
- package/dist/templates/platforms/firetv/project/amazoniap/src/main/kotlin/com/twentyfouri/bridgetv/amazoniap/AmazonIapServiceFactory.kt +13 -0
- package/dist/templates/platforms/firetv/project/app/build.gradle +138 -0
- package/dist/templates/platforms/firetv/project/app/proguard-rules.pro +47 -0
- package/dist/templates/platforms/firetv/project/app/src/bigscreenAppstage/kotlin/com/twentyfouri/tvbridge/Flavor.kt +9 -0
- package/dist/templates/platforms/firetv/project/app/src/bigscreenAppstage/res/raw/configuration.json +8 -0
- package/dist/templates/platforms/firetv/project/app/src/main/AndroidManifest.xml +52 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/FlavorBase.kt +9 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/bridge/BridgeFromJavaScript.kt +421 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/bridge/BridgeToJavaScript.kt +121 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/configuration/BridgeConfig.kt +19 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/configuration/ConfigCallback.kt +6 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/configuration/ConfigProvider.kt +27 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/configuration/Drm.kt +10 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/configuration/UserAgent.kt +6 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/BaseApplication.kt +73 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/di/ActivityComponent.kt +13 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/di/ActivityModule.kt +14 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/di/ApplicationComponent.kt +23 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/di/ApplicationModule.kt +51 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/di/PerActivity.kt +26 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/utils/LocalStorage.kt +30 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/utils/LoggingDrmCallback.kt +38 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/utils/OverriddenHttpMediaDrmCallback.kt +134 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/utils/PlayerFactoryBitmovinCustomized.kt +19 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/utils/PlayerFactoryConfigured.kt +37 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/utils/PlayerFactoryExoPlayerCustomized.kt +106 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/utils/PlayerFactoryExoPlayerNpaw.kt +581 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/utils/PlayerFactoryVersion.kt +27 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/utils/SimpleActivityLifecycleCallback.kt +32 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/global/utils/SourceDrmOverridden.kt +91 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/sound/TouchPlayer.kt +86 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/client/BridgeWebView.kt +82 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/client/BridgeWebViewClient.kt +114 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/model/AnalyticsPlaybackInfo.kt +10 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/model/ContentModel.kt +14 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/model/DrmModel.kt +20 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/model/MediaEventType.kt +31 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/parser/PlaybackInfoParser.kt +10 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/parser/SourceParser.kt +89 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/parser/TrackJsonModelParser.kt +58 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/view/Mainview.kt +18 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/view/PlayerCache.kt +15 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/view/WebViewActivity.kt +252 -0
- package/dist/templates/platforms/firetv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/viewmodel/WebViewModel.kt +748 -0
- package/dist/templates/platforms/firetv/project/app/src/main/res/drawable/button_background_focus.xml +10 -0
- package/dist/templates/platforms/firetv/project/app/src/main/res/drawable/button_background_normal.xml +7 -0
- package/dist/templates/platforms/firetv/project/app/src/main/res/drawable/button_background_pressed.xml +7 -0
- package/dist/templates/platforms/firetv/project/app/src/main/res/drawable/button_focus.xml +8 -0
- package/dist/templates/platforms/firetv/project/app/src/main/res/layout/activity_web_view.xml +28 -0
- package/dist/templates/platforms/firetv/project/app/src/main/res/raw/click.ogg +0 -0
- package/dist/templates/platforms/firetv/project/app/src/main/res/values/styles.xml +12 -0
- package/dist/templates/platforms/firetv/project/app/src/main/res/xml/network_security_config.xml +4 -0
- package/dist/templates/platforms/firetv/project/build.gradle +45 -0
- package/dist/templates/platforms/firetv/project/common/build.gradle +41 -0
- package/dist/templates/platforms/firetv/project/common/consumer-rules.pro +0 -0
- package/dist/templates/platforms/firetv/project/common/proguard-rules.pro +21 -0
- package/dist/templates/platforms/firetv/project/common/src/main/kotlin/com/twentyfouri/tvbridge/common/Util.kt +11 -0
- package/dist/templates/platforms/firetv/project/common/src/main/kotlin/com/twentyfouri/tvbridge/common/iap/IapCallback.kt +11 -0
- package/dist/templates/platforms/firetv/project/common/src/main/kotlin/com/twentyfouri/tvbridge/common/iap/IapException.kt +14 -0
- package/dist/templates/platforms/firetv/project/common/src/main/kotlin/com/twentyfouri/tvbridge/common/iap/IapProduct.kt +16 -0
- package/dist/templates/platforms/firetv/project/common/src/main/kotlin/com/twentyfouri/tvbridge/common/iap/IapPurchase.kt +9 -0
- package/dist/templates/platforms/firetv/project/common/src/main/kotlin/com/twentyfouri/tvbridge/common/iap/IapService.kt +14 -0
- package/dist/templates/platforms/firetv/project/common/src/main/kotlin/com/twentyfouri/tvbridge/common/iap/IapServiceFactory.kt +8 -0
- package/dist/templates/platforms/firetv/project/common/src/main/kotlin/com/twentyfouri/tvbridge/common/iap/NullIapService.kt +32 -0
- package/dist/templates/platforms/firetv/project/googleiap/build.gradle +41 -0
- package/dist/templates/platforms/firetv/project/googleiap/consumer-rules.pro +0 -0
- package/dist/templates/platforms/firetv/project/googleiap/proguard-rules.pro +21 -0
- package/dist/templates/platforms/firetv/project/googleiap/src/main/kotlin/com/twentyfouri/tvbridge/googleiap/GoogleIapService.kt +6 -0
- package/dist/templates/platforms/firetv/project/googleiap/src/main/kotlin/com/twentyfouri/tvbridge/googleiap/GoogleIapServiceFactory.kt +13 -0
- package/dist/templates/platforms/firetv/project/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/dist/templates/platforms/firetv/project/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/dist/templates/platforms/firetv/project/gradle.properties +4 -0
- package/dist/templates/platforms/firetv/project/gradlew +251 -0
- package/dist/templates/platforms/firetv/project/gradlew.bat +94 -0
- package/dist/templates/platforms/firetv/project/proguard-rules.pro +42 -0
- package/dist/templates/platforms/firetv/project/settings.gradle +4 -0
- package/index.js +2 -31
- package/package.json +4 -3
- package/project.json +57 -11
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
package com.twentyfouri.tvbridge.global.utils
|
|
2
|
+
|
|
3
|
+
import com.twentyfouri.player.base.Source
|
|
4
|
+
import com.twentyfouri.player.base.SourceAuthorization
|
|
5
|
+
import com.twentyfouri.player.base.SourceDrm
|
|
6
|
+
import com.twentyfouri.player.base.SourceDrmPlayready
|
|
7
|
+
import com.twentyfouri.player.base.SourceDrmWidevine
|
|
8
|
+
import com.twentyfouri.player.base.buildUpon
|
|
9
|
+
import java.net.URI
|
|
10
|
+
|
|
11
|
+
open class SourceDrmOverridden protected constructor(
|
|
12
|
+
builder: Builder
|
|
13
|
+
) : SourceDrm() {
|
|
14
|
+
|
|
15
|
+
override val packageName: String = builder.packageName
|
|
16
|
+
?: throw IllegalStateException("Missing SourceDrmOverridden.packageName")
|
|
17
|
+
val licenseServer: URI? = builder.licenseServer
|
|
18
|
+
val forceLicenseServer: Boolean = builder.forceLicenseServer
|
|
19
|
+
val authorization: SourceAuthorization? = builder.authorization
|
|
20
|
+
|
|
21
|
+
override fun hashCode(): Int = licenseServer.hashCode()
|
|
22
|
+
|
|
23
|
+
override fun toString(): String = "SourceDrmOverridden($licenseServer)"
|
|
24
|
+
|
|
25
|
+
override fun equals(other: Any?): Boolean = other is SourceDrmOverridden &&
|
|
26
|
+
packageName == other.packageName &&
|
|
27
|
+
licenseServer == other.licenseServer &&
|
|
28
|
+
forceLicenseServer == other.forceLicenseServer &&
|
|
29
|
+
authorization == other.authorization
|
|
30
|
+
|
|
31
|
+
override fun buildUpon() = Builder()
|
|
32
|
+
.also { it.applyFrom(this) }
|
|
33
|
+
|
|
34
|
+
open class Builder : SourceDrm.Builder() {
|
|
35
|
+
var packageName: String? = null
|
|
36
|
+
var licenseServer: URI? = null
|
|
37
|
+
var forceLicenseServer: Boolean = false
|
|
38
|
+
var authorization: SourceAuthorization? = null
|
|
39
|
+
|
|
40
|
+
open fun applyFrom(source: SourceDrm) {
|
|
41
|
+
when (source) {
|
|
42
|
+
is SourceDrmOverridden -> applyFrom(source)
|
|
43
|
+
is SourceDrmWidevine -> applyFrom(source)
|
|
44
|
+
is SourceDrmPlayready -> applyFrom(source)
|
|
45
|
+
else -> {
|
|
46
|
+
packageName = source.packageName
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
open fun applyFrom(source: SourceDrmOverridden) {
|
|
52
|
+
packageName = source.packageName
|
|
53
|
+
licenseServer = source.licenseServer
|
|
54
|
+
forceLicenseServer = source.forceLicenseServer
|
|
55
|
+
authorization = source.authorization
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
open fun applyFrom(source: SourceDrmWidevine) {
|
|
59
|
+
packageName = source.packageName
|
|
60
|
+
licenseServer = source.licenseServer
|
|
61
|
+
forceLicenseServer = source.forceLicenseServer
|
|
62
|
+
authorization = source.authorization
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
open fun applyFrom(source: SourceDrmPlayready) {
|
|
66
|
+
packageName = source.packageName
|
|
67
|
+
licenseServer = source.licenseServer
|
|
68
|
+
forceLicenseServer = source.forceLicenseServer
|
|
69
|
+
authorization = source.authorization
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
override fun build() =
|
|
73
|
+
SourceDrmOverridden(this)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
companion object {
|
|
77
|
+
fun replaceSource(source: Source): Source {
|
|
78
|
+
if (source.drm.isEmpty()) return source
|
|
79
|
+
return source.buildUpon {
|
|
80
|
+
drm = drm.mapTo(mutableListOf()) { sourceDrm ->
|
|
81
|
+
SourceDrmOverridden {
|
|
82
|
+
applyFrom(sourceDrm)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
inline fun SourceDrmOverridden(block: SourceDrmOverridden.Builder.() -> Unit) =
|
|
91
|
+
SourceDrmOverridden.Builder().apply(block).build()
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
package com.twentyfouri.tvbridge.sound
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.media.AudioManager
|
|
5
|
+
import android.media.MediaPlayer
|
|
6
|
+
import android.provider.MediaStore
|
|
7
|
+
import android.util.Log
|
|
8
|
+
import androidx.annotation.IntRange
|
|
9
|
+
import androidx.annotation.RawRes
|
|
10
|
+
import com.twentyfouri.tvbridge.R
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Play touch sound. Uses queue to handle several overlapping sounds
|
|
14
|
+
* Configuration:
|
|
15
|
+
* MEDIA_PLAYER_LIST_SIZE: Number of parallel touch sounds that can be played at once
|
|
16
|
+
* TOUCH_SOUND_RES: Resource ID of touch sound to be used
|
|
17
|
+
* USE_NATIVE_SOUND: Uses native click sound from AudioManager, don't use overlapping & queue at all
|
|
18
|
+
*/
|
|
19
|
+
class TouchPlayer(
|
|
20
|
+
private val context: Context
|
|
21
|
+
) : MediaPlayer.OnCompletionListener {
|
|
22
|
+
|
|
23
|
+
companion object {
|
|
24
|
+
private const val MEDIA_PLAYER_LIST_SIZE = 1L
|
|
25
|
+
@RawRes
|
|
26
|
+
private val TOUCH_SOUND_RES = R.raw.click
|
|
27
|
+
private const val USE_NATIVE_SOUND = true
|
|
28
|
+
private var audioManager: AudioManager? = null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private var mediaPlayerList = mutableListOf<MediaPlayer>()
|
|
32
|
+
|
|
33
|
+
@IntRange(from = 0, to = MEDIA_PLAYER_LIST_SIZE - 1)
|
|
34
|
+
private var mediaPlayerListIterator: Int = 0
|
|
35
|
+
|
|
36
|
+
init {
|
|
37
|
+
for (i in 0 until Companion.MEDIA_PLAYER_LIST_SIZE) {
|
|
38
|
+
mediaPlayerList.add(getNewPlayer())
|
|
39
|
+
}
|
|
40
|
+
if (USE_NATIVE_SOUND) {
|
|
41
|
+
audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fun play() {
|
|
46
|
+
Log.d("TouchPlayer", "Touch event envoked")
|
|
47
|
+
audioManager?.playSoundEffect(AudioManager.FX_KEY_CLICK)
|
|
48
|
+
?: getAvailableMediaPlayer()?.start()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
override fun onCompletion(mp: MediaPlayer) {
|
|
52
|
+
if (mp in mediaPlayerList) {
|
|
53
|
+
mediaPlayerList[mediaPlayerList.indexOf(mp)] = getNewPlayer()
|
|
54
|
+
mp.release()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Returns available player from buffer. If there is no available player already, it returns null
|
|
60
|
+
*/
|
|
61
|
+
private fun getAvailableMediaPlayer(): MediaPlayer? {
|
|
62
|
+
val nextIter = if (MEDIA_PLAYER_LIST_SIZE.toInt() == 1) {
|
|
63
|
+
mediaPlayerListIterator
|
|
64
|
+
} else {
|
|
65
|
+
++mediaPlayerListIterator / MEDIA_PLAYER_LIST_SIZE.toInt()
|
|
66
|
+
}
|
|
67
|
+
val selectedPlayer = mediaPlayerList[mediaPlayerListIterator]
|
|
68
|
+
|
|
69
|
+
return if (selectedPlayer.isPlaying) { // We reached the end of available buffer
|
|
70
|
+
null
|
|
71
|
+
} else {
|
|
72
|
+
mediaPlayerListIterator = nextIter
|
|
73
|
+
selectedPlayer
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private fun getNewPlayer(): MediaPlayer {
|
|
78
|
+
val mediaPlayer = MediaPlayer()
|
|
79
|
+
mediaPlayer.setAudioStreamType(AudioManager.STREAM_SYSTEM)
|
|
80
|
+
mediaPlayer.setOnCompletionListener(this)
|
|
81
|
+
val afd = context.resources.openRawResourceFd(TOUCH_SOUND_RES)
|
|
82
|
+
mediaPlayer.setDataSource(afd.fileDescriptor, afd.startOffset, afd.length)
|
|
83
|
+
mediaPlayer.prepare()
|
|
84
|
+
return mediaPlayer
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
package com.twentyfouri.tvbridge.webview.client
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.content.pm.PackageManager
|
|
5
|
+
import android.graphics.Color
|
|
6
|
+
import android.util.AttributeSet
|
|
7
|
+
import android.util.Log
|
|
8
|
+
import android.view.KeyEvent
|
|
9
|
+
import android.webkit.WebSettings
|
|
10
|
+
import android.webkit.WebView
|
|
11
|
+
import com.twentyfouri.tvbridge.BuildConfig
|
|
12
|
+
import com.twentyfouri.tvbridge.configuration.BridgeConfig
|
|
13
|
+
import com.twentyfouri.tvbridge.global.BaseApplication
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Created by gonzapico on 20/09/2017.
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
* Custom WebView of 24i with the configuration required to play the videos.
|
|
20
|
+
*/
|
|
21
|
+
class BridgeWebView @JvmOverloads constructor(
|
|
22
|
+
context: Context,
|
|
23
|
+
attrs: AttributeSet? = null
|
|
24
|
+
) : WebView(context, attrs) {
|
|
25
|
+
|
|
26
|
+
var previewKeyEvent: ((KeyEvent) -> Boolean)? = null
|
|
27
|
+
|
|
28
|
+
private val config: BridgeConfig?
|
|
29
|
+
get() = (context.applicationContext as? BaseApplication)?.component?.configuration
|
|
30
|
+
|
|
31
|
+
init {
|
|
32
|
+
// Set the background color of the WebView to transparent, so the video player can be shown behind it.
|
|
33
|
+
setBackgroundColor(Color.TRANSPARENT)
|
|
34
|
+
val webSettings = this.settings
|
|
35
|
+
webSettings.javaScriptEnabled = true
|
|
36
|
+
webSettings.domStorageEnabled = true
|
|
37
|
+
webSettings.useWideViewPort = true
|
|
38
|
+
webSettings.loadWithOverviewMode = true
|
|
39
|
+
webSettings.mediaPlaybackRequiresUserGesture = false
|
|
40
|
+
webSettings.allowFileAccess = true
|
|
41
|
+
webSettings.allowContentAccess = true
|
|
42
|
+
webSettings.userAgentString = config?.userAgent?.value ?: userAgent
|
|
43
|
+
|
|
44
|
+
// Log the settings of the WebView.
|
|
45
|
+
if (BuildConfig.DEBUG) {
|
|
46
|
+
logWebViewSettings(webSettings)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private val userAgent: String?
|
|
51
|
+
get() {
|
|
52
|
+
try {
|
|
53
|
+
val ai = context.packageManager.getApplicationInfo(context.packageName, PackageManager.GET_META_DATA)
|
|
54
|
+
val bundle = ai.metaData
|
|
55
|
+
return bundle.getString("user-agent")
|
|
56
|
+
} catch (e: PackageManager.NameNotFoundException) {
|
|
57
|
+
Log.e(LOG, "Failed to load meta-data, NameNotFound: " + e.message)
|
|
58
|
+
} catch (e: NullPointerException) {
|
|
59
|
+
Log.e(LOG, "Failed to load meta-data, NullPointer: " + e.message)
|
|
60
|
+
}
|
|
61
|
+
return "unknown"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
|
65
|
+
if (previewKeyEvent?.invoke(event) == true) return true
|
|
66
|
+
return super.dispatchKeyEvent(event)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
companion object {
|
|
70
|
+
private const val LOG = "24iWebView"
|
|
71
|
+
private fun logWebViewSettings(webSettings: WebSettings) {
|
|
72
|
+
Log.v(LOG, "logWebViewSettings")
|
|
73
|
+
Log.v(LOG, " * supportZoom: " + webSettings.supportZoom())
|
|
74
|
+
Log.v(LOG, " * getBuiltInZoomControls: " + webSettings.builtInZoomControls)
|
|
75
|
+
Log.v(LOG, " * getDisplayZoomControls: " + webSettings.displayZoomControls)
|
|
76
|
+
Log.v(LOG, " * getLoadWithOverviewMode: " + webSettings.loadWithOverviewMode)
|
|
77
|
+
Log.v(LOG, " * getUseWideViewPort: " + webSettings.useWideViewPort)
|
|
78
|
+
Log.v(LOG, " * getJavaScriptEnabled: " + webSettings.javaScriptEnabled)
|
|
79
|
+
Log.v(LOG, " * getJavaScriptCanOpenWindowsAutomatically: " + webSettings.javaScriptCanOpenWindowsAutomatically)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
package com.twentyfouri.tvbridge.webview.client
|
|
2
|
+
|
|
3
|
+
import android.graphics.Bitmap
|
|
4
|
+
import android.net.http.SslError
|
|
5
|
+
import android.os.Build
|
|
6
|
+
import android.os.Message
|
|
7
|
+
import android.util.Log
|
|
8
|
+
import android.view.InputEvent
|
|
9
|
+
import android.view.KeyEvent
|
|
10
|
+
import android.webkit.*
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Created by gonzapico on 21/09/2017.
|
|
14
|
+
*
|
|
15
|
+
*
|
|
16
|
+
* Custom 24i WebViewClient to override the methods required by the app.
|
|
17
|
+
*/
|
|
18
|
+
class BridgeWebViewClient(
|
|
19
|
+
private val callback: BridgeWebViewClientCallback
|
|
20
|
+
) : WebViewClient() {
|
|
21
|
+
|
|
22
|
+
interface BridgeWebViewClientCallback {
|
|
23
|
+
fun onUnhandledKeyEvent(view: WebView, event: KeyEvent)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override fun doUpdateVisitedHistory(view: WebView, url: String, isReload: Boolean) {
|
|
27
|
+
//Log.v(LOGTAG, "doUpdateVisitedHistory - " + url);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun onFormResubmission(view: WebView, dontResend: Message?, resend: Message?) {
|
|
31
|
+
Log.v(LOGTAG, "onFormResubmission")
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun onLoadResource(view: WebView, url: String?) {
|
|
35
|
+
//Log.v(LOGTAG, "onLoadResource - " + url);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
override fun onPageFinished(view: WebView, url: String?) {
|
|
39
|
+
Log.v(LOGTAG, "onPageFinished - $url")
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
|
|
43
|
+
Log.v(LOGTAG, "onPageStarted - $url")
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Surpress warnings about deprecation. Also added API level 23 version of method below.
|
|
47
|
+
override fun onReceivedError(view: WebView, errorCode: Int, description: String, failingUrl: String) {
|
|
48
|
+
Log.v(LOGTAG, "onReceivedError (<=22) - $description")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
override fun onReceivedError(view: WebView, request: WebResourceRequest, error: WebResourceError) {
|
|
52
|
+
// Log the description on devices at API level 23 (Marshmellow) or higher.
|
|
53
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
54
|
+
Log.v(LOGTAG, "onReceivedError (>=23) - " + error.description)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override fun onReceivedHttpAuthRequest(view: WebView, handler: HttpAuthHandler, host: String, realm: String) {
|
|
59
|
+
Log.v(LOGTAG, "onReceivedHttpAuthRequest - $host")
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
override fun onReceivedHttpError(view: WebView, request: WebResourceRequest, errorResponse: WebResourceResponse) {
|
|
63
|
+
// Log the description on devices at API level 23 (Marshmellow) or higher.
|
|
64
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
65
|
+
Log.v(LOGTAG, "onReceivedError (>=23) - " + errorResponse.statusCode + " " + errorResponse.reasonPhrase)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
override fun onReceivedLoginRequest(view: WebView, realm: String, account: String?, args: String?) {
|
|
70
|
+
Log.v(LOGTAG, "onReceivedLoginRequest - $realm")
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
override fun onReceivedSslError(view: WebView, handler: SslErrorHandler, error: SslError) {
|
|
74
|
+
Log.v(LOGTAG, "onReceivedSslError - $error")
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
override fun onScaleChanged(view: WebView, oldScale: Float, newScale: Float) {
|
|
78
|
+
Log.v(LOGTAG, "onScaleChanged - oldScale: $oldScale, newScale: $newScale")
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Surpress warnings about deprecation. Also added API level 21 version of method below.
|
|
82
|
+
override fun onUnhandledKeyEvent(view: WebView, event: KeyEvent) {
|
|
83
|
+
callback.onUnhandledKeyEvent(view, event)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fun onUnhandledInputEvent(view: WebView?, event: InputEvent) {
|
|
87
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
88
|
+
Log.v(LOGTAG, "onUnhandledInputEvent (>=21) - $event")
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Surpress warnings about deprecation. Also added API level 21 version of method below.
|
|
93
|
+
override fun shouldInterceptRequest(view: WebView, url: String?): WebResourceResponse? {
|
|
94
|
+
return null
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse? {
|
|
98
|
+
return null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
override fun shouldOverrideKeyEvent(view: WebView, event: KeyEvent): Boolean {
|
|
102
|
+
return false
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Handle all clicked links within the WebView.
|
|
106
|
+
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
|
|
107
|
+
Log.v(LOGTAG, "shouldOverrideUrlLoading - $url")
|
|
108
|
+
return false
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
companion object {
|
|
112
|
+
private const val LOGTAG = "24iWebViewClient"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
package com.twentyfouri.tvbridge.webview.model
|
|
2
|
+
|
|
3
|
+
import com.google.gson.annotations.SerializedName
|
|
4
|
+
|
|
5
|
+
class ContentModel {
|
|
6
|
+
@SerializedName("streamUrl")
|
|
7
|
+
var streamUrl: String? = null
|
|
8
|
+
|
|
9
|
+
@SerializedName("drmConfig")
|
|
10
|
+
var drmModel: DrmModel? = null
|
|
11
|
+
|
|
12
|
+
@SerializedName("streamType")
|
|
13
|
+
var streamType: String? = null
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package com.twentyfouri.tvbridge.webview.model
|
|
2
|
+
|
|
3
|
+
import com.google.gson.annotations.SerializedName
|
|
4
|
+
|
|
5
|
+
class DrmModel {
|
|
6
|
+
@SerializedName("drmSchemeUuid")
|
|
7
|
+
var drmSchemeUuid: String? = null
|
|
8
|
+
|
|
9
|
+
@SerializedName("drmLicenseUrl")
|
|
10
|
+
var drmLicenseUrl: String? = null
|
|
11
|
+
|
|
12
|
+
@SerializedName("drmCustomData")
|
|
13
|
+
var keyRequestProperties: Map<String, String>? = null
|
|
14
|
+
|
|
15
|
+
@SerializedName("overrideDrmCallback")
|
|
16
|
+
var overrideDrmCallback: Boolean? = null
|
|
17
|
+
|
|
18
|
+
@SerializedName("multiSessionEnabled")
|
|
19
|
+
var multiSessionEnabled: Boolean? = null
|
|
20
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package com.twentyfouri.tvbridge.webview.model
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Created by mitchellwit on 10/03/2017.
|
|
5
|
+
*/
|
|
6
|
+
object MediaEventType {
|
|
7
|
+
const val TIME_UPDATE = "timeupdate"
|
|
8
|
+
const val ERROR = "error"
|
|
9
|
+
const val PLAYING = "playing"
|
|
10
|
+
const val PAUSE = "pause"
|
|
11
|
+
const val PLAY = "play"
|
|
12
|
+
const val ENDED = "ended"
|
|
13
|
+
const val CANPLAY = "canplay"
|
|
14
|
+
const val LOADEDMETADATA = "loadedmetadata"
|
|
15
|
+
const val LOADEDDATA = "loadeddata"
|
|
16
|
+
const val WAITING = "waiting"
|
|
17
|
+
const val DURATION_CHANGE = "durationchange"
|
|
18
|
+
const val SEEKING = "seeking"
|
|
19
|
+
const val SEEKED = "seeked"
|
|
20
|
+
const val KEY_PRESS = "keypress"
|
|
21
|
+
const val KEY_UP = "keyup"
|
|
22
|
+
const val KEY_DOWN = "keydown"
|
|
23
|
+
const val TRACKS_CHANGED = "trackschanged"
|
|
24
|
+
const val AD_BREAK_START = "adbreakbegin"
|
|
25
|
+
const val AD_BREAK_END = "adbreakend"
|
|
26
|
+
const val AD_BREAKS_RESCHEDULED = "adcuepointschanged"
|
|
27
|
+
const val AD_STARTED = "adbegin"
|
|
28
|
+
const val AD_ENDED = "adend"
|
|
29
|
+
const val AD_ERROR = "aderror"
|
|
30
|
+
const val AD_SKIPPED = "adskip"
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
package com.twentyfouri.tvbridge.webview.parser
|
|
2
|
+
|
|
3
|
+
import com.google.gson.Gson
|
|
4
|
+
import com.twentyfouri.tvbridge.webview.model.AnalyticsPlaybackInfo
|
|
5
|
+
|
|
6
|
+
object PlaybackInfoParser {
|
|
7
|
+
fun parse(serialized: String?): AnalyticsPlaybackInfo {
|
|
8
|
+
return Gson().fromJson(serialized, AnalyticsPlaybackInfo::class.java)
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
package com.twentyfouri.tvbridge.webview.parser
|
|
2
|
+
|
|
3
|
+
import com.twentyfouri.player.base.*
|
|
4
|
+
import com.twentyfouri.tvbridge.global.utils.SourceDrmOverridden
|
|
5
|
+
import org.json.JSONException
|
|
6
|
+
import org.json.JSONObject
|
|
7
|
+
import java.net.URI
|
|
8
|
+
import java.util.UUID
|
|
9
|
+
|
|
10
|
+
object SourceParser {
|
|
11
|
+
private val sourceSerializer = DefaultSourceSerializer()
|
|
12
|
+
|
|
13
|
+
fun stringToJson(jsonString: String?): Source? {
|
|
14
|
+
if (jsonString.isNullOrEmpty()) return null
|
|
15
|
+
if (jsonString.startsWith("http://") || jsonString.startsWith("https://")) {
|
|
16
|
+
return Source {
|
|
17
|
+
url = URI(jsonString)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
val jsonSource = JSONObject(jsonString)
|
|
23
|
+
if (jsonSource.has("streamUrl")) {
|
|
24
|
+
return parseContentModel(jsonSource)
|
|
25
|
+
}
|
|
26
|
+
return sourceSerializer.toSource(jsonSource)
|
|
27
|
+
|
|
28
|
+
} catch (e: JSONException) {
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private fun parseContentModel(jsonSource: JSONObject): Source? {
|
|
34
|
+
return Source {
|
|
35
|
+
val streamUrl = jsonSource.getString("streamUrl", null)
|
|
36
|
+
if (streamUrl.isNullOrEmpty()) return null
|
|
37
|
+
url = URI(streamUrl)
|
|
38
|
+
|
|
39
|
+
mimeType = jsonSource.getString("streamType", null)
|
|
40
|
+
?.let { MimeType.parse(it) }
|
|
41
|
+
|
|
42
|
+
jsonSource.getObject("drmConfig") { parseDrmModel(it) }
|
|
43
|
+
?.also { drm.add(it) }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private fun parseDrmModel(jsonDrm: JSONObject): SourceDrm? {
|
|
48
|
+
val drmSchemeUuid = jsonDrm.getString("drmSchemeUuid", null)
|
|
49
|
+
val drmLicenseUri = jsonDrm.getString("drmLicenseUrl", null)
|
|
50
|
+
?.let { URI(it) }
|
|
51
|
+
val drmCustomData = jsonDrm.getObject("drmCustomData") { parseSourceAuthorization (it) }
|
|
52
|
+
val overrideDrmCallback = jsonDrm.getBoolean("overrideDrmCallback")
|
|
53
|
+
|
|
54
|
+
return if (overrideDrmCallback) {
|
|
55
|
+
SourceDrmOverridden {
|
|
56
|
+
packageName = when (drmSchemeUuid) {
|
|
57
|
+
"widevine", WIDEVINE_UUID -> DrmWidevine.packageName
|
|
58
|
+
"playready", PLAYREADY_UUID -> DrmPlayready.packageName
|
|
59
|
+
else -> null
|
|
60
|
+
}
|
|
61
|
+
licenseServer = drmLicenseUri
|
|
62
|
+
authorization = drmCustomData
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
when (drmSchemeUuid) {
|
|
66
|
+
"widevine", WIDEVINE_UUID -> SourceDrmWidevine {
|
|
67
|
+
licenseServer = drmLicenseUri
|
|
68
|
+
authorization = drmCustomData
|
|
69
|
+
}
|
|
70
|
+
"playready", PLAYREADY_UUID -> SourceDrmPlayready {
|
|
71
|
+
licenseServer = drmLicenseUri
|
|
72
|
+
authorization = drmCustomData
|
|
73
|
+
}
|
|
74
|
+
else -> null
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private fun parseSourceAuthorization(jsonMap: JSONObject): SourceAuthorization? {
|
|
80
|
+
return SourceAuthorizationHeaders {
|
|
81
|
+
jsonMap.keys().forEach { key ->
|
|
82
|
+
headers[key] = jsonMap.getString(key)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
val WIDEVINE_UUID = "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
|
|
88
|
+
val PLAYREADY_UUID = "9a04f079-9840-4286-ab92-e65be0885f95"
|
|
89
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
package com.twentyfouri.tvbridge.webview.parser
|
|
2
|
+
|
|
3
|
+
import com.twentyfouri.player.base.AudioTrack
|
|
4
|
+
import com.twentyfouri.player.base.DefaultSourceSerializer
|
|
5
|
+
import com.twentyfouri.player.base.TextTrack
|
|
6
|
+
import org.json.JSONArray
|
|
7
|
+
import org.json.JSONObject
|
|
8
|
+
import java.util.*
|
|
9
|
+
|
|
10
|
+
object TrackJsonModelParser {
|
|
11
|
+
|
|
12
|
+
val serializer = DefaultSourceSerializer()
|
|
13
|
+
|
|
14
|
+
fun toJson(audioTracks: List<AudioTrack>?, textTracks: List<TextTrack>?): String {
|
|
15
|
+
val jsonArray = JSONArray()
|
|
16
|
+
audioTracks?.forEach {
|
|
17
|
+
jsonArray.put(toJsonTree(it))
|
|
18
|
+
}
|
|
19
|
+
textTracks?.forEach {
|
|
20
|
+
jsonArray.put(toJsonTree(it))
|
|
21
|
+
}
|
|
22
|
+
return jsonArray.toString()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun toJson(trackInfo: AudioTrack?): String {
|
|
26
|
+
if (trackInfo == null) return ""
|
|
27
|
+
return toJsonTree(trackInfo ?: return "").toString()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
fun toJson(trackInfo: TextTrack?): String {
|
|
31
|
+
return toJsonTree(trackInfo ?: return "").toString()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private fun toJsonTree(trackInfo: AudioTrack) = serializer.toPersistentMap(trackInfo).also {
|
|
35
|
+
it.put("type", "audio")
|
|
36
|
+
it.put("name", buildTrackName(trackInfo.language, trackInfo.label))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private fun toJsonTree(trackInfo: TextTrack) = serializer.toPersistentMap(trackInfo).also {
|
|
40
|
+
it.put("type", "subtitles")
|
|
41
|
+
it.put("name", buildTrackName(trackInfo.language, trackInfo.label))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private fun buildTrackName(language: String?, label: String?): String? {
|
|
45
|
+
if (language.isNullOrEmpty()) return label
|
|
46
|
+
return Locale(language).displayName
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
fun audioFromJson(json: String?): AudioTrack? {
|
|
50
|
+
if (json.isNullOrEmpty()) return null
|
|
51
|
+
return serializer.toAudioTrack(JSONObject(json))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fun textFromJson(json: String?): TextTrack? {
|
|
55
|
+
if (json.isNullOrEmpty()) return null
|
|
56
|
+
return serializer.toTextTrack(JSONObject(json))
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package com.twentyfouri.tvbridge.webview.view
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Created by destivar on 15/02/16.
|
|
5
|
+
*/
|
|
6
|
+
interface Mainview {
|
|
7
|
+
fun loadUrl(url: String?)
|
|
8
|
+
fun goFullscreen()
|
|
9
|
+
fun exitFullscreen(width: Int, height: Int, left: Int, top: Int)
|
|
10
|
+
fun setBlackCurtainVisibility(visibility: Int)
|
|
11
|
+
fun showMessage(message: String?)
|
|
12
|
+
fun requestAudioFocus(): Int
|
|
13
|
+
fun abandonAudioFocus()
|
|
14
|
+
fun onBackPressed()
|
|
15
|
+
fun launchIapPurchase(sku: String)
|
|
16
|
+
fun hideKeyboard()
|
|
17
|
+
fun reloadPlayer()
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package com.twentyfouri.tvbridge.webview.view
|
|
2
|
+
|
|
3
|
+
import com.twentyfouri.player.base.Source
|
|
4
|
+
|
|
5
|
+
class PlayerCache {
|
|
6
|
+
enum class PlayerState {
|
|
7
|
+
PLAYING, PAUSED
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var loadFromCache = false
|
|
11
|
+
var savedPlayerPosition: Double = 0.0
|
|
12
|
+
var savedPlayerDuration: Double = 0.0
|
|
13
|
+
var savedPlayerState: PlayerState? = null
|
|
14
|
+
var savedSource: Source? = null
|
|
15
|
+
}
|