Merge pull request #36 from lineagett/main

增加分辨率、时间及缓冲速度显示 by fpotato
pull/37/head
q215613905 4 years ago committed by GitHub
commit da605700ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 39
      app/src/main/java/com/github/tvbox/osc/player/controller/VodController.java
  2. 9
      app/src/main/java/com/github/tvbox/osc/util/PlayerHelper.java
  3. 61
      app/src/main/res/layout/player_vod_control_view.xml

@ -31,8 +31,11 @@ import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Date;
import xyz.doikki.videoplayer.player.VideoView;
import xyz.doikki.videoplayer.util.PlayerUtils;
@ -101,11 +104,35 @@ public class VodController extends BaseController {
TextView mPlayerTimeStartBtn;
TextView mPlayerTimeSkipBtn;
TextView mPlayerTimeStepBtn;
TextView mPlayPauseTime;
TextView mPlayLoadNetSpeed;
TextView mVideoSize;
Handler myHandle;
Runnable myRunnable;
int myHandleSeconds = 6000;//闲置多少毫秒秒关闭底栏 默认6秒
private Runnable myRunnable2 = new Runnable() {
@Override
public void run() {
Date date = new Date();
SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
mPlayPauseTime.setText(timeFormat.format(date));
mPlayLoadNetSpeed.setText(PlayerHelper.getDisplaySpeed(mControlWrapper.getTcpSpeed()));
String width = Integer.toString(mControlWrapper.getVideoSize()[0]);
String height = Integer.toString(mControlWrapper.getVideoSize()[1]);
mVideoSize.setText("[ " + width + " X " + height +" ]");
mHandler.postDelayed(this, 1000);
}
};
@Override
protected void initView() {
super.initView();
@ -130,6 +157,9 @@ public class VodController extends BaseController {
mPlayerTimeStartBtn = findViewById(R.id.play_time_start);
mPlayerTimeSkipBtn = findViewById(R.id.play_time_end);
mPlayerTimeStepBtn = findViewById(R.id.play_time_step);
mPlayPauseTime = findViewById(R.id.tv_sys_time);
mPlayLoadNetSpeed = findViewById(R.id.tv_play_load_net_speed);
mVideoSize = findViewById(R.id.tv_videosize);
myHandle=new Handler();
myRunnable = new Runnable() {
@ -139,6 +169,13 @@ public class VodController extends BaseController {
}
};
mPlayPauseTime.post(new Runnable() {
@Override
public void run() {
mHandler.post(myRunnable2);
}
});
mGridView.setLayoutManager(new V7LinearLayoutManager(getContext(), 0, false));
ParseAdapter parseAdapter = new ParseAdapter();
parseAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@ -601,9 +638,11 @@ public class VodController extends BaseController {
break;
case VideoView.STATE_PREPARED:
case VideoView.STATE_BUFFERED:
mPlayLoadNetSpeed.setVisibility(GONE);
break;
case VideoView.STATE_PREPARING:
case VideoView.STATE_BUFFERING:
mPlayLoadNetSpeed.setVisibility(VISIBLE);
break;
case VideoView.STATE_PLAYBACK_COMPLETED:
listener.playNext(true);

@ -184,4 +184,13 @@ public class PlayerHelper {
}
return scaleText;
}
public static String getDisplaySpeed(long speed) {
if(speed > 1048576)
return (speed / 1048576) + "MB/s";
else if(speed > 1024)
return (speed / 1024) + "KB/s";
else
return speed + "B/s";
}
}

@ -293,15 +293,57 @@
android:visibility="gone"
tools:visibility="visible">
<TextView
android:id="@+id/tv_info_name"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginStart="@dimen/vs_20"
android:layout_marginLeft="@dimen/vs_20"
android:layout_marginTop="@dimen/vs_10"
android:orientation="vertical">
<TextView
android:id="@+id/tv_info_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:ellipsize="end"
android:maxLines="1"
android:paddingTop="@dimen/vs_20"
android:paddingLeft="@dimen/vs_20"
android:text="http://"
android:textColor="@android:color/white"
android:textSize="@dimen/ts_24" />
<TextView
android:id="@+id/tv_videosize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:ellipsize="end"
android:maxLines="1"
android:paddingLeft="@dimen/vs_20"
android:tag="vod_video_size"
android:text="[ 1024 x 768 ]"
android:textColor="@android:color/white"
android:textSize="@dimen/ts_24" />
</LinearLayout>
<TextView
android:id="@+id/tv_sys_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/vs_20"
android:layout_marginRight="@dimen/vs_20"
android:layout_marginTop="@dimen/vs_10"
android:layout_gravity="right"
android:ellipsize="end"
android:maxLines="1"
android:padding="@dimen/vs_20"
android:text="http://"
android:tag="vod_control_pause_time"
android:text="00:00:00"
android:textColor="@android:color/white"
android:textSize="@dimen/ts_24" />
@ -400,4 +442,17 @@
android:tag="vod_control_loading"
android:visibility="gone" />
<TextView
android:id="@+id/tv_play_load_net_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/vs_40"
android:focusable="false"
android:focusableInTouchMode="false"
android:tag="play_load_net_speed"
android:text="0"
android:textColor="@color/color_FFFFFF"
android:textSize="@dimen/ts_24" />
</FrameLayout>

Loading…
Cancel
Save