parent
cc27b751b5
commit
e3b0bb8191
@ -1,28 +0,0 @@ |
|||||||
package com.github.tvbox.osc.receiver; |
|
||||||
|
|
||||||
import android.content.BroadcastReceiver; |
|
||||||
import android.content.Context; |
|
||||||
import android.content.Intent; |
|
||||||
|
|
||||||
import com.github.tvbox.osc.ui.activity.ProjectionPlayActivity; |
|
||||||
import com.github.tvbox.osc.util.AppManager; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author pj567 |
|
||||||
* @date :2021/3/5 |
|
||||||
* @description: |
|
||||||
*/ |
|
||||||
public class ProjectionReceiver extends BroadcastReceiver { |
|
||||||
public static String action = "android.content.movie.projection.Action"; |
|
||||||
|
|
||||||
@Override |
|
||||||
public void onReceive(Context context, Intent intent) { |
|
||||||
if (action.equals(intent.getAction()) && intent.getExtras() != null) { |
|
||||||
AppManager.getInstance().finishActivity(ProjectionPlayActivity.class); |
|
||||||
Intent newIntent = new Intent(context, ProjectionPlayActivity.class); |
|
||||||
newIntent.putExtra("html", intent.getExtras().getString("html")); |
|
||||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
|
||||||
context.startActivity(newIntent); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,180 +0,0 @@ |
|||||||
package com.github.tvbox.osc.ui.activity; |
|
||||||
|
|
||||||
import android.content.Intent; |
|
||||||
import android.os.Bundle; |
|
||||||
import android.view.KeyEvent; |
|
||||||
import android.widget.Toast; |
|
||||||
|
|
||||||
import com.github.tvbox.osc.R; |
|
||||||
import com.github.tvbox.osc.base.BaseActivity; |
|
||||||
import com.github.tvbox.osc.player.controller.BoxVideoController; |
|
||||||
import com.github.tvbox.osc.player.controller.BoxVodControlView; |
|
||||||
import com.github.tvbox.osc.ui.dialog.ParseDialog; |
|
||||||
import com.github.tvbox.osc.util.HawkConfig; |
|
||||||
import com.github.tvbox.osc.util.PlayerHelper; |
|
||||||
import com.orhanobut.hawk.Hawk; |
|
||||||
|
|
||||||
import xyz.doikki.videocontroller.component.GestureView; |
|
||||||
import xyz.doikki.videoplayer.player.VideoView; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author pj567 |
|
||||||
* @date :2021/3/5 |
|
||||||
* @description: |
|
||||||
*/ |
|
||||||
public class ProjectionPlayActivity extends BaseActivity { |
|
||||||
private VideoView mVideoView; |
|
||||||
private BoxVideoController controller; |
|
||||||
|
|
||||||
@Override |
|
||||||
protected int getLayoutResID() { |
|
||||||
return R.layout.activity_projection_play; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected void init() { |
|
||||||
initView(); |
|
||||||
initData(); |
|
||||||
} |
|
||||||
|
|
||||||
private void initView() { |
|
||||||
mVideoView = findViewById(R.id.mVideoView); |
|
||||||
PlayerHelper.updateCfg(mVideoView); |
|
||||||
|
|
||||||
// ViewGroup.LayoutParams layoutParams = mVideoView.getLayoutParams();
|
|
||||||
// layoutParams.width = 100;
|
|
||||||
// layoutParams.height = 50;
|
|
||||||
// mVideoView.setLayoutParams(layoutParams);
|
|
||||||
|
|
||||||
mVideoView.addOnStateChangeListener(new VideoView.SimpleOnStateChangeListener() { |
|
||||||
@Override |
|
||||||
public void onPlayStateChanged(int state) { |
|
||||||
switch (state) { |
|
||||||
case VideoView.STATE_IDLE: |
|
||||||
case VideoView.STATE_PREPARED: |
|
||||||
case VideoView.STATE_PLAYING: |
|
||||||
case VideoView.STATE_BUFFERED: |
|
||||||
case VideoView.STATE_PAUSED: |
|
||||||
case VideoView.STATE_BUFFERING: |
|
||||||
case VideoView.STATE_PREPARING: |
|
||||||
break; |
|
||||||
case VideoView.STATE_PLAYBACK_COMPLETED: |
|
||||||
finish(); |
|
||||||
break; |
|
||||||
case VideoView.STATE_ERROR: |
|
||||||
finish(); |
|
||||||
tryDismissParse(); |
|
||||||
Toast.makeText(mContext, "播放错误", Toast.LENGTH_SHORT).show(); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
controller = new BoxVideoController(this); |
|
||||||
|
|
||||||
controller.addControlComponent(new GestureView(this)); |
|
||||||
BoxVodControlView boxVodControlView = new BoxVodControlView(this); |
|
||||||
boxVodControlView.hideNextPre(); |
|
||||||
controller.addControlComponent(boxVodControlView); |
|
||||||
controller.setCanChangePosition(true); |
|
||||||
controller.setEnableInNormal(true); |
|
||||||
controller.setGestureEnabled(true); |
|
||||||
mVideoView.setVideoController(controller); |
|
||||||
} |
|
||||||
|
|
||||||
ParseDialog parseDialog = null; |
|
||||||
|
|
||||||
void tryDismissParse() { |
|
||||||
if (parseDialog != null) { |
|
||||||
try { |
|
||||||
parseDialog.dismiss(); |
|
||||||
} catch (Throwable th) { |
|
||||||
th.printStackTrace(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void initData() { |
|
||||||
Intent intent = getIntent(); |
|
||||||
if (intent != null && intent.getExtras() != null) { |
|
||||||
Bundle bundle = intent.getExtras(); |
|
||||||
String html = bundle.getString("html"); |
|
||||||
|
|
||||||
tryDismissParse(); |
|
||||||
|
|
||||||
parseDialog = new ParseDialog().build(this, new ParseDialog.BackPress() { |
|
||||||
@Override |
|
||||||
public void onBack() { |
|
||||||
ProjectionPlayActivity.this.finish(); |
|
||||||
tryDismissParse(); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
parseDialog.show(); |
|
||||||
|
|
||||||
/* parseDialog.parse("", "", html, new ParseDialog.ParseCallback() { |
|
||||||
@Override |
|
||||||
public void success(String playUrl, Map<String, String> headers) { |
|
||||||
controller.boxTVRefreshInfo(playUrl); |
|
||||||
if (mVideoView != null) { |
|
||||||
mVideoView.release(); |
|
||||||
mVideoView.setUrl(playUrl); |
|
||||||
mVideoView.start(); |
|
||||||
} |
|
||||||
tryDismissParse(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void fail() { |
|
||||||
ProjectionPlayActivity.this.finish(); |
|
||||||
tryDismissParse(); |
|
||||||
} |
|
||||||
});*/ |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) { |
|
||||||
int keyCode = event.getKeyCode(); |
|
||||||
int action = event.getAction(); |
|
||||||
if (action == KeyEvent.ACTION_DOWN) { |
|
||||||
if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { |
|
||||||
controller.boxTVSlideStart(keyCode == KeyEvent.KEYCODE_DPAD_RIGHT ? 1 : -1); |
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || (Hawk.get(HawkConfig.DEBUG_OPEN, false) && keyCode == KeyEvent.KEYCODE_0)) { |
|
||||||
controller.boxTVTogglePlay(); |
|
||||||
} |
|
||||||
} else if (action == KeyEvent.ACTION_UP) { |
|
||||||
if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { |
|
||||||
controller.boxTVSlideStop(); |
|
||||||
} |
|
||||||
} |
|
||||||
return super.dispatchKeyEvent(event); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected void onResume() { |
|
||||||
super.onResume(); |
|
||||||
if (mVideoView != null) { |
|
||||||
mVideoView.resume(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
protected void onPause() { |
|
||||||
super.onPause(); |
|
||||||
if (mVideoView != null) { |
|
||||||
mVideoView.pause(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected void onDestroy() { |
|
||||||
super.onDestroy(); |
|
||||||
if (mVideoView != null) { |
|
||||||
mVideoView.release(); |
|
||||||
mVideoView = null; |
|
||||||
} |
|
||||||
tryDismissParse(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -0,0 +1,68 @@ |
|||||||
|
package com.github.tvbox.osc.ui.activity; |
||||||
|
|
||||||
|
import android.content.ClipData; |
||||||
|
import android.content.ClipboardManager; |
||||||
|
import android.content.Context; |
||||||
|
import android.content.Intent; |
||||||
|
import android.view.View; |
||||||
|
import android.widget.ImageView; |
||||||
|
import android.widget.TextView; |
||||||
|
|
||||||
|
import com.github.tvbox.osc.R; |
||||||
|
import com.github.tvbox.osc.base.BaseActivity; |
||||||
|
import com.github.tvbox.osc.server.ControlManager; |
||||||
|
import com.github.tvbox.osc.ui.tv.QRCodeGen; |
||||||
|
|
||||||
|
import me.jessyan.autosize.utils.AutoSizeUtils; |
||||||
|
|
||||||
|
public class PushActivity extends BaseActivity { |
||||||
|
private ImageView ivQRCode; |
||||||
|
private TextView tvAddress; |
||||||
|
|
||||||
|
@Override |
||||||
|
protected int getLayoutResID() { |
||||||
|
return R.layout.activity_push; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void init() { |
||||||
|
initView(); |
||||||
|
initData(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initView() { |
||||||
|
ivQRCode = findViewById(R.id.ivQRCode); |
||||||
|
tvAddress = findViewById(R.id.tvAddress); |
||||||
|
refreshQRCode(); |
||||||
|
findViewById(R.id.pushLocal).setOnClickListener(new View.OnClickListener() { |
||||||
|
@Override |
||||||
|
public void onClick(View v) { |
||||||
|
try { |
||||||
|
ClipboardManager manager = (ClipboardManager) PushActivity.this.getSystemService(Context.CLIPBOARD_SERVICE); |
||||||
|
if (manager != null) { |
||||||
|
if (manager.hasPrimaryClip() && manager.getPrimaryClip() != null && manager.getPrimaryClip().getItemCount() > 0) { |
||||||
|
ClipData.Item addedText = manager.getPrimaryClip().getItemAt(0); |
||||||
|
Intent newIntent = new Intent(mContext, DetailActivity.class); |
||||||
|
newIntent.putExtra("id", addedText.getText().toString().trim()); |
||||||
|
newIntent.putExtra("sourceKey", "push_agent"); |
||||||
|
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
||||||
|
PushActivity.this.startActivity(newIntent); |
||||||
|
} |
||||||
|
} |
||||||
|
} catch (Throwable th) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void refreshQRCode() { |
||||||
|
String address = ControlManager.get().getAddress(false); |
||||||
|
tvAddress.setText(String.format("手机/电脑扫描上方二维码或者直接浏览器访问地址\n%s", address)); |
||||||
|
ivQRCode.setImageBitmap(QRCodeGen.generateBitmap(address, AutoSizeUtils.mm2px(this, 300), AutoSizeUtils.mm2px(this, 300), 4)); |
||||||
|
} |
||||||
|
|
||||||
|
private void initData() { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,47 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
xmlns:tools="http://schemas.android.com/tools" |
||||||
|
android:id="@+id/rootLayout" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
|
||||||
|
<LinearLayout |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_gravity="center" |
||||||
|
android:orientation="vertical"> |
||||||
|
|
||||||
|
<ImageView |
||||||
|
android:id="@+id/ivQRCode" |
||||||
|
android:layout_width="@dimen/vs_300" |
||||||
|
android:layout_height="@dimen/vs_300" |
||||||
|
android:layout_gravity="center" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/tvAddress" |
||||||
|
android:layout_width="@dimen/vs_480" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_gravity="center" |
||||||
|
android:layout_marginTop="@dimen/vs_20" |
||||||
|
android:gravity="center" |
||||||
|
android:lineSpacingMultiplier="1.5" |
||||||
|
android:textAlignment="gravity" |
||||||
|
android:textColor="@color/color_FFFFFF" |
||||||
|
android:textSize="@dimen/ts_24" |
||||||
|
tools:text="1111111111111111111111111111111111111111111111111111" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/pushLocal" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_gravity="center" |
||||||
|
android:layout_marginTop="@dimen/vs_20" |
||||||
|
android:background="@drawable/user_focus" |
||||||
|
android:focusable="true" |
||||||
|
android:gravity="center" |
||||||
|
android:padding="@dimen/vs_10" |
||||||
|
android:text="推送剪贴板内容" |
||||||
|
android:textColor="@color/color_FFFFFF" |
||||||
|
android:textSize="@dimen/ts_24" /> |
||||||
|
</LinearLayout> |
||||||
|
</FrameLayout> |
||||||
Loading…
Reference in new issue