diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index 481bb43..b72a5fb 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -18,4 +18,7 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +-dontwarn com.google.android.gms.tasks.OnFailureListener +-dontwarn com.google.android.gms.tasks.OnSuccessListener diff --git a/android/app/src/main/java/tv/broadpeak/simid/app/MainActivity.kt b/android/app/src/main/java/tv/broadpeak/simid/app/MainActivity.kt index 734548e..9863f9f 100644 --- a/android/app/src/main/java/tv/broadpeak/simid/app/MainActivity.kt +++ b/android/app/src/main/java/tv/broadpeak/simid/app/MainActivity.kt @@ -6,7 +6,13 @@ import android.view.View import androidx.activity.ComponentActivity import androidx.tv.material3.ExperimentalTvMaterial3Api -const val DEFAULT_STREAM_URL = "https://d2lwku66j7s1id.cloudfront.net/9bf31c7ff062936a7f941ad65712fad3/out/v1/6e0f649095ca4131b16bd0f877048629/index.mpd?nl-config=demo-samples-live" +const val DEFAULT_STREAM_URL = "https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd" + +const val DEFAULT_CREATIVE_URL = "https://interactiveadvertisingbureau.github.io/SIMID/examples/creatives/banner_nonlinear.html" +const val DEFAULT_CREATIVE_AD_PARAMS = "{\"bannerText\":\"Click here to draw!\",\"webUrl\":\"https://quickdraw.withgoogle.com/\"}" +const val DEFAULT_CREATIVE_DURATION = 10 + +const val DEFAULT_STREAM_BPKIO_URL = "https://dcv5s0ei7csoc.cloudfront.net/2ab56412b1163ee103b9ed7065a20563/AVOD/Meridian_1920x1080_30fps_SDR/conditioned/stream.mpd?midfreq=40&coll=cooldrink&adid=crea&max_ads=1&nldur=20&vdur=600&vod=true" class MainActivity : ComponentActivity() { @@ -15,13 +21,26 @@ class MainActivity : ComponentActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) - findViewById(R.id.buttonLoad).setOnClickListener { + findViewById(R.id.buttonLoadDefault).setOnClickListener { startActivity( Intent( this, PlayerActivity::class.java ) .putExtra("url", DEFAULT_STREAM_URL) + .putExtra("creativeUrl", DEFAULT_CREATIVE_URL) + .putExtra("creativeAdParams", DEFAULT_CREATIVE_AD_PARAMS) + .putExtra("creativeDuration", DEFAULT_CREATIVE_DURATION) + ) + } + + findViewById(R.id.buttonLoadBpkio).setOnClickListener { + startActivity( + Intent( + this, + PlayerActivity::class.java + ) + .putExtra("url", DEFAULT_STREAM_BPKIO_URL) ) } } diff --git a/android/app/src/main/java/tv/broadpeak/simid/app/PlayerActivity.kt b/android/app/src/main/java/tv/broadpeak/simid/app/PlayerActivity.kt index b347ad6..0628b84 100644 --- a/android/app/src/main/java/tv/broadpeak/simid/app/PlayerActivity.kt +++ b/android/app/src/main/java/tv/broadpeak/simid/app/PlayerActivity.kt @@ -23,6 +23,7 @@ import androidx.media3.exoplayer.source.MediaSource import androidx.media3.ui.PlayerView import androidx.core.net.toUri import androidx.media3.common.util.UnstableApi +import androidx.media3.ui.PlayerNotificationManager import tv.broadpeak.simid.controller.MediaState import tv.broadpeak.smartlib.SmartLib import tv.broadpeak.smartlib.ad.AdBreakData @@ -88,6 +89,15 @@ class PlayerActivity : AppCompatActivity() { initSmartLib(inputUrl) loadStream(inputUrl) + + val creativeUrl = b.getString("creativeUrl") + if (creativeUrl == null) { + findViewById(R.id.buttonStartCreative).visibility = View.GONE + } else { + findViewById(R.id.buttonStartCreative).setOnClickListener { + startCreative() + } + } } override fun onDestroy() { @@ -102,7 +112,7 @@ class PlayerActivity : AppCompatActivity() { private fun loadStream(url: String) { val result = session!!.getURL(url) - val streamUrl = if (result != null) result.url else url + val streamUrl = if (result != null && !result.isError) result.url else url player?.let { sPlayer -> @@ -124,6 +134,14 @@ class PlayerActivity : AppCompatActivity() { } } + private fun startCreative() { + val b = intent.extras + val creativeUrl = b?.getString("creativeUrl") ?: return + val creativeAdParams = b.getString("creativeAdParams") ?: "" + val creativeDuration = b.getInt("creativeDuration") + loadSimid("input-creative", creativeUrl, creativeAdParams, creativeDuration.toFloat(), true) + } + private fun initSmartLib(url: String) { val domain = URL(url).host @@ -195,7 +213,7 @@ class PlayerActivity : AppCompatActivity() { } } - private fun loadSimid(adId: String, creativeUri: String, adParameters: String, duration: Float) { + private fun loadSimid(adId: String, creativeUri: String, adParameters: String, duration: Float, autoStart: Boolean = false) { if (playerContainer == null) { return @@ -221,7 +239,7 @@ class PlayerActivity : AppCompatActivity() { controller.simidControllerApi(bpkSimidController!!) Log.d(TAG, "Load SIMID controller v${controller.getVersion()} and creative from $creativeUri") - controller.load(false) + controller.load(autoStart) simidControllers[adId] = controller } @@ -260,6 +278,10 @@ class PlayerActivity : AppCompatActivity() { webView?.let { runOnUiThread { webView.visibility = if (show) View.VISIBLE else View.GONE + if (show) { + session?.sendTracker("impression", adId) + session?.sendTracker("creativeView", adId) + } } } } diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml index 23e1f3f..127343b 100644 --- a/android/app/src/main/res/layout/activity_main.xml +++ b/android/app/src/main/res/layout/activity_main.xml @@ -8,14 +8,27 @@ android:layout_height="match_parent" tools:context=".MainActivity"> - - - - + +
+ +
+
+ + + +
- -
- +
+ + + + + + +
+
+
+
+
+ +
+ +
+ +
+