Skip to content

Commit

Permalink
Releases/v0.3.0 (#16)
Browse files Browse the repository at this point in the history
## New

* new: Add max and min playback resolution (#17)

## Updates

* update: Improve example app appearance + misc updates (#14)


Co-authored-by: Emily Dixon <edixon@mux.com>
Co-authored-by: Tom Kordic <tkordic+private@github.com>
  • Loading branch information
daytime-em and Tom Kordic authored Nov 18, 2023
1 parent 961ceaa commit 0cbc705
Show file tree
Hide file tree
Showing 16 changed files with 314 additions and 53 deletions.
9 changes: 4 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ plugins {
}

android {
namespace = "com.mux.video.media3"
namespace = "com.mux.player.media3"
compileSdk = 34

defaultConfig {
applicationId = "com.mux.video.media3"
minSdk = 21
targetSdk = 33
targetSdk = 34
versionCode = 1
versionName = "1.0"

Expand Down Expand Up @@ -38,9 +37,9 @@ android {
dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.9.0")
implementation("com.google.android.material:material:1.10.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.recyclerview:recyclerview:1.3.1")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation(project(":library"))

testImplementation("junit:junit:4.13.2")
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@
tools:targetApi="31">
<activity
android:name=".examples.BasicPlayerActivity"
android:exported="false" />
android:exported="false"
android:label="Basic Foreground Player" />
<activity android:name=".examples.MaxResActivity"
android:exported="false"
android:label="Max-Res Modifier"
/>
<activity
android:name=".MainActivity"
android:exported="true">
android:exported="true"
android:label="Examples"
android:theme="@style/Theme.MuxVideoMedia3.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/com/mux/player/media3/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ package com.mux.player.media3
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.mux.player.media3.databinding.ActivityMainBinding
import com.mux.player.media3.databinding.ListitemExampleBinding
import com.mux.player.media3.examples.BasicPlayerActivity
import com.mux.video.media3.databinding.ActivityMainBinding
import com.mux.video.media3.databinding.ListitemExampleBinding
import com.mux.player.media3.examples.MaxResActivity

class MainActivity : AppCompatActivity() {

Expand All @@ -24,6 +26,10 @@ class MainActivity : AppCompatActivity() {
setContentView(binding.root)
examplesView.layoutManager = LinearLayoutManager(this)

binding.mainExampleTb.apply {
setLogo(R.drawable.mux_logo)
}

setUpExampleList()
}

Expand All @@ -36,6 +42,10 @@ class MainActivity : AppCompatActivity() {
Example(
title = "Basic Foreground Player",
destination = Intent(this@MainActivity, BasicPlayerActivity::class.java)
),
Example(
title = "Max-Resolution Modifier",
destination = Intent(this@MainActivity, MaxResActivity::class.java)
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import com.mux.stats.sdk.core.model.CustomerViewData
import com.mux.stats.sdk.core.util.UUID
import com.mux.player.MuxPlayer
import com.mux.player.media.MediaItems
import com.mux.player.media.PlaybackMaxResolution
import com.mux.player.media.PlaybackResolution
import com.mux.player.media3.PlaybackIds
import com.mux.video.media3.databinding.ActivityBasicPlayerBinding
import com.mux.player.media3.databinding.ActivityBasicPlayerBinding

/**
* A simple example that uses the normal media3 player UI to play a video in the foreground from
Expand Down Expand Up @@ -59,8 +59,6 @@ class BasicPlayerActivity : AppCompatActivity() {
val player = createPlayer(this)
val mediaItem = MediaItems.builderFromMuxPlaybackId(
PlaybackIds.TEARS_OF_STEEL,
// PlaybackResolution.FHD_1080,
PlaybackMaxResolution.HD_720,
)
.setMediaMetadata(
MediaMetadata.Builder()
Expand Down
122 changes: 122 additions & 0 deletions app/src/main/java/com/mux/player/media3/examples/MaxResActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package com.mux.player.media3.examples

import android.content.Context
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import androidx.annotation.OptIn
import androidx.appcompat.app.AppCompatActivity
import androidx.media3.common.MediaMetadata
import androidx.media3.common.PlaybackException
import androidx.media3.common.Player
import androidx.media3.common.util.UnstableApi
import com.mux.stats.sdk.core.model.CustomData
import com.mux.stats.sdk.core.model.CustomerData
import com.mux.stats.sdk.core.model.CustomerVideoData
import com.mux.stats.sdk.core.model.CustomerViewData
import com.mux.stats.sdk.core.util.UUID
import com.mux.player.MuxPlayer
import com.mux.player.media.MediaItems
import com.mux.player.media.PlaybackResolution
import com.mux.player.media3.PlaybackIds
import com.mux.player.media3.databinding.ActivityBasicPlayerBinding

/**
* A simple example that uses the normal media3 player UI to play a video in the foreground from
* Mux Video, using a Playback ID
*/
class MaxResActivity : AppCompatActivity() {

private lateinit var binding: ActivityBasicPlayerBinding
private val playerView get() = binding.player

private var player: MuxPlayer? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityBasicPlayerBinding.inflate(layoutInflater)
setContentView(binding.root)
}

override fun onStart() {
super.onStart()

playSomething()
}

override fun onStop() {
tearDownPlayer()

super.onStop()
}

private fun tearDownPlayer() {
playerView.player = null
player?.release()
}

private fun playSomething() {
val player = createPlayer(this)
val mediaItem = MediaItems.builderFromMuxPlaybackId(
PlaybackIds.TEARS_OF_STEEL,
maxResolution = PlaybackResolution.HD_720,
)
.setMediaMetadata(
MediaMetadata.Builder()
.setTitle("Basic MuxExoPlayer Example")
.build()
)
.build()
player.setMediaItem(mediaItem)
player.prepare()
player.playWhenReady = true

this.playerView.player = player
this.player = player
}

@OptIn(UnstableApi::class)
private fun createPlayer(context: Context): MuxPlayer {
val out: MuxPlayer = MuxPlayer.Builder(context)
.addMonitoringData(
CustomerData().apply {
customerViewData = CustomerViewData().apply {
viewSessionId = UUID.generateUUID()
}
customerVideoData = CustomerVideoData().apply {
videoSeries = "My Series"
videoId = "abc1234zyxw"
}
customData = CustomData().apply {
customData1 = "my custom metadata field"
customData2 = "another custom metadata field"
customData10 = "up to 10 custom fields"
}
}
)
.applyExoConfig {
// Call ExoPlayer.Builder methods here
setHandleAudioBecomingNoisy(true)
setSeekBackIncrementMs(10_000)
setSeekForwardIncrementMs(30_000)
}
.build()

out.addListener(object : Player.Listener {
override fun onPlayerError(error: PlaybackException) {
Log.e(TAG, "player error!", error)
Toast.makeText(
this@MaxResActivity,
"Playback error! ${error.localizedMessage}",
Toast.LENGTH_LONG
).show()
}
})

return out
}

companion object {
val TAG = MaxResActivity::class.simpleName
}
}
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/mux_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="45dp"
android:height="14dp"
android:viewportWidth="90"
android:viewportHeight="28">
<group>
<clip-path
android:pathData="M0,0h90v28h-90z"/>
<path
android:pathData="M55.929,0C53.988,0 52.414,1.567 52.414,3.499V14C52.414,17.861 49.259,21.002 45.381,21.002C41.504,21.002 38.348,17.861 38.348,14V3.499C38.348,1.567 36.775,0 34.834,0C32.893,0 31.319,1.567 31.319,3.499V14C31.319,21.72 37.628,28 45.382,28C53.136,28 59.444,21.72 59.444,14V3.499C59.444,1.567 57.871,0 55.93,0H55.929ZM55.929,5.235C54.966,5.235 54.185,4.458 54.185,3.499C54.185,2.541 54.966,1.763 55.929,1.763C56.892,1.763 57.673,2.541 57.673,3.499C57.673,4.458 56.892,5.235 55.929,5.235Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M70.967,14L62.904,22.027C61.532,23.393 61.532,25.609 62.904,26.975C64.277,28.342 66.503,28.342 67.875,26.975L75.938,18.949L84,26.975C85.372,28.342 87.598,28.342 88.971,26.975C90.343,25.609 90.343,23.393 88.971,22.027L80.908,14L88.971,5.974C90.343,4.607 90.343,2.391 88.971,1.025C87.598,-0.342 85.372,-0.342 84,1.025L75.938,9.051L67.875,1.025C66.503,-0.342 64.277,-0.342 62.904,1.025C61.532,2.391 61.532,4.607 62.904,5.974L70.967,14ZM86.485,26.237C85.522,26.237 84.741,25.459 84.741,24.501C84.741,23.542 85.522,22.765 86.485,22.765C87.448,22.765 88.229,23.542 88.229,24.501C88.229,25.459 87.448,26.237 86.485,26.237Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M25.955,0.267C24.642,-0.275 23.13,0.024 22.125,1.025L14.063,9.051L6,1.025C4.995,0.024 3.483,-0.275 2.17,0.267C0.856,0.808 0,2.084 0,3.5V24.501C0,26.433 1.574,28 3.515,28C5.456,28 7.03,26.433 7.03,24.501V11.947L11.577,16.474C12.95,17.841 15.176,17.841 16.548,16.474L21.095,11.947V24.501C21.095,26.433 22.669,28 24.611,28C26.552,28 28.126,26.433 28.126,24.501V3.5C28.126,2.084 27.269,0.808 25.956,0.267H25.955ZM24.611,26.237C23.647,26.237 22.867,25.46 22.867,24.501C22.867,23.542 23.647,22.765 24.611,22.765C25.573,22.765 26.354,23.542 26.354,24.501C26.354,25.46 25.573,26.237 24.611,26.237Z"
android:fillColor="#ffffff"/>
</group>
</vector>
25 changes: 24 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,33 @@
android:layout_height="match_parent"
tools:context=".MainActivity">

<androidx.appcompat.widget.Toolbar
android:id="@+id/main_example_tb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/Gray100"
app:layout_constraintTop_toTopOf="parent"
app:logo="@drawable/mux_logo"
/>

<TextView
android:id="@+id/main_example_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?textAppearanceCaption"
android:text="Mux Player Examples"
android:textColor="@color/White"
android:padding="18dp"
app:layout_constraintTop_toBottomOf="@id/main_example_tb"
app:layout_constraintStart_toStartOf="parent"
/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/main_example_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/main_example_subtitle"
app:layout_constraintBottom_toBottomOf="parent"
/>

</androidx.constraintlayout.widget.ConstraintLayout>
8 changes: 6 additions & 2 deletions app/src/main/res/layout/listitem_example.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">

<TextView
android:id="@+id/example_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Material.Medium"
android:textColor="?colorOnPrimary"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:text="Lorem Ipsum blah blah"
/>

</androidx.constraintlayout.widget.ConstraintLayout>
35 changes: 26 additions & 9 deletions app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,32 @@
<!-- Base application theme. -->
<style name="Theme.MuxVideoMedia3" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/black</item>
<item name="colorPrimary">@color/Green50</item>
<item name="colorPrimaryVariant">@color/Green60</item>
<item name="colorOnPrimary">@color/White</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<item name="colorSecondary">@color/Pink40</item>
<item name="colorOnSecondary">@color/White</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="android:statusBarColor">@color/Gray100</item>
<!-- Surface color -->
<item name="colorSurface">@color/Gray100</item>
<item name="colorOnSurface">@color/White</item>
<item name="android:colorBackground">@color/BackgroundDark</item>
</style>
</resources>
<style name="Theme.MuxVideoMedia3.NoActionBar" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/Green50</item>
<item name="colorPrimaryVariant">@color/Green60</item>
<item name="colorOnPrimary">@color/White</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/Pink40</item>
<item name="colorOnSecondary">@color/White</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">@color/Gray100</item>
<!-- Surface color -->
<item name="colorSurface">@color/Gray100</item>
<item name="colorOnSurface">@color/White</item>
<item name="android:colorBackground">@color/BackgroundDark</item>
</style>
</resources>
15 changes: 15 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,19 @@
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>

<!-- Mux Colors -->
<color name="Green50">#FF00AA3C</color>
<color name="Green60">#FF00802D</color>
<color name="Green70">#FF005C20</color>
<color name="Gray30">#FFB2BAC2</color>
<color name="Gray50">#FF808C99</color>
<color name="Gray70">#FF565E67</color>
<color name="Gray80">#FF3E4247</color>
<color name="Gray90">#FF242628</color>
<color name="Gray100">#FF0A0A0B</color>
<color name="Pink40">#FFFB65D5</color>
<color name="White">#FFFFFFFF</color>

<color name="BackgroundDark">#FF1E1E1E</color>
</resources>
Loading

0 comments on commit 0cbc705

Please sign in to comment.