question

Pankaj avatar image
Pankaj asked

Embeding YouTube videos in webapp

I am using YouTube's iframe api to embed videos in my web app. I able to play the video on Kindle HDX devices but on HD devices Kindle Fire HD 8.9" 2nd gen & 7" 2nd gen its not playing well. The iframe gets cropped and video stutters while playing, I tried changing the hardware acceleration for web view but no luck. The video plays perfectly even on Kindle Fire SD 1st gen but not on HD devices. Is there anything I am missing? Need some help.
iap
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Pankaj, Can you please post the code you are using?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Pankaj avatar image
Pankaj answered
Hey Sujoy, Here is the java snippet that I use to initialize the YouTube embed. String url=" https://www.youtube.com/embed/DERzYnthq1s?controls=0&modestbranding=1&rel=0&showinfo=0&enablejsapi=1"; WebView webVideoView = (WebView) fView.findViewById(R.id.webView1); webVideoView.setBackgroundColor(0x00000000); webVideoView.setWebChromeClient(new WebChromeClient()); webVideoView.getSettings().setJavaScriptEnabled(true); webVideoView.getSettings().setPluginState(PluginState.ON); webVideoView.loadUrl(jsInitializeVideo); xml snippet: It works on both 3rd gen HDX, even 1st gen SD but not on any of the 2nd gen HD devices. I found a weird fix to make it work on HD devices, if I align the webview to parent left (i.e. no margin from left) the video plays well. If I put some left margin or align the webview in center, the video gets cropped from right, I've attached 3 screenshots (taken on Kindle Fire 2nd gen HD 7" ICS 4.0.3) with annotated xml code, I can't even make the web view transparent for a work around, setting explicit rendering layer types to make the web view transparent breaks the video rendering, using View.LAYER_TYPE_SOFTWARE won't render the video, only audio is audible and View.LAYER_TYPE_HARDWARE is a complete blackout with flickering, (tested on Kindle Fire 2nd gen HD 7" & 8.9") Any suggestions? Thanks,
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Pankaj, Did you ever check that your app in a generic android device running on API 15 (OS 4.0.3)? Our 2nd generation devices have this version of OS installed. Changing layout_width to 800dp of your webview is fixing the issue. Also, I will recommend you to use Amazon Web View if you target your app for Kindle devices. AWV is also able to play the video with out any UI issue. super.onCreate(savedInstanceState); setContentView(R.layout.main); if (!sFactoryInit) { factory = AmazonWebKitFactories.getDefaultFactory(); if (factory.isRenderProcess(this)) { return; } factory.initialize(this); factory.getCookieManager().setAcceptCookie(true); sFactoryInit = true; } else { factory = AmazonWebKitFactories.getDefaultFactory(); } AmazonWebView mWebView = (AmazonWebView) findViewById(R.id.myWebView); factory.initializeWebView(mWebView, 0xFFFFFF, false, null); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setAllowFileAccessFromFileURLs(true); mWebView.getSettings().setPluginState(AmazonWebSettings.PluginState.ON); String url=" https://www.youtube.com/embed/DERzYnthq1s?controls=0&modestbranding=1&rel=0&showinfo=0&enablejsapi=1"; mWebView.loadUrl(url); }
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Pankaj avatar image
Pankaj answered
Hello Sujoy, I've tested the app on Samsung GT I1903 ICS 4.0.3 and its working fine. Regarding the AmazonWebView , I tries it but no luck, I can only hear the sound with black video display. I am not able to digest why the left margin is causing this issue! Any further suggestions? Thanks,
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Pankaj, I have checked the above code in Kindle HDX and HD devices and they are able to play the video with out any issue. Please note that the AWV is only supported in Kindle Fire devices. Please let us know in which device are having this issue. Thanks.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Pankaj avatar image
Pankaj answered
Hi Sujoy, Thanks for your last code sample, I managed to run it but when I try to use the seekbar and in between that If video is paused/played, I can see some rendering issues, I am not able to attach the video here it says attachment too large, here is the link to my drive having the sample app and the video showing the issue. https://drive.google.com/folderview?id=0B27MNfR6LNeHLVhtOGxwT2l5R1E&usp=sharing I ran this test on: Kindle Fire 2nd gen 7" HD (amazon-kftt-D025A0A025060EWK) Android 4.0.3 API 15 Thanks,
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Yes. The issue is reproducible in 2nd gen devices. I am forwarding issue to the concerned team here. I will get back to you once I get updates from them. Thanks for the sample and video.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hey Pankaj, The issue is passed to respective team here and they might fix it in the subsequent release. Thanks for bringing the issue into our notice. Thanks. Message was edited by: Sujoy@Amazon
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Pankaj avatar image
Pankaj answered
Hey Sujoy, Thanks for your time, I'll keep looking for the next update, Thanks once again,
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Pankaj avatar image
Pankaj answered
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.