From 257e32d7119887a4b2cdf6b84e9c251d3631ec71 Mon Sep 17 00:00:00 2001 From: Brayan Oliveira <69634269+brayandso@users.noreply.github.com> Date: Sat, 23 Dec 2023 07:04:00 -0300 Subject: [PATCH] fix: not being able to seek videos --- .../java/com/ichi2/libanki/TemplateManager.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt index a9a19229519b..51b71ada2db7 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt @@ -184,16 +184,17 @@ class TemplateManager { * because of old webview codecs in python, and to allow extending the video player. * To simplify things and deliver a better result, * we use the webview player, like AnkiMobile does + * + * `file:///` is used to enable seeking the video */ - fun parseVideos(text: String): String { + fun parseVideos(text: String, mediaDir: String): String { return SOUND_RE.replace(text) { match -> val fileName = match.groupValues[1] val extension = fileName.substringAfterLast(".", "") if (extension in VIDEO_EXTENSIONS) { - @Suppress("HtmlUnknownAttribute") // controlsList is valid, but marked as invalid in the IDE @Language("HTML") val result = - """""" + """""" result } else { match.value @@ -201,11 +202,18 @@ class TemplateManager { } } - val qtext = parseVideos(applyCustomFilters(partial.qnodes, this, front_side = null)) + val mediaDir = col().media.dir + val qtext = parseVideos( + text = applyCustomFilters(partial.qnodes, this, front_side = null), + mediaDir = mediaDir + ) val qout = col().backend.extractAvTags(text = qtext, questionSide = true) var qoutText = qout.text - val atext = parseVideos(applyCustomFilters(partial.anodes, this, front_side = qout.text)) + val atext = parseVideos( + text = applyCustomFilters(partial.anodes, this, front_side = qout.text), + mediaDir = mediaDir + ) val aout = col().backend.extractAvTags(text = atext, questionSide = false) var aoutText = aout.text