pull/142/head
FongMi 3 years ago
parent 49c96c547c
commit 1e88fd6b7b
  1. 11
      app/src/mobile/AndroidManifest.xml
  2. 24
      app/src/mobile/java/com/fongmi/android/tv/event/ActionEvent.java
  3. 10
      app/src/mobile/java/com/fongmi/android/tv/receiver/ActionReceiver.java
  4. 8
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  5. 8
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java

@ -136,6 +136,7 @@
android:foregroundServiceType="mediaPlayback">
<intent-filter>
<action android:name="androidx.media3.session.MediaSessionService" />
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>
@ -143,11 +144,11 @@
android:name=".receiver.ActionReceiver"
android:exported="false">
<intent-filter>
<action android:name="${applicationId}.PREV" />
<action android:name="${applicationId}.NEXT" />
<action android:name="${applicationId}.PLAY" />
<action android:name="${applicationId}.PAUSE" />
<action android:name="${applicationId}.CANCEL" />
<action android:name="${applicationId}.stop" />
<action android:name="${applicationId}.prev" />
<action android:name="${applicationId}.next" />
<action android:name="${applicationId}.play" />
<action android:name="${applicationId}.pause" />
</intent-filter>
</receiver>

@ -1,17 +1,19 @@
package com.fongmi.android.tv.event;
import com.fongmi.android.tv.BuildConfig;
import org.greenrobot.eventbus.EventBus;
public class ActionEvent {
public static String PREV = "PREV";
public static String NEXT = "NEXT";
public static String PLAY = "PLAY";
public static String PAUSE = "PAUSE";
public static String UPDATE = "UPDATE";
public static String CANCEL = "CANCEL";
public static String STOP = BuildConfig.APPLICATION_ID.concat(".stop");
public static String PREV = BuildConfig.APPLICATION_ID.concat(".prev");
public static String NEXT = BuildConfig.APPLICATION_ID.concat(".next");
public static String PLAY = BuildConfig.APPLICATION_ID.concat(".play");
public static String PAUSE = BuildConfig.APPLICATION_ID.concat(".pause");
public static String UPDATE = BuildConfig.APPLICATION_ID.concat(".update");
private String type;
private final String action;
public static void send(String action) {
EventBus.getDefault().post(new ActionEvent(action));
@ -21,11 +23,11 @@ public class ActionEvent {
EventBus.getDefault().post(new ActionEvent(UPDATE));
}
public ActionEvent(String type) {
this.type = type;
public ActionEvent(String action) {
this.action = action;
}
public String getType() {
return type;
public String getAction() {
return action;
}
}

@ -2,24 +2,20 @@ package com.fongmi.android.tv.receiver;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import com.fongmi.android.tv.App;
import com.fongmi.android.tv.event.ActionEvent;
import com.fongmi.android.tv.utils.Utils;
public class ActionReceiver extends BroadcastReceiver {
public static PendingIntent getPendingIntent(Context context, String type) {
Intent intent = new Intent(App.get().getPackageName() + "." + type);
intent.setComponent(new ComponentName(context, ActionReceiver.class));
return PendingIntent.getBroadcast(context, 0, intent, Utils.getPendingFlag());
public static PendingIntent getPendingIntent(Context context, String action) {
return PendingIntent.getBroadcast(context, 100, new Intent(action).setPackage(context.getPackageName()), Utils.getPendingFlag());
}
@Override
public void onReceive(Context context, Intent intent) {
ActionEvent.send(intent.getAction().replace(context.getPackageName() + ".", ""));
ActionEvent.send(intent.getAction());
}
}

@ -639,13 +639,13 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
@Subscribe(threadMode = ThreadMode.MAIN)
public void onActionEvent(ActionEvent event) {
if (event.getType().equals(ActionEvent.PLAY) || event.getType().equals(ActionEvent.PAUSE)) {
if (ActionEvent.PLAY.equals(event.getAction()) || ActionEvent.PAUSE.equals(event.getAction())) {
checkPlay();
} else if (event.getType().equals(ActionEvent.NEXT)) {
} else if (ActionEvent.NEXT.equals(event.getAction())) {
nextChannel();
} else if (event.getType().equals(ActionEvent.PREV)) {
} else if (ActionEvent.PREV.equals(event.getAction())) {
prevChannel();
} else if (event.getType().equals(ActionEvent.CANCEL)) {
} else if (ActionEvent.STOP.equals(event.getAction())) {
finish();
}
}

@ -1028,13 +1028,13 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
@Subscribe(threadMode = ThreadMode.MAIN)
public void onActionEvent(ActionEvent event) {
if (event.getType().equals(ActionEvent.PLAY) || event.getType().equals(ActionEvent.PAUSE)) {
if (ActionEvent.PLAY.equals(event.getAction()) || ActionEvent.PAUSE.equals(event.getAction())) {
mBinding.control.play.performClick();
} else if (event.getType().equals(ActionEvent.NEXT)) {
} else if (ActionEvent.NEXT.equals(event.getAction())) {
mBinding.control.next.performClick();
} else if (event.getType().equals(ActionEvent.PREV)) {
} else if (ActionEvent.PREV.equals(event.getAction())) {
mBinding.control.prev.performClick();
} else if (event.getType().equals(ActionEvent.CANCEL)) {
} else if (ActionEvent.STOP.equals(event.getAction())) {
finish();
}
}

Loading…
Cancel
Save