Skip to content

Commit

Permalink
Attempt to show album image
Browse files Browse the repository at this point in the history
  • Loading branch information
Xwilarg committed Oct 31, 2024
1 parent 1b2ffe7 commit 0b202ba
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.euphonia

import android.content.Intent
import androidx.media3.common.MediaItem
import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.session.MediaSession
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.example.euphonia.ui

import android.graphics.BitmapFactory
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.media3.common.MediaItem
import androidx.media3.common.Player
import androidx.media3.common.util.Log
import androidx.media3.common.util.UnstableApi
import androidx.media3.ui.PlayerView
import com.example.euphonia.R
Expand All @@ -28,7 +33,21 @@ class PlayFragment : Fragment() {

pView.controllerFuture?.addListener(
{
videoView.player = pView.controllerFuture!!.get()
val player = pView.controllerFuture!!.get()
videoView.player = player
player.addListener(object : Player.Listener {
override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
val view = pView.findViewById<ImageView>(R.id.exo_image)
if (view != null) {
view.setImageBitmap(null)
val bmp = BitmapFactory.decodeFile(mediaItem!!.mediaMetadata.artworkUri!!.path)
if (bmp != null) {
view.setImageBitmap(bmp)
Log.d("TEMPS", mediaItem!!.mediaMetadata.artworkUri!!.path.toString())
}
}
}
})
},
MoreExecutors.directExecutor()
)
Expand Down
7 changes: 6 additions & 1 deletion android/app/src/main/res/layout/player_controls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/exo_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@color/cardview_light_background"/>

<LinearLayout
android:layout_gravity="center"
android:gravity="center"
Expand All @@ -17,5 +23,4 @@
style="@style/ExoStyledControls.Button.Center.Next"/>
</LinearLayout>


</FrameLayout>

0 comments on commit 0b202ba

Please sign in to comment.