View Full Version : xtype video on ANDROID - support please clarify

9 Sep 2011, 1:47 AM

Without being required to pay $300 for a simple answer, can I ask someone from Sencha to clarify what is a core requirement for many apps in our multi-media world.

is it actually possible for Sencha Touch to render video for Android devices?

There's a lot I like about Sencha Touch, though it's a steep learning curve. But, if the answer to the above is no (and one user recently stated to me - 'yep, I get round it by hiding the video menu item from my android users') then there's a problem.

Of course everyone likes the iPhone, but there are more Android device users than iPhone these days and it seems that the sencha xtype 'video' doesn't mark up the video tag properly for Android.

Can I ask for a response from the support team (who I hope do actually look in this section from time to time), so that I, and many like me, can either solve this or move on.


9 Sep 2011, 5:22 AM
The problem we have noticed is that Android doesn't really support things as well as we would like. iOS is still king by a long shot. Video is one of those things Android doesn't do the best on.

9 Sep 2011, 5:27 AM
Hi there - thanks for the reply.

Yes, I can see that Android is not that helpful - so...is there any workaround or are you saying that, until Android adapt, video will never work on that platform, through Sencha Touch?

Thanks for your help

9 Sep 2011, 5:33 AM
I dont know in Android 3.0, but till 2.3.3 the Android Browser simply dont support video tag, this is the first, so to view a video in sencha you have to do location.href ="yourvideourl" that will open the native video player. In phonegap i modified the childBrowser plugin in order to stream a video.Second in order to strream a video on android you have to add moov atom at the beginning of the video, i do this with ffmpeg (qt-faststart) server side.

9 Sep 2011, 6:00 AM
Thanks Steve.

Just to clarify what you are saying - the location.href ="yourvideourl" is to reference an external webpage that you show with the phonegap childbrowser (never yet got that to work in android myself, though IOS is fine).

And if I wanted to hold the videos as local assets rather than call a web page? Is that possible?


9 Sep 2011, 6:03 AM
No, the location.href ="yourvideourl" is your video url not a webpage location.href ="http://yourdomain.com/test.3gp", this is for webapp, in Phonegap is different because location.href dont work and it's because you have to use the plugin. If you hold videos on local asset you dont need the moov atom at the begining of the video and you can still use the childBrowser plugin

9 Sep 2011, 6:05 AM
just do location.href="myvideo.mp4"; and it will open up the native video player

9 Sep 2011, 6:05 AM

How did you get videos to work on Android in Phonegap using ChildBrowser?
Did you enable hardware acceleration?

I was only able to get videos working after enabling hardware acceleration but then my Sencha CSS transitions got all choppy.

If you have a solutions please let me know how you did it.

9 Sep 2011, 6:14 AM
The childBrowser plugin simply open an url from within the app, if the url refers to a video file then the native video player is invoked and the video is played. You are speaking about Android 3.0, this is a bug of the Android Browser in 3.0, if you enable hardaware acceleration in the AndroidManifest.xml the css are broken, but with childBrowser you open the video in native video player so you dont need hardaware acceleration.

9 Sep 2011, 6:18 AM
Well I actually open a Sencha app in ChildBrowser that has a video embeded in a carousel. So I'm not opening the video directly.

9 Sep 2011, 6:21 AM
childBrowser modified plugin in order to direct open video in native video player (the mod in red). Otherwise the original plugin will prompt if you wnat to play the video in the native videoplayer or in the browser.

* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
* Copyright (c) 2005-2010, Nitobi Software Inc.
* Copyright (c) 2010, IBM Corporation
package com.phonegap.plugins.childBrowser;

import org.json.JSONArray;
import org.json.JSONException;

import android.content.Intent;
import android.net.Uri;

import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;

public class ChildBrowser extends Plugin {

* Executes the request and returns PluginResult.
* @param action The action to execute.
* @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript.
* @return A PluginResult object with a status and message.
public PluginResult execute(String action, JSONArray args, String callbackId) {
PluginResult.Status status = PluginResult.Status.OK;
String result = "";

try {
if (action.equals("showWebPage")) {
result = this.showWebPage(args.getString(0), args.optBoolean(1));
if (result.length() > 0) {
status = PluginResult.Status.ERROR;
return new PluginResult(status, result);
} catch (JSONException e) {
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);

* Identifies if action to be executed returns a value and should be run synchronously.
* @param action The action to execute
* @return T=returns value
public boolean isSynch(String action) {
return false;

* Called by AccelBroker when listener is to be shut down.
* Stop listener.
public void onDestroy() {


* Display a new browser with the specified URL.
* NOTE: If usePhoneGap is set, only trusted PhoneGap URLs should be loaded,
* since any PhoneGap API can be called by the loaded HTML page.
* @param url The url to load.
* @param usePhoneGap Load url in PhoneGap webview.
* @return "" if ok, or error message.
public String showWebPage(String url, boolean usePhoneGap) {
try {
Intent intent = null;
if (usePhoneGap) {
// Loads and displays a new PhoneGap app on top of current PhoneGap app.
// For the currently running PhoneGap app:
// If keepRunning=true (default), then the current app continues to run in background
// If keepRunning=false, then the current app is paused by Android
// When BACK is pressed, the current app has focus.
intent = new Intent().setClass(this.ctx, com.phonegap.DroidGap.class);
intent.setData(Uri.parse(url)); // This line will be removed in future.
intent.putExtra("url", url);

// Timeout parameter: 60 sec max - May be less if http device timeout is less.
intent.putExtra("loadUrlTimeoutValue", 60000);

// These parameters can be configured if you want to show the loading dialog
intent.putExtra("loadingDialog", "Wait,Loading web page..."); // show loading dialog
intent.putExtra("hideLoadingDialogOnPageLoad", true); // hide it once page has completely loaded

else {
intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "video/*");

return "";
} catch (android.content.ActivityNotFoundException e) {
System.out.println("ChildBrowser: Error loading url "+url+":"+ e.toString());
return e.toString();


9 Sep 2011, 6:31 AM
Mitchell - I noticed you were still referencing an MP4 video file. Are you saying that you believe that codec will work with Android devices, or is that only IOS?


9 Sep 2011, 6:33 AM
In my experiments, I was able to get a regular mp4 file that I use on iOS to work on Android version 2.3 and up.

9 Sep 2011, 6:39 AM
In 2.2 and 2.2.1 is not working i use 3gp video file or mp4 file but with the moov atom, i'm referring to streaming file, for local asset is different

9 Sep 2011, 7:05 AM
OK - just to clarify then - local video assets, which can be 3gp or mp4 (h.264?), can work but only in 2.3 upwards. Not 2.1 or 2.2?

Thanks for bearing with me....:)


10 Sep 2011, 4:35 AM
For local asset you can use mp4 or 3gp, but bw aware that for mp4 (h264) google will drop support for this encoding due to copyright issue, is because google has webm video format:

5 Jan 2016, 1:35 AM
I supply a powerful MP4 to Android converter-Avdshare Video Converter, which can convert MP4 to Android supporting format like MPEG-4 or H.264 AVC, thus play MP4 on Android phones or tablets.