Vimeo video stops playing on Android 6 devices - android

I'm trying to play video's from Vimeo in my app. The problem is that on Android 6 devices the video stops playing after a certain time. On devices with a lower API everything plays fine.
The time depends on the quality. For the video of the provided url's below plays a certain minutes (1 to 3). How lower the video quality how longer it keeps playing.
After 1 to 3 minutes the mediaplayer throws an ProtocolException. The app does not crash on this but the video freezes when the buffered video piece is played. [MediaHTTPConnection] readAt 25182208 / 32768 => java.net.ProtocolException: unexpected end of stream and shows this in de log
After the exception the video plays 30 seconds (buffered), then the application outputs this [MediaPlayer] error (1, -1004)
We're emailing for weeks now with Vimeo Support but they can't provide a solution or a possible cause. Now after weeks of mailing the support desk says that they're not supporting Android, but we've tried their suggestions:
Use the redirected and unredirected url's
http://player.vimeo.com/external/185069251.hd.mp4?s=fd7b4178a59166b3f636f2e48f1d49b99db66ed2&profile_id=174 [Redirected URL]
https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/2013/7/185069251/610514667.mp4?token=586a9287_0xbb25f73405c612b30e0c64dc4c3a169e30137f84 [Not redirected URL]
Use a video view instead of a mediaplayer
We've tried a native Android and a Xamarin Android implementation
Try to download the file => this works but we want to stream because some video's are longer then 30 minutes (>100mb). Uncomment the code in the onCreate in the DownLoadActivity to test downloading.
In the browser everything works fine.
I've placed a testproject on We-Transfer where you can see the problem https://bazookas.wetransfer.com/downloads/40dadcc8a01f7ebf025345cdf88b731220170102160508/21970a

HI in my app I'm also using Vimeo but in another way.
And it' working fine without issue in any OS. (For Native Android)
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.i("", "Processing webview url click...");
view.loadUrl(url);
return true;
}
public void onPageFinished(WebView view, String url) {
Log.i("", "Finished loading URL: " + url);
Const.disMisProgressdialog();
}
#Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
}
});
if(windowwidth < 480) {
webView.loadUrl("https://player.vimeo.com/video/<YOUR VEMIO ID>?player_id=player&autoplay=1&title=0&byline=0&portrait=0&api=1&maxheight=320&maxwidth=480");
}else{
webView.loadUrl("https://player.vimeo.com/video/<YOUR VEMIO ID>?player_id=player&autoplay=1&title=0&byline=0&portrait=0&api=1&maxheight=480&maxwidth=800");
}
for
windowwidth :-
int windowwidth = getWindowManager().getDefaultDisplay().getWidth();
int windowheight = getWindowManager().getDefaultDisplay().getHeight();

Looks like the issue with the url you use.
You use url from vimeo api for HD file. And for some reason android system don't allow to cache more then some amount of KB.
If you change the url from HD to vimeoHLS - link for streaming, everything works fine.
It fixed the issue for my 7 android, but i haven't tested this for another version yet tho.
Can't find a reason why this doesn't work on Android 6+, but works fine for lower versions.

Related

Twitter video not rendering in webview

I get tweet blockquote in the description . I create a html document and appened blockquote and twitter script and load that html to webview. All the tweets and videos renders properly. Only problem is, When i click on the video, it shows a black screen. This happening for all twitter videos in kitkat devcies. Works fine in lollypop and above. I know there is a bug in API level 16 and 17 and videos won't play in the webview. But from API level 18, videos in webview must play and all other videos are playing in the webview in these devices. Only the twitter videos are not working. Below is my html content:
<!DOCTYPE html> <head>
<script async src ="http://platform.twitter.com/widgets.js"
charset="utf-8"></script></head> <body><blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Goodbye #Sarbjit.Gratitude to #OmungKumar #Vanita_ok #SandeepSinghOne #RichaChadda_ #kirandeohans #AishwaryaRai CREW pic.twitter.com/1tC4CiCwBN</p>— Randeep Hooda (#RandeepHooda) March 15, 2016</blockquote></body> </html>
This is my webview code:
public static void setupWebview(WebView webView) {
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.setBackgroundColor(Color.parseColor("#ffffff"));
android.webkit.CookieManager.getInstance().setAcceptCookie(true);
}
What might be the issue here. I googled a lot, but couldn't get any solution. Is anyone else also, facing similar issue?
Thanks in Advance
I am facing the same issue.For me it is working on JellyBean(4.1.2) and Lollipop and above,but fails to load on KitKat(API 19). I was checking the logs from the webview by overriding onConsoleMessage method of WebChromeClient and noticed that I am getting the following error after it tries to load the video resource:
Uncaught InvalidStateError: An attempt was made to use an object that
is not, or is no longer, usable.
Check your logs and try to debug what step is failing when trying to render the video.

shouldInterceptRequest on Android 4.4 KitKat

I have an App that uses custom schemes in Android WebViewClient's shouldInterceptRequest(WebView view, String url) and shouldOverrideUrlLoading(WebView view, String url) to intercept requests in a web application and use a native library to fetch resources from elsewhere in shouldInterceptRequest. This has worked fine up until Android 4.4 KitKat, where Google has made some crucial changes to the webView component.
http://developer.android.com/guide/webapps/migrating.html#URLs
Now the url received in shouldOverrideUrlLoading suddenly gets invalid, looking like this; custom-scheme:////my.pathname.com/. First I suspected the extra slashes were because Android did not think the url were valid RFC3986, but in a series of resource fetches (css, js, images), the url starts off correct and suddenly changes to the invalid format. The webView in Android 4.3 kept the url correctly as custom-scheme://my.pathname.com/. It seems like the base url suddenly changes to '/' instead of 'my.pathname.com'.
Then my attention changed to the fact that the webView 4.4 migration guide talks about:
If you call methods on WebView from any thread other than your app's UI thread, it can cause unexpected results. http://developer.android.com/guide/webapps/migrating.html#Threads
This also might be what I am experiencing, but I have not yet come up with a solution where I can use runOnUiThread() to fetch data with the native api and return it to the webView inside shouldInterceptRequest. Has anyone experienced something similar?
Here is a simplified version of my shouldInterceptRequest code:
#Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
if (urlStartsWithKnownPrefix(url)) {
UrlFetchResult fetchRes = api.fetchUrl(url);
String charset = "utf-8";
String mime = fetchRes.getMimetype();
WebResourceResponse res = new WebResourceResponse(mime, charset, new ByteArrayInputStream(fetchRes.getResult()));
return res;
}
return null;
}
Are you using jquery-mobile by any chance? This sounds very similar to: How can I use relative urls in ajax requests within trigger.io apps on Android 4.4 (kitkat)?

Sorry, this video is not valid for streaming to this device in Http streaming android

