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