Bug 936851 - Part 1: Remove VideoPlayer. r=mfinkle, a=lmandel
authorRichard Newman <rnewman@mozilla.com>
Thu, 31 Jul 2014 08:56:51 -0700
changeset 208290 e9fc6b3efaf3
parent 208289 b8d426a326f5
child 208291 086068fe1b98
push id3806
push userryanvm@gmail.com
push date2014-08-11 18:37 +0000
treeherdermozilla-beta@f76498a1bcbd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, lmandel
bugs936851
milestone32.0
Bug 936851 - Part 1: Remove VideoPlayer. r=mfinkle, a=lmandel
mobile/android/base/AndroidManifest.xml.in
mobile/android/base/GeckoAppShell.java
mobile/android/base/VideoPlayer.java
mobile/android/base/moz.build
--- a/mobile/android/base/AndroidManifest.xml.in
+++ b/mobile/android/base/AndroidManifest.xml.in
@@ -289,24 +289,16 @@
             android:exported="false"
             android:excludeFromRecents="true">
           <intent-filter>
             <action android:name="org.mozilla.gecko.reportCrash" />
           </intent-filter>
   </activity>
 #endif
 
-        <activity android:name="org.mozilla.gecko.VideoPlayer"
-                  android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|locale|layoutDirection"
-                  android:theme="@android:style/Theme.NoTitleBar">
-            <intent-filter>
-                <action android:name="org.mozilla.gecko.PLAY_VIDEO" />
-            </intent-filter>
-        </activity>
-
         <activity android:name="org.mozilla.gecko.preferences.GeckoPreferences"
                   android:theme="@style/Gecko.Preferences"
                   android:configChanges="orientation|screenSize|locale|layoutDirection"
                   android:excludeFromRecents="true"/>
 
         <activity android:name="org.mozilla.gecko.home.HomePanelPicker"
                   android:theme="@style/Gecko.TitleDialog"
                   android:label="@string/home_add_panel_title"
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -1245,34 +1245,26 @@ public class GeckoAppShell
         }
 
         if (!isUriSafeForScheme(uri)) {
             return null;
         }
 
         final String scheme = uri.getScheme();
 
-        final Intent intent;
-
         // Compute our most likely intent, then check to see if there are any
         // custom handlers that would apply.
         // Start with the original URI. If we end up modifying it, we'll
         // overwrite it.
-        final Intent likelyIntent = getIntentForActionString(action);
-        likelyIntent.setData(uri);
-
-        if ("vnd.youtube".equals(scheme) && !hasHandlersForIntent(likelyIntent)) {
-            // Special-case YouTube to use our own player if no system handler
-            // exists.
-            intent = new Intent(VideoPlayer.VIDEO_ACTION);
-            intent.setClassName(AppConstants.ANDROID_PACKAGE_NAME,
-                                "org.mozilla.gecko.VideoPlayer");
-            intent.setData(uri);
-        } else {
-            intent = likelyIntent;
+        final Intent intent = getIntentForActionString(action);
+        intent.setData(uri);
+
+        if ("vnd.youtube".equals(scheme) && !hasHandlersForIntent(intent)) {
+            // TODO: reload the page to request HTML5 video.
+            // For now, we will simply fail.
         }
 
         // Have a special handling for SMS, as the message body
         // is not extracted from the URI automatically.
         if (!"sms".equals(scheme)) {
             return intent;
         }
 
deleted file mode 100644
--- a/mobile/android/base/VideoPlayer.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-package org.mozilla.gecko;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-import android.widget.MediaController;
-import android.widget.VideoView;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-
-public final class VideoPlayer extends Activity {
-    public static final String VIDEO_ACTION = "org.mozilla.gecko.PLAY_VIDEO";
-
-    private VideoView mVideoView;
-
-    /** Called when the activity is first created. */
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.videoplayer);
-        mVideoView = (VideoView) findViewById(R.id.VideoView);
-        MediaController mediaController = new MediaController(this);
-        mediaController.setAnchorView(mVideoView);
-        Intent intent = getIntent();
-        final Uri data = intent.getData();
-        if (data == null) {
-            return;
-        }
-
-        String spec = null;
-        if ("vnd.youtube".equals(data.getScheme())) {
-            String ssp = data.getSchemeSpecificPart();
-            int paramIndex = ssp.indexOf('?');
-            String id;
-            if (paramIndex == -1) {
-                id = ssp;
-            } else {
-                id = ssp.substring(0, paramIndex);
-            }
-            spec = getSpecFromYouTubeVideoID(id);
-        }
-
-        if (spec == null) {
-            return;
-        }
-
-        final Uri video = Uri.parse(spec);
-        mVideoView.setMediaController(mediaController);
-        mVideoView.setVideoURI(video);
-        mVideoView.start();
-    }
-
-    private String getSpecFromYouTubeVideoID(String id) {
-        String spec = null;
-        try {
-            String infoUri = "http://www.youtube.com/get_video_info?&video_id=" + id;
-            URL infoUrl = new URL(infoUri);
-            URLConnection urlConnection = infoUrl.openConnection();
-            BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
-            try {
-                StringBuilder sb = new StringBuilder();
-                String line;
-                while ((line = br.readLine()) != null)
-                    sb.append(line);
-                android.net.Uri fakeUri = android.net.Uri.parse("fake:/fake?" + sb);
-                String streamMap = fakeUri.getQueryParameter("url_encoded_fmt_stream_map");
-                if (streamMap == null)
-                    return null;
-                String[] streams = streamMap.split(",");
-                for (int i = 0; i < streams.length; i++) {
-                    fakeUri = android.net.Uri.parse("fake:/fake?" + streams[i]);
-                    String url = fakeUri.getQueryParameter("url");
-                    String type = fakeUri.getQueryParameter("type");
-                    if (type != null && url != null &&
-                        (type.startsWith("video/mp4") || type.startsWith("video/webm"))) {
-                        spec = url;
-                    }
-                }
-            } finally {
-                br.close();
-            }
-        } catch (Exception e) {
-            Log.e("VideoPlayer", "exception", e);
-        }
-        return spec;
-    }
-}
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -389,17 +389,16 @@ gbjar.sources += [
     'toolbar/ToolbarDisplayLayout.java',
     'toolbar/ToolbarEditLayout.java',
     'toolbar/ToolbarEditText.java',
     'toolbar/ToolbarProgressView.java',
     'toolbar/ToolbarTitlePrefs.java',
     'TouchEventInterceptor.java',
     'updater/UpdateService.java',
     'updater/UpdateServiceHelper.java',
-    'VideoPlayer.java',
     'webapp/Allocator.java',
     'webapp/ApkResources.java',
     'webapp/Dispatcher.java',
     'webapp/EventListener.java',
     'webapp/InstallHelper.java',
     'webapp/InstallListener.java',
     'webapp/TaskKiller.java',
     'webapp/UninstallListener.java',