改为file协议,mac无法播放,试试windows
This commit is contained in:
@@ -118,19 +118,31 @@ async function updateVideoSrc() {
|
|||||||
const isWindowsPath = /^[a-zA-Z]:[\\/]|^\\/.test(raw)
|
const isWindowsPath = /^[a-zA-Z]:[\\/]|^\\/.test(raw)
|
||||||
|
|
||||||
if (isWindowsPath) {
|
if (isWindowsPath) {
|
||||||
// Windows: Use Tauri's asset protocol for absolute paths
|
// Windows: Use file:// protocol for local file access
|
||||||
// Convert backslashes to forward slashes and use asset:// protocol
|
// Convert backslashes to forward slashes and use file:// protocol
|
||||||
const normalizedPath = raw.replace(/\\/g, '/')
|
let normalizedPath = raw.replace(/\\/g, '/')
|
||||||
videoSrc.value = `asset://localhost/${normalizedPath}`
|
|
||||||
} else {
|
|
||||||
// Unix-like: Use HTTP protocol for both Tauri and development
|
|
||||||
const filename = raw.split(/[/\\]/).pop() || "video.mp4";
|
|
||||||
|
|
||||||
// Use relative HTTP URL for bundled resources
|
// Ensure proper file:// format with drive letter
|
||||||
if (filename === 'video.mp4') {
|
if (!normalizedPath.startsWith('/')) {
|
||||||
videoSrc.value = '/video.mp4'
|
normalizedPath = '/' + normalizedPath
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicate slashes
|
||||||
|
normalizedPath = normalizedPath.replace(/\/+/g, '/')
|
||||||
|
|
||||||
|
videoSrc.value = `file://${normalizedPath}`
|
||||||
|
} else {
|
||||||
|
// Unix-like: Use file:// protocol for absolute paths
|
||||||
|
if (raw.startsWith('/')) {
|
||||||
|
videoSrc.value = `file://${raw}`
|
||||||
} else {
|
} else {
|
||||||
videoSrc.value = `/${filename}`
|
// Use relative HTTP URL for bundled resources
|
||||||
|
const filename = raw.split(/[/\\]/).pop() || "video.mp4";
|
||||||
|
if (filename === 'video.mp4') {
|
||||||
|
videoSrc.value = '/video.mp4'
|
||||||
|
} else {
|
||||||
|
videoSrc.value = `/${filename}`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
src-tauri/Cargo.lock
generated
7
src-tauri/Cargo.lock
generated
@@ -1576,6 +1576,12 @@ dependencies = [
|
|||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "http-range"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "httparse"
|
name = "httparse"
|
||||||
version = "1.10.1"
|
version = "1.10.1"
|
||||||
@@ -3817,6 +3823,7 @@ dependencies = [
|
|||||||
"gtk",
|
"gtk",
|
||||||
"heck 0.5.0",
|
"heck 0.5.0",
|
||||||
"http",
|
"http",
|
||||||
|
"http-range",
|
||||||
"jni",
|
"jni",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
|
@@ -33,7 +33,7 @@ env_logger = "0.11"
|
|||||||
|
|
||||||
[dependencies.tauri]
|
[dependencies.tauri]
|
||||||
version = "2.6.2"
|
version = "2.6.2"
|
||||||
features = [
|
features = [ "protocol-asset",
|
||||||
"tray-icon",
|
"tray-icon",
|
||||||
"unstable"
|
"unstable"
|
||||||
]
|
]
|
||||||
|
@@ -51,7 +51,11 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"security": {
|
"security": {
|
||||||
"csp": null
|
"csp": null,
|
||||||
|
"assetProtocol": {
|
||||||
|
"enable": true,
|
||||||
|
"scope": ["**"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user