直播遥控左右键切换线路;

直播支持数字键换台;
pull/143/head
于俊 1 year ago
parent a6c12f09ef
commit cff4b03e73
  1. 1
      app/src/main/java/com/github/catvod/crawler/JarLoader.java
  2. 53
      app/src/main/java/com/github/tvbox/osc/ui/activity/LivePlayActivity.java
  3. 18
      app/src/main/res/layout/activity_live_play.xml
  4. 5
      app/src/main/res/layout/activity_search.xml
  5. 2
      app/src/main/res/layout/fragment_model.xml

@ -96,6 +96,7 @@ public class JarLoader {
// return success;
// }
private boolean loadClassLoader(String jar, String key) {
if (classLoaders.contains(key)) return true;
final String TAG = "JarLoader";
final File jarFile = new File(jar);
final AtomicBoolean success = new AtomicBoolean(false);

@ -194,6 +194,11 @@ public class LivePlayActivity extends BaseActivity {
private boolean show = false;
private static final int postTimeout = 6000;
// 遥控器数字键输入的要切换的频道号码
private int selectedChannelNumber = 0;
private TextView tvSelectedChannel;
@Override
protected int getLayoutResID() {
return R.layout.activity_live_play;
@ -269,6 +274,7 @@ public class LivePlayActivity extends BaseActivity {
iv_playpause = findViewById(R.id.iv_playpause);
iv_play = findViewById(R.id.iv_play);
tvSelectedChannel = findViewById(R.id.tv_selected_channel);
if(show){
backcontroller.setVisibility(View.VISIBLE);
@ -619,6 +625,42 @@ public class LivePlayActivity extends BaseActivity {
}
}
private final Runnable mPlaySelectedChannel = new Runnable() {
@Override
public void run() {
int currentTotal = 0;
int groupIndex = 0;
int channelIndex = -1;
for (LiveChannelGroup group : liveChannelGroupList) {
int groupChannelCount = group.getLiveChannels().size();
if (currentTotal + groupChannelCount >= selectedChannelNumber) {
channelIndex = selectedChannelNumber - currentTotal - 1; // 转换为0-based索引
break;
}
currentTotal += groupChannelCount;
groupIndex++;
}
tvSelectedChannel.setVisibility(View.INVISIBLE);
tvSelectedChannel.setText("");
if(channelIndex>0){
playChannel(groupIndex, channelIndex, false);
}else {
playChannel(currentChannelGroupIndex, currentLiveChannelIndex, false);
}
selectedChannelNumber = 0;
}
};
@SuppressLint("SetTextI18n")
private void numericKeyDown(int digit) {
selectedChannelNumber = selectedChannelNumber * 10 + digit;
tvSelectedChannel.setText(Integer.toString(selectedChannelNumber));
tvSelectedChannel.setVisibility(View.VISIBLE);
mHandler.removeCallbacks(mPlaySelectedChannel);
mHandler.postDelayed(mPlaySelectedChannel, 2500);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
@ -643,7 +685,7 @@ public class LivePlayActivity extends BaseActivity {
if(isBack){
showProgressBars(true);
}else{
showSettingGroup();
playPreSource();
}
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
@ -658,6 +700,15 @@ public class LivePlayActivity extends BaseActivity {
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
showChannelList();
break;
default:
if (keyCode >= KeyEvent.KEYCODE_0 && keyCode <= KeyEvent.KEYCODE_9) {
keyCode -= KeyEvent.KEYCODE_0;
} else if ( keyCode >= KeyEvent.KEYCODE_NUMPAD_0 && keyCode <= KeyEvent.KEYCODE_NUMPAD_9) {
keyCode -= KeyEvent.KEYCODE_NUMPAD_0;
} else {
break;
}
numericKeyDown(keyCode);
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {

@ -12,6 +12,24 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/tv_selected_channel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|start"
android:layout_margin="20dp"
android:background="@android:color/transparent"
android:clickable="false"
android:focusable="false"
android:shadowColor="@color/color_1890FF"
android:shadowDx="2"
android:shadowDy="2"
android:shadowRadius="1"
android:textColor="@android:color/white"
android:textSize="96sp"
android:textStyle="bold"
android:visibility="invisible" />
<LinearLayout
android:id="@+id/tvLeftChannnelListLayout"
android:layout_width="match_parent"

@ -22,8 +22,7 @@
<TextView
android:id="@+id/tvSearchCheckboxBtn"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_height="28mm"
android:background="@drawable/shape_user_focus"
android:focusable="true"
android:gravity="center"
@ -133,7 +132,7 @@
android:textColor="@android:color/white"
android:textSize="@dimen/ts_20"
android:layout_marginBottom="@dimen/ts_10"
android:layout_height="@dimen/ts_24"/>
android:layout_height="28mm"/>
<com.owen.tvrecyclerview.widget.TvRecyclerView
android:id="@+id/mGridViewWord"

@ -428,7 +428,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="聚合模式"
android:text="聚合搜索"
android:textColor="@android:color/white"
android:textSize="@dimen/ts_24" />

Loading…
Cancel
Save