Display embedded tweet with video in Android WebView

android
embeddedtweet

#1

I’m trying to embed a twitter video in my android application using a WebView.

Its working correctly on all devices on and above android version Lollipop(API level 21). It is working even on Android Version 4.1.2. However, the video is not loading on certain versions - Version 4.4.2. It just shows a black screen for the video player and nothing loads.

I’m using the following html code to embed the video:
http://pastebin.com/KWGp2Qey

I tried debugging the issue and I’m seeing the following error getting thrown from the WebView:

Uncaught InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable.

Can someone help me figure out what is going wrong with this strange issue. The same code works on different android versions and even on desktop. Thanks in advance.


Refused to load the image 'android-webview-video-poster:default_video_poster' because it violates CSP
#2

Is there any reason why you’re using a WebView, and not a TweetView provided by Twitter Kit for Fabric?


#3

Yes, I had used webview and iframe because I wanted to support video content from different sources like facebook,vimeo etc too.

Also,does the TweetView for android support video playback without leaving the app? I couldn’t see anything in the docs here to suggest that it could handle video content: https://docs.fabric.io/android/twitter/show-tweets.html


#4

Yes, per our blog post, support for videos in TweetView on Android has been available since December.


#5

Thanks! I’m sorry I missed that. Will the TweetView be able to handle all formats of videos?
I saw the reply to this post and thought it supports only certain types of video.


#6

You’re right - at the moment we support native Twitter video in the TweetView - as we noted in that other thread, since Vines etc are not currently returned inside extended entities on Tweet objects, we cannot display them yet, but you’d expect us to want to bring these kinds of things to TweetViews in Fabric in the future.


#7

Thank you so much for clearing that up. So what approach would you recommend to give the best experience to users right now? I’m considering using TweetView to show native videos and using a webview to show any other formats like Vines and amp.twimg etc, because I would prefer to stay in the app to watch all types of videos.


#8

Well, I suggested the TweetView because I know the native performance will be much better, and you’re reporting issues with the embedded WebView. I’m afraid I don’t know how to help with the WebView piece. I understand that you’d like to include all our types of video, but at the moment a WebView would be the only way to do that.


#9

Thanks @andypiper for the input. For my current requirements, amp.twimg is the only format which I need that TweetView doesn’t support, so I can handle that case separately on a WebView and use TweetView for everything else. So the only problem scenario would be an amp.twimg video rendered on a WebView on a KitKat device.


#10

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.