-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## 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
1 parent
961ceaa
commit 0cbc705
Showing
16 changed files
with
314 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
app/src/main/java/com/mux/player/media3/examples/MaxResActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.