Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: xtype video on ANDROID - support please clarify

  1. #11
    Sencha User
    Join Date
    Aug 2010
    Posts
    315

    Default childBrowser modified plugin

    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.

    Code:
    /*
     * 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() {
        }
    
    
        //--------------------------------------------------------------------------
        // LOCAL METHODS
        //--------------------------------------------------------------------------
    
    
        /**
         * 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/*");
                }
    
    
                this.ctx.startActivity(intent);
                return "";
            } catch (android.content.ActivityNotFoundException e) {
                System.out.println("ChildBrowser: Error loading url "+url+":"+ e.toString());
                return e.toString();
            }
        }
    
    
    }

  2. #12
    Sencha User
    Join Date
    Aug 2011
    Posts
    206

    Default

    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?

    allister

  3. #13

    Default

    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.
    http://www.dev4.life - Software Development Blog

  4. #14
    Sencha User
    Join Date
    Aug 2010
    Posts
    315

    Default

    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

  5. #15
    Sencha User
    Join Date
    Aug 2011
    Posts
    206

    Default

    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....

    Allister

  6. #16
    Sencha User
    Join Date
    Aug 2010
    Posts
    315

    Default

    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:
    http://www.osnews.com/story/24243/Go...rt_from_Chrome

  7. #17

    Default

    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.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •