Bug 936851 - Part 1: remove VideoPlayer. r=mfinkle

This commit is contained in:
Richard Newman 2014-07-31 08:56:51 -07:00
Родитель 2d0a634cff
Коммит 162bd5a0bb
4 изменённых файлов: 5 добавлений и 119 удалений

Просмотреть файл

@ -349,14 +349,6 @@
</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"

Просмотреть файл

@ -1142,24 +1142,16 @@ public class GeckoAppShell
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);
final Intent intent = getIntentForActionString(action);
intent.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;
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

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -411,7 +411,6 @@ gbjar.sources += [
'TouchEventInterceptor.java',
'updater/UpdateService.java',
'updater/UpdateServiceHelper.java',
'VideoPlayer.java',
'Webapp.java',
'webapp/Allocator.java',
'webapp/ApkResources.java',