Javascript ended event when video playback ends on android

I am trying to create a web page that redirects the user after watching the video (or if he interrupted playback). It works for me on iphone, but I can’t understand how it works on Android.

On Iphone, I found two ways to do this. using the tag to embed the quicktime plugin and then adding an event listener using javascript to listen for the qt_ended event. Obviously this does not work on android because there is no quicktime plugin.

The second thing I tried was to use the html5-tag and listen to the event “ended”, again it worked on the iphone, but, to my surprise, not on Android. In this case, I received the video played on the Android phone, but the redirection did not occur after the video reached the end. Therefore, I assume that the Android browser does not fully support the video tag and that it does not fire an event.

So at this time I really don’t know how to act. I guess I can do something similar to a quick embed solution, but with a plugin available on Android. But I can’t find information about which plug-ins are available on android, and if they support some kind of “completed” event.

+3
source share
3 answers

This is supported in Android 2.2, but not 2.1. Android 1.6 did not even support the Video tag, so that goes without saying.

I spent some time looking for workarounds and found nothing.

+2
source

I have the same problem with a completed event (Android 2.1). I found this, but so far no luck. https://github.com/bcrescimanno/droidfix

As a result, I discovered Android 2.1 or lower and showing a button that the user can activate, and then triggered the completed event.

I used PHP for detection, but you can easily convert it to JavaScript.

if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false){

        $androidVersion = intval(substr($_SERVER['HTTP_USER_AGENT'], strpos($_SERVER['HTTP_USER_AGENT'], 'Android')+8, 3));

        if($androidVersion < 2.2) {
            echo 'android 2.1 or less';
        }
    }
+1
source

Android , . . .

+1

Source: https://habr.com/ru/post/1750246/


All Articles