The code below shows a simple Android app that utilizes the Youtube IFrame API to play a specific video link.

    class MainActivity : AppCompatActivity() {

        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
            val myWebView: WebView = findViewById(R.id.webview)
            myWebView.settings.javaScriptEnabled = true
            myWebView.loadDataWithBaseURL("",   "<!DOCTYPE html>\n" +
                                                "<html>\n" +
                                                "<body>\n" +
                                                "\n" +
                                                "<h1>My First Heading</h1>\n"
                                                "\n" +
                                                "<p>My first paragraph.</p›\n" +
                                                "<iframe id=\"ytplayer\" type=\"text/html\" width=\"720\" height=\"405\"\n" +
                                                "src=\"https://www.youtube.com/embed/?playlist=w0eVN8mqtiw\"\n" +
                                                "frameborder=\"0\" allowfullscreen›\n" +
                                                "</body>\n" +
                                                "</html>", "text/html", "UTF-8", "")
        }
    }

This code plays well on ARMv8-based Android devices.

However, on 2 ARMv7-based Android devices I tried, it causes the relatively high-quality video https://www.youtube.com/embed/?playlist=w0eVN8mqtiw to lag and show green artifacts after a couple of seconds.

  1. This happens ONLY if the quality of playback is set to Auto (which is the default option for every YouTube link we play using the IFrame player).
  2. Once I set the quality of playback (manually in the IFrame player playback settings), to any specific supported resolution, the lagging and green artifact disappears. This means this issue is somehow related to the Auto playback quality adaptations of the IFrame player in high-quality (1080p+) Youtube videos

That being said any video below 1080p, works fine (without lags or green artifacts). That is not being caused due to network issues since all devices I tested used the same network.

Moreover, the same video link plays well on the device's Youtube app as well as in IFrame player running directly on a Chrome web page (used https://developers.google.com/youtube/youtube_player_demo to play the same link).

enter image description here

Any idea what could be the issue or how it can be avoided?

0

There are 0 best solutions below