I am using an android 4.4.4
with armv7l
CPU.
For some reason, other devices with same android version but different CPUs are facing different kind of problems. My only concern is armv7l
CPUs.
The Xwalk library version I am using is 23.53.589.4
I am also using NanoHTTPD to serve local files for the crosswalk webview.
Inside the oncreate
mXWalkView = new XWalkView(getApplicationContext(), (Activity) Main_activity.this);
RelativeLayout second_container = findViewById(R.id.second_container);
second_container.addView(mXWalkView);
mXWalkView.setResourceClient(new ResourceClient(mXWalkView));
XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, false);
mXWalkView.addJavascriptInterface(new JavaScriptInterface(), "interface");
mXWalkView.clearCache(true);
mXWalkView.getSettings().setMediaPlaybackRequiresUserGesture(false);
As for the xml
file I have:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:orientation="horizontal"
android:visibility="invisible"
tools:context=".Main_activity">
<RelativeLayout
android:id="@+id/second_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
The application displays the html file along with any images, text, iframes, etc. but for the html5 video tag it plays the video once and either doesn't loop, freezes on a certain frame or displays an empty white screen where the video should be.
When debugging the app I get the following messages which I think are connected to the problem:
E/MediaPlayer: Unable to create media player
D/MediaPlayer: create failed:
java.io.IOException: setDataSourceFD failed.: status=0x80000000
at android.media.MediaPlayer._setDataSource(Native Method)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1025)
at android.media.MediaPlayer.create(MediaPlayer.java:848)
at org.chromium.content.browser.MediaThrottler$StartWatchDogTask.doInBackground(MediaThrottler.java:107)
at org.chromium.content.browser.MediaThrottler$StartWatchDogTask.doInBackground(MediaThrottler.java:101)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
E/cr_MediaThrottler: Unable to create watch dog player, treat it as server crash.
D/cr_MediaResource: [MediaResourceGetter.java:167] resource has video
D/cr_MediaResource: [MediaResourceGetter.java:196] extracted valid metadata: MediaMetadata[durationInMilliseconds=13333, width=1280, height=720, success=true]
D/MediaPlayer: Couldn't open file on client side, trying server side
E/cr_MediaThrottler: Unable to create watch dog player, treat it as server crash.
E/MediaPlayer: Should have subtitle controller already set
These logs keep on repeating because the video is looping using javascript
As for the javascript
part:
//check if the video element is stuck either at the start or at the end and attempt to reload
//if it is not stuck repeat the video from the start
if (element.currentTime == 0 || element.currentTime == element.duration) {
element.src = element.src;
element.load();
} else {
element.currentTime = 0;
}
element.play();
The HTML video is as follows:
<!-- the video source holds a link to the same video on the server -->
<video src="video2.mp4" content-type="video" transition-time="13.33" style="width: 100%; height: 100%; object-fit: fill; display: block;" id="video" autoplay muted loop playsinline>
<source src="http://example/videos/video2.mp4">
Sorry, your browser doesn't support embedded videos.
</video>
I have tried adding setMediaPlaybackRequiresUserGesture
as false
on the android crosswalk side but the video still didn't loop.
I have also tried adding a JavaScriptInterface
to check if the video results in an error but it didn't (at least in android 4.4.4). The video played without leaving an error even when I have tried checking for the error using addEventListener()
(javascript) and onerror
(html).
The video is muted
with autoplay
and loop
and this html loop
doesn't work the video stops when it is done.
I have also tried loading and unloading the videos using javascript
in multiple different ways but they all resulted in the same output. The videos are playing with no white screen but they still freez due to throttling
. When the video freezes it doesn't go back to playing normally.
I have also added controls
to the html5 video and found out that pausing and resuming using the controls causes the video to play for a few seconds before it stops again, it also allows if more than one video is present to play and then they will stop seemingly at the same time.
If one video is present, the video loops a few times (between two and four times) and then freezes, if more than one video is present, lets say two videos, they will both play once and doesn't loop. (only one of the videos is visible at a certain time, the other has a style of display none
)
I have also tested on multiple 4.4.4 with armv7l
CPU and still the same results.