I can stream some videos from URL (server) successfully,
But the others (my video up to my server) is not.
You can see both in my code (Working/Not working)
I'm on stuck with this problem.
"Sorry, this video is not valid for streaming to this device"
The following code :
String url = null;
// url = "rtsp://v5.cache5.c.youtube.com/CiILENy73wIaGQmC00ZlwwIDOxMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"; // Working
// url = "http://daily3gp.com/vids/747.3gp"; // Working
url = "http://www.ooklnet.com/files/381/381489/video.mp4"; // Working
// url = "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"; // Working
// url = "http://dl.dropbox.com/u/80419/santa.mp4"; // Working
// url = "http://trekvn.hostoi.com/encode_normal.mp4"; // Not Working
// url = "http://trekvn.hostoi.com/output_encode_mp4_box.mp4"; // Not Working
// url = "http://www.ourserversite.com:14556/ingCloud/users/400010001/mp4_320p/e8d8535852a98c949640c5d618ac23d320131022174507.mp4"; // Not Working
// url = "http://trekvn.hostoi.com/mpeg_2_ts.ts"; // Not Working
videoviewer.setVideoURI(Uri.parse(url));
videoviewer.requestFocus();
videoviewer.setKeepScreenOn(true);
videoviewer.setOnErrorListener(this);
videoviewer.setOnPreparedListener(this);
#Override
public void onPrepared(MediaPlayer mp) {
videoviewer.start()'
}
All of these video can play good on the site,
have format *.mp4 (mpeg-4 part 10), Video : .H264, Audio : aac.
Please tell me why,
and how to fix it.
p/s : Samsung Galaxy Tab 7" - 2.2.1
Thanks,
This is the issue that many people met, ensure you understand following content to fix the issue.
Through my experience and the answer in this Sorry, this video cannot be played - streaming mp4 to android
Finally, I found the reason and the solution:
- Reason : Almost the *.mp4 file was produced for developing focus on iOS, and have the encoding : H264 Main. While Android side can only stream & play the files have the encoding : H264 Baseline.
- Solution : We need convert from the encoding H264 Main to H264 Baseline (guaranteed enabled Web Optimized (move -moov atom before -mdat) feature)
- Bugs :
Sorry this video is not valid for streaming to this device.
Sorry, this video can not be played.
HandBrake tool is the easiest and cheapest way to complete it.
Thanks,
p/s : But if you use this method, you need upload your video to the server for testing.

The Best way To Add iframeVideo in Android?

I am new to android platform, and I want create simple
thats play videos from web via iframe
but the result is horrible ... very very bad
even the user can't watch in full screen
and the size of video is very big,, bigger then webView?
so, if any one know a good way to play video.. with iframe in android, please tell me..
i have tested the code on iOS it's works prefect... so the problem is android...
here's my Code
String hrmlCode = "<center>" +
"<iframe type=\"text/html\" frameborder=\"0\" scrolling=\"yes\" width=\"367\" height=\"320\" src=\"http://video.com/WqPOh.php?get=vid394g5\" allowFullScreen></iframe>" +
"</center>";
CWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
act.setProgress(progress * 1000);
}
});
CWebView.getSettings().setJavaScriptEnabled(true);
CWebView.getSettings().setPluginState(PluginState.ON);
CWebView.loadData(hrmlCode, "text/html", "UTF-8");
thanks in advance
This is a very famous issue in android. The iframe just doesnt work as expected and it is very buggy.
I would say you don't include but simply provide a thumbnail of the video which directly links to your video file
Look into the earlier solution below
https://github.com/droid28/VimeoVideo
Google Reader-esque optimizing of WebViews on Android

Android : how to stream/play any music file on HTML page in android browser

There is one HTML page, streaming a music file and It's working on window but i need to run this html file on android.
also i need to control all the feature of music by javascript function e.g. play,pause,stop, volume up & down.
Can someone give me any idea?
Note : i am new to android but good hand in java. Just going through android tutorial and i came to know this feature can be done using webview. is it ?
Its not clear from the post if its a requirement that you have to play it on a html page or you just want to play the .mp3 file linked from some online page.
However, You can look at this Streaming Audio tutorial as an initial reference. The MediaPlayer API would be your goto place in android for anything to do with Audio/ Video. WebView is mainly for embedding a browser view within your android App.
Here is an example quite close to the thing you're going to do...
public class MyJSInterface{
private MediaPlayer mp = new MediaPlayer();
....
public void play(String url){
this.mp.setDataSource(url);
this.mp.prepare();
this.mp.start();
// AlterDialog etc.
}
public void stop(){
this.mp.stop();
}
....
}
HTML from your website:
function _play(url){
window.myappname.play(url);
}
function _stop(url){
window.myappname.stop();
}
thing you may need
Android Media

Categories

Resources