mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Fix some build issues
This commit is contained in:
parent
1ee834d42b
commit
85a32d18d3
4 changed files with 110 additions and 35 deletions
|
|
@ -134,25 +134,24 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// applicationVariants.all {
|
applicationVariants.all {
|
||||||
// val variant = this
|
val variant = this
|
||||||
// variant.outputs
|
variant.outputs
|
||||||
// .map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl }
|
.map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl }
|
||||||
// .forEach { output ->
|
.forEach { output ->
|
||||||
// val outputFileName =
|
val outputFileName =
|
||||||
// "Wholphin-${variant.baseName}-${variant.versionName}-${variant.versionCode}.apk"
|
"Wholphin-${variant.baseName}-${variant.versionName}-${variant.versionCode}.apk"
|
||||||
// output.outputFileName = outputFileName
|
output.outputFileName = outputFileName
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
splits {
|
splits {
|
||||||
abi {
|
abi {
|
||||||
isEnable = true
|
isEnable = false
|
||||||
reset()
|
reset()
|
||||||
include("arm64-v8a")
|
// include("armeabi-v7a", "arm64-v8a")
|
||||||
// include("armeabi-v7a") // TODO
|
isUniversalApk = true
|
||||||
isUniversalApk = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -186,24 +185,6 @@ aboutLibraries {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map versionCode so each ABI gets a different one
|
|
||||||
// e.g. x86 with version 21 gets a versionCode of 3021
|
|
||||||
// val abiCodes = mapOf("armeabi-v7a" to 1, "arm64-v8a" to 2, "x86" to 3, "x86_64" to 4)
|
|
||||||
// val universalBase = 8000
|
|
||||||
// android.applicationVariants.all { variant ->
|
|
||||||
// variant.outputs.forEach { output ->
|
|
||||||
// val base = output.filters.firstOrNull { it.filterType==VariantOutput.ABI }
|
|
||||||
// // val base = abiCodes.get(output.getFilter(VariantOutput.ABI))
|
|
||||||
// // universal APK just gets a constant added to it
|
|
||||||
// if (base != null) {
|
|
||||||
// output.versionCodeOverride = base * 1000 + variant.versionCode
|
|
||||||
// } else {
|
|
||||||
// output.versionCodeOverride = universalBase + variant.versionCode
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// true
|
|
||||||
// }
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.androidx.core.ktx)
|
implementation(libs.androidx.core.ktx)
|
||||||
implementation(libs.androidx.appcompat)
|
implementation(libs.androidx.appcompat)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.github.damontecres.wholphin.util.mpv
|
||||||
|
|
||||||
|
import com.github.damontecres.wholphin.util.mpv.MPVLib.MpvFormat.MPV_FORMAT_DOUBLE
|
||||||
|
import com.github.damontecres.wholphin.util.mpv.MPVLib.MpvFormat.MPV_FORMAT_FLAG
|
||||||
|
import com.github.damontecres.wholphin.util.mpv.MPVLib.MpvFormat.MPV_FORMAT_INT64
|
||||||
|
import com.github.damontecres.wholphin.util.mpv.MPVLib.MpvFormat.MPV_FORMAT_NONE
|
||||||
|
import com.github.damontecres.wholphin.util.mpv.MPVLib.MpvFormat.MPV_FORMAT_STRING
|
||||||
|
|
||||||
|
object MPVProperty {
|
||||||
|
const val POSITION = "time-pos"
|
||||||
|
const val DURATION = "duration/full"
|
||||||
|
const val PAUSED = "pause"
|
||||||
|
const val PAUSED_FOR_CACHE = "paused-for-cache"
|
||||||
|
const val SPEED = "speed"
|
||||||
|
const val TRACK_LIST = "track-list"
|
||||||
|
const val ASPECT = "video-params/aspect"
|
||||||
|
const val ROTATE = "video-params/rotate"
|
||||||
|
const val TRACK_VIDEO = "current-tracks/video/image"
|
||||||
|
const val METADATA = "metadata"
|
||||||
|
const val HWDEC = "hwdec-current"
|
||||||
|
const val MUTE = "mute"
|
||||||
|
const val TRACK_AUDIO = "current-tracks/audio/selected"
|
||||||
|
|
||||||
|
val observedProperties =
|
||||||
|
mapOf(
|
||||||
|
POSITION to MPV_FORMAT_INT64,
|
||||||
|
DURATION to MPV_FORMAT_DOUBLE,
|
||||||
|
PAUSED to MPV_FORMAT_FLAG,
|
||||||
|
PAUSED_FOR_CACHE to MPV_FORMAT_FLAG,
|
||||||
|
SPEED to MPV_FORMAT_STRING,
|
||||||
|
TRACK_LIST to MPV_FORMAT_NONE,
|
||||||
|
ASPECT to MPV_FORMAT_DOUBLE,
|
||||||
|
ROTATE to MPV_FORMAT_DOUBLE,
|
||||||
|
TRACK_VIDEO to MPV_FORMAT_NONE,
|
||||||
|
METADATA to MPV_FORMAT_NONE,
|
||||||
|
HWDEC to MPV_FORMAT_NONE,
|
||||||
|
MUTE to MPV_FORMAT_FLAG,
|
||||||
|
TRACK_AUDIO to MPV_FORMAT_NONE,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -25,12 +25,16 @@ import androidx.media3.common.text.CueGroup
|
||||||
import androidx.media3.common.util.Size
|
import androidx.media3.common.util.Size
|
||||||
import androidx.media3.common.util.UnstableApi
|
import androidx.media3.common.util.UnstableApi
|
||||||
import androidx.media3.common.util.Util
|
import androidx.media3.common.util.Util
|
||||||
|
import timber.log.Timber
|
||||||
|
import kotlin.concurrent.atomics.ExperimentalAtomicApi
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
|
@kotlin.OptIn(ExperimentalAtomicApi::class)
|
||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
class MpvPlayer(
|
class MpvPlayer(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
) : BasePlayer() {
|
) : BasePlayer(),
|
||||||
|
MPVLib.EventObserver {
|
||||||
private var surface: Surface? = null
|
private var surface: Surface? = null
|
||||||
private val listeners = mutableListOf<Player.Listener>()
|
private val listeners = mutableListOf<Player.Listener>()
|
||||||
private val looper = Util.getCurrentOrMainLooper()
|
private val looper = Util.getCurrentOrMainLooper()
|
||||||
|
|
@ -42,8 +46,13 @@ class MpvPlayer(
|
||||||
init {
|
init {
|
||||||
MPVLib.create(context)
|
MPVLib.create(context)
|
||||||
MPVLib.init()
|
MPVLib.init()
|
||||||
MPVLib.setOptionString("hwdec", "mediacodec,mediacodec-copy")
|
// TODO add option for enabling HW decoding
|
||||||
|
// MPVLib.setOptionString("hwdec", "mediacodec,mediacodec-copy")
|
||||||
|
// MPVLib.setOptionString("vo", "gpu")
|
||||||
MPVLib.setOptionString("gpu-context", "android")
|
MPVLib.setOptionString("gpu-context", "android")
|
||||||
|
// TODO disable HW decoding for now
|
||||||
|
MPVLib.setOptionString("hwdec", "no")
|
||||||
|
|
||||||
MPVLib.setOptionString("opengl-es", "yes")
|
MPVLib.setOptionString("opengl-es", "yes")
|
||||||
MPVLib.setOptionString("hwdec-codecs", "h264,hevc,mpeg4,mpeg2video,vp8,vp9,av1")
|
MPVLib.setOptionString("hwdec-codecs", "h264,hevc,mpeg4,mpeg2video,vp8,vp9,av1")
|
||||||
val cacheMegs = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) 64 else 32
|
val cacheMegs = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) 64 else 32
|
||||||
|
|
@ -53,6 +62,8 @@ class MpvPlayer(
|
||||||
MPVLib.setOptionString("force-window", "no")
|
MPVLib.setOptionString("force-window", "no")
|
||||||
// need to idle at least once for playFile() logic to work
|
// need to idle at least once for playFile() logic to work
|
||||||
MPVLib.setOptionString("idle", "once")
|
MPVLib.setOptionString("idle", "once")
|
||||||
|
MPVLib.addObserver(this)
|
||||||
|
MPVProperty.observedProperties.forEach(MPVLib::observeProperty)
|
||||||
|
|
||||||
availableCommands =
|
availableCommands =
|
||||||
Player.Commands
|
Player.Commands
|
||||||
|
|
@ -228,7 +239,7 @@ class MpvPlayer(
|
||||||
override fun getCurrentMediaItemIndex(): Int = 0
|
override fun getCurrentMediaItemIndex(): Int = 0
|
||||||
|
|
||||||
override fun getDuration(): Long {
|
override fun getDuration(): Long {
|
||||||
val duration = MPVLib.getPropertyDouble("duration")!!.milliseconds.inWholeMilliseconds
|
val duration = MPVLib.getPropertyDouble("duration/full")!!.milliseconds.inWholeMilliseconds
|
||||||
return duration
|
return duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,17 +290,22 @@ class MpvPlayer(
|
||||||
this.surfaceSize = if (surface == null) Size(0, 0) else Size.UNKNOWN
|
this.surfaceSize = if (surface == null) Size(0, 0) else Size.UNKNOWN
|
||||||
if (surface != null) {
|
if (surface != null) {
|
||||||
this.surface = surface
|
this.surface = surface
|
||||||
|
Timber.v("Queued attach")
|
||||||
MPVLib.attachSurface(surface)
|
MPVLib.attachSurface(surface)
|
||||||
MPVLib.setOptionString("force-window", "yes")
|
MPVLib.setOptionString("force-window", "yes")
|
||||||
|
Timber.d("Attached surface")
|
||||||
|
|
||||||
val url = mediaItem!!.localConfiguration?.uri.toString()
|
val url = mediaItem!!.localConfiguration?.uri.toString()
|
||||||
MPVLib.command(arrayOf("loadfile", url))
|
MPVLib.command(arrayOf("loadfile", url))
|
||||||
|
MPVLib.setPropertyString("vo", "gpu")
|
||||||
|
Timber.d("Called loadfile")
|
||||||
} else {
|
} else {
|
||||||
clearVideoSurfaceView(null)
|
clearVideoSurfaceView(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearVideoSurfaceView(surfaceView: SurfaceView?) {
|
override fun clearVideoSurfaceView(surfaceView: SurfaceView?) {
|
||||||
|
Timber.d("Detaching surface")
|
||||||
MPVLib.detachSurface()
|
MPVLib.detachSurface()
|
||||||
MPVLib.setPropertyString("vo", "null")
|
MPVLib.setPropertyString("vo", "null")
|
||||||
MPVLib.setPropertyString("force-window", "no")
|
MPVLib.setPropertyString("force-window", "no")
|
||||||
|
|
@ -389,4 +405,40 @@ class MpvPlayer(
|
||||||
}
|
}
|
||||||
MPVLib.setPropertyDouble("time-pos", positionMs.toDouble())
|
MPVLib.setPropertyDouble("time-pos", positionMs.toDouble())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun eventProperty(property: String) {
|
||||||
|
Timber.v("eventProperty: $property")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun eventProperty(
|
||||||
|
property: String,
|
||||||
|
value: Long,
|
||||||
|
) {
|
||||||
|
Timber.v("eventProperty: $property=$value")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun eventProperty(
|
||||||
|
property: String,
|
||||||
|
value: Boolean,
|
||||||
|
) {
|
||||||
|
Timber.v("eventProperty: $property=$value")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun eventProperty(
|
||||||
|
property: String,
|
||||||
|
value: String,
|
||||||
|
) {
|
||||||
|
Timber.v("eventProperty: $property=$value")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun eventProperty(
|
||||||
|
property: String,
|
||||||
|
value: Double,
|
||||||
|
) {
|
||||||
|
Timber.v("eventProperty: $property=$value")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun event(eventId: Int) {
|
||||||
|
Timber.v("event: $eventId")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,3 +66,5 @@ if [[ ! -d lua ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# python packages: jsonschema jinja2 meson
|
# python packages: jsonschema jinja2 meson
|
||||||
|
|
||||||
|
popd || exit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue