feat: apple music support (partly broken)
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
001e58bc3c
commit
3b2a1172e9
|
|
@ -0,0 +1,56 @@
|
||||||
|
package chat.revolt.components.chat.specialembeds
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.net.Uri
|
||||||
|
import android.webkit.WebView
|
||||||
|
import androidx.compose.foundation.layout.requiredHeight
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.viewinterop.AndroidView
|
||||||
|
import chat.revolt.api.schemas.Special
|
||||||
|
import chat.revolt.api.settings.GlobalState
|
||||||
|
import chat.revolt.ui.theme.isThemeDark
|
||||||
|
|
||||||
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
|
@Composable
|
||||||
|
fun AppleMusicEmbed(special: Special, modifier: Modifier = Modifier) {
|
||||||
|
val useDarkTheme = isThemeDark(GlobalState.theme)
|
||||||
|
|
||||||
|
AndroidView(
|
||||||
|
factory = { ctx ->
|
||||||
|
WebView(ctx).apply {
|
||||||
|
settings.apply {
|
||||||
|
javaScriptEnabled = true
|
||||||
|
mediaPlaybackRequiresUserGesture = false
|
||||||
|
javaScriptCanOpenWindowsAutomatically = true
|
||||||
|
builtInZoomControls = false
|
||||||
|
loadWithOverviewMode = true
|
||||||
|
useWideViewPort = true
|
||||||
|
displayZoomControls = false
|
||||||
|
setSupportZoom(false)
|
||||||
|
isVerticalScrollBarEnabled = false
|
||||||
|
isHorizontalScrollBarEnabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
update = {
|
||||||
|
val embedUrl = Uri.Builder().apply {
|
||||||
|
scheme("https")
|
||||||
|
authority("embed.music.apple.com")
|
||||||
|
appendPath("album")
|
||||||
|
appendPath("")
|
||||||
|
appendPath(special.albumID)
|
||||||
|
appendQueryParameter("theme", if (useDarkTheme) "dark" else "light")
|
||||||
|
}
|
||||||
|
it.loadUrl(embedUrl.toString())
|
||||||
|
},
|
||||||
|
modifier = modifier
|
||||||
|
.clip(MaterialTheme.shapes.medium)
|
||||||
|
.width(400.dp)
|
||||||
|
.requiredHeight(450.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -8,6 +8,7 @@ import chat.revolt.api.schemas.Special
|
||||||
fun SpecialEmbedSwitch(special: Special, modifier: Modifier = Modifier) {
|
fun SpecialEmbedSwitch(special: Special, modifier: Modifier = Modifier) {
|
||||||
when (special.type) {
|
when (special.type) {
|
||||||
"YouTube" -> YoutubeEmbedSwitch(special, modifier)
|
"YouTube" -> YoutubeEmbedSwitch(special, modifier)
|
||||||
|
"AppleMusic" -> AppleMusicEmbed(special, modifier)
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue