Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-dontwarn com.google.android.gms.tasks.OnFailureListener
-dontwarn com.google.android.gms.tasks.OnSuccessListener
23 changes: 21 additions & 2 deletions android/app/src/main/java/tv/broadpeak/simid/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -15,13 +21,26 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

findViewById<View>(R.id.buttonLoad).setOnClickListener {
findViewById<View>(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<View>(R.id.buttonLoadBpkio).setOnClickListener {
startActivity(
Intent(
this,
PlayerActivity::class.java
)
.putExtra("url", DEFAULT_STREAM_BPKIO_URL)
)
}
}
Expand Down
28 changes: 25 additions & 3 deletions android/app/src/main/java/tv/broadpeak/simid/app/PlayerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -88,6 +89,15 @@ class PlayerActivity : AppCompatActivity() {

initSmartLib(inputUrl)
loadStream(inputUrl)

val creativeUrl = b.getString("creativeUrl")
if (creativeUrl == null) {
findViewById<View>(R.id.buttonStartCreative).visibility = View.GONE
} else {
findViewById<View>(R.id.buttonStartCreative).setOnClickListener {
startCreative()
}
}
}

override fun onDestroy() {
Expand All @@ -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 ->

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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)
}
}
}
}
Expand Down
31 changes: 22 additions & 9 deletions android/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@
android:layout_height="match_parent"
tools:context=".MainActivity">

<Button
android:id="@+id/buttonLoad"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:text="@string/button_load"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">

<Button
android:id="@+id/buttonLoadDefault"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/button_load" />

<Button
android:id="@+id/buttonLoadBpkio"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="LOAD TEST STREAM (bpkio)" />
</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
10 changes: 9 additions & 1 deletion android/app/src/main/res/layout/activity_player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top|start"
app:show_shuffle_button="true" />
app:show_shuffle_button="true" >

<Button
android:id="@+id/buttonStartCreative"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="32dp"
android:text="Start Creative" />
</androidx.media3.ui.PlayerView>

</FrameLayout>
</RelativeLayout>
7 changes: 7 additions & 0 deletions android/controller/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-keepattributes *Annotation*, Signature, InnerClasses, EnclosingMethod

-keep class com.google.gson.** { *; }
-dontwarn com.google.gson.**

-keep class tv.broadpeak.simid.controller.** { *; }
-keep class tv.broadpeak.simid.controller.SimidMessagesKt { *; }
4 changes: 3 additions & 1 deletion android/controller/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-dontwarn java.lang.invoke.StringConcatFactory
2 changes: 1 addition & 1 deletion android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ coreKtx = "1.15.0"
appcompat = "1.7.0"
composeBom = "2024.09.00"
media3Exoplayer = "1.4.1"
smartlibMedia3 = "05.01.03.66cdf2a"
smartlibMedia3 = "05.04.04.808048b"
tvFoundation = "1.0.0-alpha12"
tvMaterial = "1.0.0"
lifecycleRuntimeKtx = "2.8.7"
Expand Down
137 changes: 87 additions & 50 deletions web/app/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,68 +17,90 @@
}

body {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;

background-color: black;
color: white;
text-align: center;
font-family: Helvetica, Arial, sans-serif;
font-size: 1vw;
}

#main {
position: absolute;
width: 100vw;
height: 100vh;
main {
min-height: 100vh;
display: flex;
flex-direction: column;
background: #111;
overflow: hidden;
}

#player {
position: relative;
.inputs {
width: 100%;
height: 100%;
display: flex;
transition: all .5s linear;
flex-direction: column;
align-items: stretch;
justify-content: center;
background: #3d3838;
gap: 8px;
margin: 8px;
padding: 8px 16px;
z-index: 999;
}

#video {
object-fit: contain;
width: 100%;
height: auto;
/* margin: auto; */
top: 0;
left: 0;
.inputs button,
.inputs select,
.inputs input {
height: 24px;
box-sizing: border-box;
}

.inputs label {
white-space: nowrap;
flex: 0 0 auto;
}

.inputs {
position: absolute;
top: 5%;
left: 5%;
.inputs .input {
display: flex;
flex-direction: column;
gap: 10px;
background: rgba(0, 0, 0, 0.5);
padding: 20px;
border-radius: 5px;
z-index: 999;
width: 90%
align-items: center;
gap: 8px;
width: 100%;
}

.flex-edit {
flex: 1 1 0;
min-width: 0;
}

.inputs button {
padding: 4px;
}

.input {
.app {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
#stream-edit-url {

#player-container {
position: relative;
aspect-ratio: 16 / 9;
width: min(100%, calc((100vh - 90px) * 16 / 9));
height: auto;
max-height: calc(100vh - 90px);
}

#player {
position: absolute;
width: 100%;
height: 100%;
display: flex;
transition: all .5s linear;
}

.input * {
padding: 10px;
#video {
object-fit: contain;
width: 100%;
height: auto;
}

iframe {
Expand All @@ -94,23 +116,38 @@
</style>
</head>
<body>
<div id="main">

<div class="inputs">
<div id="stream" class="input">
<label for="stream-edit-url">Stream:</label>
<input type="text" id="stream-edit-url" size=100 value="">
<button id="stream-button-load">LOAD</button>
<button id="stream-button-stop">STOP</button>
<!-- <button id="button-draw">Draw</button> -->
</div>

<main>

<div class="inputs">
<div id="stream" class="input">
<label for="stream-edit-url">Stream:</label>
<input type="text" id="stream-edit-url" class="flex-edit" value="">
<button id="stream-button-load">LOAD</button>
<button id="stream-button-stop">STOP</button>
</div>

<div id="player">
<video id="video" controls autoplay muted></video>
<div id="creative" class="input">
<label for="creative-edit-url">Creative:</label>
<input type="text" id="creative-edit-url" class="flex-edit" value="">
<label for="creative-edit-adparams">Ad params:</label>
<input type="text" id="creative-edit-adparams" class="flex-edit" value='{"bannerText":"Click here to draw!","webUrl":"https://quickdraw.withgoogle.com/"}'>
<label for="creative-edit-duration">duration:</label>
<input type="text" id="creative-edit-duration" size=10 value="">
<button id="creative-button-start">START</button> </div>
</div>
</div>

<div class="app">
<div id="player-container">
<div id="player">
<video id="video" controls autoplay muted></video>
</div>
<!-- iframe -->
</div>
</div>

</main>

</body>
<script>
document.addEventListener('DOMContentLoaded', function () {
Expand Down
Loading