mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-08-04 10:36:56 +00:00
Refactor code structure
This commit is contained in:
parent
2a21f294c5
commit
e31c39b1a6
4 changed files with 3809 additions and 3799 deletions
|
|
@ -197,14 +197,20 @@ internal object NativePlayerBridge {
|
|||
private fun exportControlsPageAssets(): ControlsPageAssets {
|
||||
val root = File(System.getProperty("java.io.tmpdir"), "nuvio-player-ui").apply { mkdirs() }
|
||||
val fontsDir = root.resolve("fonts").apply { mkdirs() }
|
||||
val htmlResource = "/player-ui/controls.html"
|
||||
val html = NativePlayerBridge::class.java.getResourceAsStream(htmlResource)
|
||||
?.bufferedReader()
|
||||
?.use { it.readText() }
|
||||
?: error("Missing native player controls resource: $htmlResource")
|
||||
val resolvedHtml = html.replace("/* __NUVIO_PLAYER_FONT_FACES__ */", nativePlayerFontFaces())
|
||||
val htmlFile = root.resolve("controls.html")
|
||||
writeTextIfChanged(htmlFile, resolvedHtml)
|
||||
writeTextIfChanged(
|
||||
target = htmlFile,
|
||||
text = readTextResource("/player-ui/controls.html"),
|
||||
)
|
||||
writeTextIfChanged(
|
||||
target = root.resolve("controls.css"),
|
||||
text = readTextResource("/player-ui/controls.css")
|
||||
.replace("/* __NUVIO_PLAYER_FONT_FACES__ */", nativePlayerFontFaces()),
|
||||
)
|
||||
copyResourceIfChanged(
|
||||
resource = "/player-ui/controls.js",
|
||||
target = root.resolve("controls.js"),
|
||||
)
|
||||
copyResourceIfChanged(
|
||||
resource = "/composeResources/nuvio.composeapp.generated.resources/font/jetbrains_sans_regular.ttf",
|
||||
target = fontsDir.resolve("jetbrains_sans_regular.ttf"),
|
||||
|
|
@ -247,6 +253,12 @@ internal object NativePlayerBridge {
|
|||
}
|
||||
""".trimIndent()
|
||||
|
||||
private fun readTextResource(resource: String): String =
|
||||
NativePlayerBridge::class.java.getResourceAsStream(resource)
|
||||
?.bufferedReader(Charsets.UTF_8)
|
||||
?.use { it.readText() }
|
||||
?: error("Missing native player controls resource: $resource")
|
||||
|
||||
private fun writeTextIfChanged(target: File, text: String) {
|
||||
val bytes = text.toByteArray(Charsets.UTF_8)
|
||||
if (target.exists() && target.readBytes().contentEquals(bytes)) return
|
||||
|
|
|
|||
1883
composeApp/src/desktopMain/resources/player-ui/controls.css
Normal file
1883
composeApp/src/desktopMain/resources/player-ui/controls.css
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
1905
composeApp/src/desktopMain/resources/player-ui/controls.js
vendored
Normal file
1905
composeApp/src/desktopMain/resources/player-ui/controls.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue