Repository navigation
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
25.1.0
What operating system are you using?
Other Linux
Operating System Version
Linux Mint 21.1
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
I'm using a custom protocol in place of file:// URLs for a video player. This works:
protocol.registerFileProtocol("video", (request, callback) => {
callback(request.url.slice("video://".length)) // simplified path for this example
})Since protocol.registerFileProtocol got deprecated in version 25, I tried the suggested alternative protocol.handle as per the update notes:
protocol.handle("video", (request) => {
return net.fetch(request.url.replace(/^video:/, "file:")) // simplified path
})This allows me to play videos. However now when I set .currentTimeon a <video> element with a video://… source, it just jumps back to zero. video.seekable.end() is always 0. This breaks seeking in HTML5 videos with custom protocol URLs.
I've also tried this, with the same result:
protocol.handle("video", (request) => {
return new Response(fs.readFileSync(request.url.replace(/^video:/, "file:")))
})Not sure if it matters, the scheme is registered like this:
protocol.registerSchemesAsPrivileged([
{
scheme: "video",
privileges: {
secure: true,
bypassCSP: true,
stream: true,
},
},
])Expected behavior: The documented alternative to protocol.registerFileProtocol should allow serving seekable video files.
Actual Behavior
See above.
Testcase Gist URL
No response
Additional Information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsUnsorted Items
Activity
[-][Bug]: [/-][+][Bug]: video files not seekable with protocol.handle [/+]github-actions commentedon Jun 13, 2023
Hello @philer. Thanks for reporting this and helping to make Electron better!
Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use.
Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.
Now adding the
blocked/need-reprolabel for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed.philer commentedon Jun 13, 2023
@codebytere I don't think this is something I can reproduce in a fiddle…
takumus commentedon Jun 14, 2023
Hello!
I have the same problem on Windows.
Video files prepared using
protocol.handlecannot be seeked.Electron: 25.1.0
OS: Windows 11 Pro x64 10.0.22621 Build 22621
Fiddle:
https://gist.github.com/takumus/7b6d73df884df009f36bc6ff1979d5ff
This text was translated by Deepl.
65 remaining items
blurymind commentedon Aug 4, 2025
This pr resolves this problem? #47703
zoy-l commentedon Aug 9, 2025
Hey guys, here’s my solution. It works on version
37.2.6.macOS/Windowsworkdanielweck commentedon Aug 11, 2025
Yes, we shipped with v37 since this fix (before, we stayed on v36)
Upgrade Electron 33 → 40 to fix seek during playback
Fix local-file:// video range requests with manual fs.createReadStrea…
v0.87.38: FIX видео в отдельном окне — net.fetch + bypassCSP (из доку…
cxw2299 commentedon Jun 18, 2026
if my video without autoplay , After some time, an error occurred: "The operation was aborted."
feat(electron): Plan 10 — native yuu-media:// protocol for recording …
feat(electron): Plan 10 — native yuu-media:// protocol for recording …
fix: ローカル動画再生をcustom protocolからループバックHTTP配信へ変更
fix: address second review pass on appProtocol
akabekobeko commentedon Oct 3, 2026
Follow-up to my earlier comments (#38749 (comment)): I found what made
currentTimefail outside the buffered range, and it is not a bug inprotocol.handleor in the Range handling of the handler.Symptom
Audio served over a custom scheme (
protocol.handle,stream: true, correct206/Content-Range/Accept-Rangesresponses) plays fine, but settingcurrentTimeto a position outsidebufferedstops playback with:Cause
Chromium's media stack validates that every Range response for a resource comes from the same origin as the first one (
UrlData::ValidateDataOrigininthird_party/blink/renderer/platform/media/url_index.cc). The check only runs when the element is loaded in no-cors mode (cors_mode_ == CORS_UNSPECIFIED, i.e. nocrossOriginattribute):A custom scheme that is not registered with
standard: truehas no host-based origin. Each comparison creates a fresh opaque origin, so the first response passes (nothing to compare yet) and the very first follow-up Range request, which a seek outsidebufferedtriggers, fails the check. The data source is marked failed and the demuxer reportsPIPELINE_ERROR_READ.This also explains the observations in this thread and in #51442 that adding
standard: truemade seeking work: a standard scheme yields a stable tuple origin, so the comparison succeeds.Verified on Electron 44.4.5 (macOS, Apple Silicon)
Same app, same protocol handler, same files (1 h m4a and CBR mp3); the only difference is how the element is loaded:
<audio>load modebufferedcrossOrigin(opaque response)PIPELINE_ERROR_READcrossOrigin = "anonymous"+Access-Control-Allow-Origin: *on every response +corsEnabled: trueon the schemeRange: bytes=N-and playback continuesFull write-up and the fix are in akabekobeko/parade#269 (the PR description is in Japanese; the summary above covers the same findings in English).
Workarounds
Either of these is enough:
standard: trueso it has a real origin.crossOrigin = "anonymous"on the<audio>/<video>, addcorsEnabled: trueto the scheme privileges, and returnAccess-Control-Allow-Originon every response (including the206ones). This is also what you need anyway if the element feeds aMediaElementAudioSourceNode, which outputs silence for tainted sources.The handler itself still has to honor
Rangeand answer with206,Content-RangeandContent-Length, as others noted above. Chromium always sendsRange: bytes=0-on the first media request, so a handler that only looks at the no-Rangepath never sees the media element's requests.It might be worth a note in the
protocoldocs: for<audio>/<video>over a custom scheme, usestandard: trueor CORS mode, otherwise seeking fails once the element needs a byte range that is not buffered yet.fix: stream audio from the shell's HTTP origin so seeking works
fix: stream audio from the shell's HTTP origin so seeking works (#2)