apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.65k stars 1.54k forks source link

Videos are not seekable (WebViewAssetLoader needs to support range requests) #1494

Open AshleyScirra opened 2 years ago

AshleyScirra commented 2 years ago

Bug Report

Problem

Videos in cordova-android are not seekable, apparently since the introduction of WebViewAssetLoader in v10.

Sample Cordova project: TestVideo.zip

When built and run on a device, touch the red circle to play a video. Touch the orange bar to seek to 10 seconds (this sets currentTime on the HTMLVideoElement).

What is expected to happen?

Video to seek to 10 second point in video.

What does actually happen?

Video restarts.

Information

I believe the problem is that WebViewAssetLoader returns 200 OK for all responses.

However Chrome can't allow media elements to be seekable unless the "server" supports range requests. This is of course designed to work over the network, but even though the resources are all local, it still must correctly handle range requests in order to allow media to be seekable. So I think if WebViewAssetLoader serves range requests as expected it will fix this problem.

I'm not sure if the API is the same but this fix from the Ionic team looks relevant: https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/298

Command or Code

Build and run provided Cordova project on an Android device.

Environment, Platform, Device

Tested on Asus ZenFone 8 with Android 12. Also reported to happen on Samsung S5e Tablet (see https://github.com/Scirra/Construct-3-bugs/issues/6122).

Version information

Cordova Android v11.0.0

Checklist

jcesarmobile commented 1 year ago

Cordova-android doesn’t use the same API, it doesn’t handle the requests directly, it uses WebViewAssetLoader https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader so should be the google team in charge of that package the ones who should fix it.