Support google home control

okjack
FongMi 3 years ago
parent 01bd42c704
commit f843058a60
  1. 19
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  2. 14
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/VideoActivity.java

@ -34,6 +34,7 @@ import com.fongmi.android.tv.bean.Keep;
import com.fongmi.android.tv.bean.Live;
import com.fongmi.android.tv.bean.Track;
import com.fongmi.android.tv.databinding.ActivityLiveBinding;
import com.fongmi.android.tv.event.ActionEvent;
import com.fongmi.android.tv.event.ErrorEvent;
import com.fongmi.android.tv.event.PlayerEvent;
import com.fongmi.android.tv.impl.Callback;
@ -282,6 +283,11 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
fetch();
}
private void checkPlay() {
if (mPlayers.isPlaying()) mPlayers.pause();
else mPlayers.play();
}
private void onTrack(View view) {
TrackDialog.create().player(mPlayers).type(Integer.parseInt(view.getTag().toString())).show(this);
hideControl();
@ -596,6 +602,19 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onActionEvent(ActionEvent event) {
if (ActionEvent.PLAY.equals(event.getAction()) || ActionEvent.PAUSE.equals(event.getAction())) {
checkPlay();
} else if (ActionEvent.NEXT.equals(event.getAction())) {
nextChannel();
} else if (ActionEvent.PREV.equals(event.getAction())) {
prevChannel();
} else if (ActionEvent.STOP.equals(event.getAction())) {
finish();
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPlayerEvent(PlayerEvent event) {
switch (event.getState()) {

@ -50,6 +50,7 @@ import com.fongmi.android.tv.bean.Track;
import com.fongmi.android.tv.bean.Vod;
import com.fongmi.android.tv.databinding.ActivityVideoBinding;
import com.fongmi.android.tv.db.AppDatabase;
import com.fongmi.android.tv.event.ActionEvent;
import com.fongmi.android.tv.event.ErrorEvent;
import com.fongmi.android.tv.event.PlayerEvent;
import com.fongmi.android.tv.event.RefreshEvent;
@ -1081,6 +1082,19 @@ public class VideoActivity extends BaseActivity implements CustomKeyDownVod.List
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onActionEvent(ActionEvent event) {
if (ActionEvent.PLAY.equals(event.getAction()) || ActionEvent.PAUSE.equals(event.getAction())) {
onKeyCenter();
} else if (ActionEvent.NEXT.equals(event.getAction())) {
mBinding.control.next.performClick();
} else if (ActionEvent.PREV.equals(event.getAction())) {
mBinding.control.prev.performClick();
} else if (ActionEvent.STOP.equals(event.getAction())) {
finish();
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPlayerEvent(PlayerEvent event) {
switch (event.getState()) {

Loading…
Cancel
Save