mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 1479270 - part2 : remove HLS video player. r=snorp
Since we have native HLS support in 59 [1], we can remove those codes which is used to play HLS. [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1345752 Differential Revision: https://phabricator.services.mozilla.com/D4166 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
45070f69f2
commit
a9a7cfd9fa
@ -37,11 +37,6 @@
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<view class="org.mozilla.gecko.media.VideoPlayer" android:id="@+id/video_player"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent">
|
||||
</view>
|
||||
|
||||
<FrameLayout android:id="@+id/home_screen_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -110,7 +110,6 @@ import org.mozilla.gecko.icons.decoders.IconDirectoryEntry;
|
||||
import org.mozilla.gecko.icons.decoders.LoadFaviconResult;
|
||||
import org.mozilla.gecko.lwt.LightweightTheme;
|
||||
import org.mozilla.gecko.media.PictureInPictureController;
|
||||
import org.mozilla.gecko.media.VideoPlayer;
|
||||
import org.mozilla.gecko.menu.GeckoMenu;
|
||||
import org.mozilla.gecko.menu.GeckoMenuItem;
|
||||
import org.mozilla.gecko.mma.MmaDelegate;
|
||||
@ -232,7 +231,6 @@ public class BrowserApp extends GeckoApp
|
||||
public ViewGroup mBrowserChrome;
|
||||
public ViewFlipper mActionBarFlipper;
|
||||
public ActionModeCompatView mActionBar;
|
||||
private VideoPlayer mVideoPlayer;
|
||||
private PictureInPictureController mPipController;
|
||||
private BrowserToolbar mBrowserToolbar;
|
||||
private View doorhangerOverlay;
|
||||
@ -374,10 +372,6 @@ public class BrowserApp extends GeckoApp
|
||||
Log.d(LOGTAG, "BrowserApp.onTabChanged: " + tab.getId() + ": " + msg);
|
||||
switch (msg) {
|
||||
case SELECTED:
|
||||
if (mVideoPlayer.isPlaying()) {
|
||||
mVideoPlayer.stop();
|
||||
}
|
||||
|
||||
if (Tabs.getInstance().isSelectedTab(tab) && mDynamicToolbar.isEnabled()) {
|
||||
final VisibilityTransition transition = (tab.getShouldShowToolbarWithoutAnimationOnFirstSelection()) ?
|
||||
VisibilityTransition.IMMEDIATE : VisibilityTransition.ANIMATE;
|
||||
@ -653,16 +647,6 @@ public class BrowserApp extends GeckoApp
|
||||
mBrowserChrome = (ViewGroup) findViewById(R.id.browser_chrome);
|
||||
mActionBarFlipper = (ViewFlipper) findViewById(R.id.browser_actionbar);
|
||||
mActionBar = (ActionModeCompatView) findViewById(R.id.actionbar);
|
||||
|
||||
mVideoPlayer = (VideoPlayer) findViewById(R.id.video_player);
|
||||
mVideoPlayer.setFullScreenListener(new VideoPlayer.FullScreenListener() {
|
||||
@Override
|
||||
public void onFullScreenChanged(boolean fullScreen) {
|
||||
mVideoPlayer.setFullScreen(fullScreen);
|
||||
setFullScreen(fullScreen);
|
||||
}
|
||||
});
|
||||
|
||||
mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar);
|
||||
mBrowserToolbar.setTouchEventInterceptor(new TouchEventInterceptor() {
|
||||
@Override
|
||||
@ -781,7 +765,6 @@ public class BrowserApp extends GeckoApp
|
||||
"Menu:Open",
|
||||
"LightweightTheme:Update",
|
||||
"Tab:Added",
|
||||
"Video:Play",
|
||||
"CharEncoding:Data",
|
||||
"CharEncoding:State",
|
||||
"Settings:Show",
|
||||
@ -974,17 +957,6 @@ public class BrowserApp extends GeckoApp
|
||||
return;
|
||||
}
|
||||
|
||||
if (mVideoPlayer.isFullScreen()) {
|
||||
mVideoPlayer.setFullScreen(false);
|
||||
setFullScreen(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mVideoPlayer.isPlaying()) {
|
||||
mVideoPlayer.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@ -1516,7 +1488,6 @@ public class BrowserApp extends GeckoApp
|
||||
"Menu:Open",
|
||||
"LightweightTheme:Update",
|
||||
"Tab:Added",
|
||||
"Video:Play",
|
||||
"CharEncoding:Data",
|
||||
"CharEncoding:State",
|
||||
"Settings:Show",
|
||||
@ -1800,14 +1771,6 @@ public class BrowserApp extends GeckoApp
|
||||
}
|
||||
break;
|
||||
|
||||
case "Video:Play":
|
||||
if (SwitchBoard.isInExperiment(this, Experiments.HLS_VIDEO_PLAYBACK)) {
|
||||
mVideoPlayer.start(Uri.parse(message.getString("uri")));
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.SHOW,
|
||||
TelemetryContract.Method.CONTENT, "playhls");
|
||||
}
|
||||
break;
|
||||
|
||||
case "CharEncoding:Data":
|
||||
final GeckoBundle[] charsets = message.getBundleArray("charsets");
|
||||
final int selected = message.getInt("selected");
|
||||
|
@ -1,204 +0,0 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; 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.media;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.MediaController;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import org.mozilla.gecko.R;
|
||||
|
||||
public class VideoPlayer extends FrameLayout {
|
||||
private VideoView video;
|
||||
private FullScreenMediaController controller;
|
||||
private FullScreenListener fullScreenListener;
|
||||
|
||||
private boolean isFullScreen;
|
||||
|
||||
public VideoPlayer(Context ctx) {
|
||||
this(ctx, null);
|
||||
}
|
||||
|
||||
public VideoPlayer(Context ctx, AttributeSet attrs) {
|
||||
this(ctx, attrs, 0);
|
||||
}
|
||||
|
||||
public VideoPlayer(Context ctx, AttributeSet attrs, int defStyle) {
|
||||
super(ctx, attrs, defStyle);
|
||||
setFullScreen(false);
|
||||
setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void start(Uri uri) {
|
||||
stop();
|
||||
|
||||
video = new VideoView(getContext());
|
||||
controller = new FullScreenMediaController(getContext());
|
||||
video.setMediaController(controller);
|
||||
controller.setAnchorView(video);
|
||||
|
||||
video.setVideoURI(uri);
|
||||
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||
Gravity.CENTER);
|
||||
|
||||
addView(video, layoutParams);
|
||||
setVisibility(View.VISIBLE);
|
||||
|
||||
video.setZOrderOnTop(true);
|
||||
video.start();
|
||||
}
|
||||
|
||||
public boolean isPlaying() {
|
||||
return video != null;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (video == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
removeAllViews();
|
||||
setVisibility(View.GONE);
|
||||
video.stopPlayback();
|
||||
|
||||
video = null;
|
||||
controller = null;
|
||||
}
|
||||
|
||||
public void setFullScreenListener(FullScreenListener listener) {
|
||||
fullScreenListener = listener;
|
||||
}
|
||||
|
||||
public boolean isFullScreen() {
|
||||
return isFullScreen;
|
||||
}
|
||||
|
||||
public void setFullScreen(boolean fullScreen) {
|
||||
isFullScreen = fullScreen;
|
||||
if (fullScreen) {
|
||||
setBackgroundColor(Color.BLACK);
|
||||
} else {
|
||||
setBackgroundResource(R.color.dark_transparent_overlay);
|
||||
}
|
||||
|
||||
if (controller != null) {
|
||||
controller.setFullScreen(fullScreen);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (event.isSystem()) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if (event.isSystem()) {
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
super.onTouchEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTrackballEvent(MotionEvent event) {
|
||||
super.onTrackballEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
public interface FullScreenListener {
|
||||
void onFullScreenChanged(boolean fullScreen);
|
||||
}
|
||||
|
||||
private class FullScreenMediaController extends MediaController {
|
||||
private ImageButton mButton;
|
||||
|
||||
public FullScreenMediaController(Context ctx) {
|
||||
super(ctx);
|
||||
|
||||
mButton = new ImageButton(getContext());
|
||||
mButton.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
mButton.setBackgroundColor(Color.TRANSPARENT);
|
||||
mButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FullScreenMediaController.this.onFullScreenClicked();
|
||||
}
|
||||
});
|
||||
|
||||
updateFullScreenButton(false);
|
||||
}
|
||||
|
||||
public void setFullScreen(boolean fullScreen) {
|
||||
updateFullScreenButton(fullScreen);
|
||||
}
|
||||
|
||||
private void updateFullScreenButton(boolean fullScreen) {
|
||||
mButton.setImageResource(fullScreen ? R.drawable.exit_fullscreen : R.drawable.fullscreen);
|
||||
}
|
||||
|
||||
private void onFullScreenClicked() {
|
||||
if (VideoPlayer.this.fullScreenListener != null) {
|
||||
boolean fullScreen = !VideoPlayer.this.isFullScreen();
|
||||
VideoPlayer.this.fullScreenListener.onFullScreenChanged(fullScreen);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnchorView(final View view) {
|
||||
super.setAnchorView(view);
|
||||
|
||||
// Add the fullscreen button here because this is where the parent class actually creates
|
||||
// the media buttons and their layout.
|
||||
//
|
||||
// http://androidxref.com/6.0.1_r10/xref/frameworks/base/core/java/android/widget/MediaController.java#239
|
||||
//
|
||||
// The media buttons are in a horizontal linear layout which is itself packed into
|
||||
// a vertical layout. The vertical layout is the only child of the FrameLayout which
|
||||
// MediaController inherits from.
|
||||
LinearLayout child = (LinearLayout) getChildAt(0);
|
||||
LinearLayout buttons = (LinearLayout) child.getChildAt(0);
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
|
||||
LayoutParams.MATCH_PARENT);
|
||||
params.gravity = Gravity.CENTER_VERTICAL;
|
||||
|
||||
if (mButton.getParent() != null) {
|
||||
((ViewGroup)mButton.getParent()).removeView(mButton);
|
||||
}
|
||||
|
||||
buttons.addView(mButton, params);
|
||||
}
|
||||
}
|
||||
}
|
@ -4848,7 +4848,6 @@ var BrowserEventHandler = {
|
||||
|
||||
BrowserApp.deck.addEventListener("DOMUpdateBlockedPopups", PopupBlockerObserver.onUpdateBlockedPopups);
|
||||
BrowserApp.deck.addEventListener("MozMouseHittest", this, true);
|
||||
BrowserApp.deck.addEventListener("OpenMediaWithExternalApp", this, true);
|
||||
|
||||
// ReaderViews support backPress listeners.
|
||||
WindowEventDispatcher.registerListener((event, data, callback) => {
|
||||
@ -4866,16 +4865,6 @@ var BrowserEventHandler = {
|
||||
case 'MozMouseHittest':
|
||||
this._handleRetargetedTouchStart(aEvent);
|
||||
break;
|
||||
case 'OpenMediaWithExternalApp': {
|
||||
let mediaSrc = aEvent.target.currentSrc || aEvent.target.src;
|
||||
let uuid = uuidgen.generateUUID().toString();
|
||||
GlobalEventDispatcher.sendRequest({
|
||||
type: "Video:Play",
|
||||
uri: mediaSrc,
|
||||
uuid: uuid
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user