Commit bfa44a58 authored by Han Ruisong's avatar Han Ruisong
Browse files

升级到v3.7.0

1. 新增弹幕功能。
2. 新增显示网速功能。
parent 31e0987e
No preview for this file type
No preview for this file type
......@@ -33,7 +33,7 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//获得场景视频SDK,必须引入
implementation 'com.bokecc:vod:3.6.0'
implementation 'com.bokecc:vod:3.7.0'
//播放加密视频必须引用http和drmv6
implementation 'com.bokecc:http:1.2.0'
implementation 'com.bokecc:drmv6:2.19.0'
......@@ -45,7 +45,10 @@ dependencies {
implementation 'com.bokecc:vrplay:1.0.0'
//使用投屏功能需要引用
implementation 'com.bokecc:projection:1.7.0'
//弹幕
implementation 'com.github.ctiao:DanmakuFlameMaster:0.9.25'
//noinspection GradleCompatible
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
......
......@@ -33,11 +33,13 @@
android:name=".play.SpeedPlayActivity"
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan|stateHidden"
android:supportsPictureInPicture="true" />
<activity
android:name=".play.MediaPlayActivity"
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan|stateHidden"
android:supportsPictureInPicture="true" />
<activity
......
......@@ -16,7 +16,6 @@ import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.bokecc.sdk.mobile.util.HttpUtil;
import com.bokecc.vod.adapter.PlayVideoAdapter;
import com.bokecc.vod.data.DataSet;
import com.bokecc.vod.data.DataUtil;
......@@ -85,6 +84,7 @@ public class MainActivity extends AppCompatActivity {
//请求数据
initData();
}
private void initView() {
......@@ -293,7 +293,7 @@ public class MainActivity extends AppCompatActivity {
private void closeSmallWindow() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
sendBroadcast(new Intent("com.bokecc.vod.play.SMALL_WINDOW").putExtra("control",3));
sendBroadcast(new Intent("com.bokecc.vod.play.SMALL_WINDOW").putExtra("control", 3));
}
}
}
package com.bokecc.vod.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.bokecc.vod.R;
import com.bokecc.vod.data.DanmuColorInfo;
import java.util.List;
public class DanmuColorAdapter extends RecyclerView.Adapter<DanmuColorAdapter.ViewHolder> {
private List<DanmuColorInfo> mData;
private boolean isPortrait = false;
private DanmuColorAdapter.OnItemClickListener onItemClickListener;
public DanmuColorAdapter(List<DanmuColorInfo> mData, boolean isPortrait) {
this.mData = mData;
this.isPortrait = isPortrait;
}
public interface OnItemClickListener {
void onItemClick(DanmuColorInfo item, int position);
}
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
this.onItemClickListener = onItemClickListener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = null;
if (isPortrait) {
v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_portrait_danmu_color, parent, false);
} else {
v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_danmu_color, parent, false);
}
ViewHolder viewHolder = new ViewHolder(v);
return viewHolder;
}
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
DanmuColorInfo danmuColorInfo = mData.get(position);
if (danmuColorInfo.isSelected()) {
holder.iv_danmu_color.setImageResource(danmuColorInfo.getSelectdImgRes());
} else {
holder.iv_danmu_color.setImageResource(danmuColorInfo.getNormalImgRes());
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
if (onItemClickListener != null) {
int pos = holder.getLayoutPosition();
onItemClickListener.onItemClick(mData.get(pos), pos);
}
}
});
}
@Override
public int getItemCount() {
return mData == null ? 0 : mData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
ImageView iv_danmu_color;
public ViewHolder(View itemView) {
super(itemView);
iv_danmu_color = itemView.findViewById(R.id.iv_danmu_color);
}
}
}
package com.bokecc.vod.data;
public class DanmuColorInfo {
private int normalImgRes;
private int selectdImgRes;
private boolean isSelected = false;
private String color;
public int getNormalImgRes() {
return normalImgRes;
}
public void setNormalImgRes(int normalImgRes) {
this.normalImgRes = normalImgRes;
}
public int getSelectdImgRes() {
return selectdImgRes;
}
public void setSelectdImgRes(int selectdImgRes) {
this.selectdImgRes = selectdImgRes;
}
public boolean isSelected() {
return isSelected;
}
public void setSelected(boolean selected) {
isSelected = selected;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
}
package com.bokecc.vod.data;
import master.flame.danmaku.danmaku.model.IDanmakus;
import master.flame.danmaku.danmaku.model.android.Danmakus;
import master.flame.danmaku.danmaku.parser.BaseDanmakuParser;
public class DanmuInfoParse extends BaseDanmakuParser {
@Override
protected IDanmakus parse() {
return new Danmakus();
}
}
package com.bokecc.vod.inter;
public interface OnDanmuSet {
void setOpaqueness(int opaqueness);
void setFontSizeLevel(int fontSizeLevel);
void setDanmuSpeed(int danmuSpeedLevel);
void setDisplayArea(int displayArea);
}
package com.bokecc.vod.inter;
public interface OnEditDanmuText {
void getDanmuText(String danmuText, String danmuColor);
}
......@@ -12,6 +12,7 @@ import android.media.ThumbnailUtils;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.net.TrafficStats;
import android.net.Uri;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
......@@ -29,13 +30,16 @@ import android.view.Display;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.bokecc.sdk.mobile.play.DanmuInfo;
import com.bokecc.vod.ConfigUtil;
import com.bokecc.vod.HuodeApplication;
import com.bokecc.vod.R;
import com.bokecc.vod.data.DanmuColorInfo;
import com.bokecc.vod.view.RoundCornerTransform;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
......@@ -47,6 +51,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -589,4 +594,125 @@ public class MultiUtils {
}
}
private static long lastTotalRxBytes = 0;
private static long lastTime = 0;
public static String getNetSpeed(int uid) {
long currentTotalRxBytes = getTotalRxBytes(uid);
long currentTime = System.currentTimeMillis();
long kbSpeed = ((currentTotalRxBytes - lastTotalRxBytes) * 1000 / (currentTime - lastTime));
lastTime = currentTime;
lastTotalRxBytes = currentTotalRxBytes;
if (kbSpeed > 1024) {
float mbSpeed = calMbSpeed(2, kbSpeed, 1024);
return mbSpeed + "MB/s";
} else {
return kbSpeed + "KB/s";
}
}
public static long getTotalRxBytes(int uid) {
return TrafficStats.getUidRxBytes(uid) == TrafficStats.UNSUPPORTED ? 0 : (TrafficStats.getTotalRxBytes() / 1024);
}
public static float calMbSpeed(int scale, long num1, long num2) {
BigDecimal bigDecimal1 = new BigDecimal(String.valueOf(num1));
BigDecimal bigDecimal2 = new BigDecimal(String.valueOf(num2));
return bigDecimal1.divide(bigDecimal2, scale, BigDecimal.ROUND_HALF_UP).floatValue();
}
//隐藏软键盘
public static void hideSoftKeyboard(View view) {
InputMethodManager inputMethodManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
//显示软键盘
public static void showSoftKeyboard(View view) {
InputMethodManager inputMethodManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
}
public static List<DanmuColorInfo> getDanmuColorInfoDatas() {
List<DanmuColorInfo> datas = new ArrayList<>();
DanmuColorInfo danmuColorInfo1 = new DanmuColorInfo();
danmuColorInfo1.setNormalImgRes(R.mipmap.danmu_color_one_normal);
danmuColorInfo1.setSelectdImgRes(R.mipmap.danmu_color_one_selected);
danmuColorInfo1.setSelected(false);
//颜色值为0x开头的小写字母组成 如0xffffff
danmuColorInfo1.setColor("0xffffff");
datas.add(danmuColorInfo1);
DanmuColorInfo danmuColorInfo2 = new DanmuColorInfo();
danmuColorInfo2.setNormalImgRes(R.mipmap.danmu_color_two_normal);
danmuColorInfo2.setSelectdImgRes(R.mipmap.danmu_color_two_selected);
danmuColorInfo2.setSelected(false);
danmuColorInfo2.setColor("0x999999");
datas.add(danmuColorInfo2);
DanmuColorInfo danmuColorInfo3 = new DanmuColorInfo();
danmuColorInfo3.setNormalImgRes(R.mipmap.danmu_color_three_normal);
danmuColorInfo3.setSelectdImgRes(R.mipmap.danmu_color_three_selected);
danmuColorInfo3.setSelected(false);
danmuColorInfo3.setColor("0xe6151e");
datas.add(danmuColorInfo3);
DanmuColorInfo danmuColorInfo4 = new DanmuColorInfo();
danmuColorInfo4.setNormalImgRes(R.mipmap.danmu_color_four_normal);
danmuColorInfo4.setSelectdImgRes(R.mipmap.danmu_color_four_selected);
danmuColorInfo4.setSelected(false);
danmuColorInfo4.setColor("0x9d22b1");
datas.add(danmuColorInfo4);
DanmuColorInfo danmuColorInfo5 = new DanmuColorInfo();
danmuColorInfo5.setNormalImgRes(R.mipmap.danmu_color_five_normal);
danmuColorInfo5.setSelectdImgRes(R.mipmap.danmu_color_five_selected);
danmuColorInfo5.setSelected(false);
danmuColorInfo5.setColor("0x6738b8");
datas.add(danmuColorInfo5);
DanmuColorInfo danmuColorInfo6 = new DanmuColorInfo();
danmuColorInfo6.setNormalImgRes(R.mipmap.danmu_color_six_normal);
danmuColorInfo6.setSelectdImgRes(R.mipmap.danmu_color_six_selected);
danmuColorInfo6.setSelected(false);
danmuColorInfo6.setColor("0x3d50b6");
datas.add(danmuColorInfo6);
DanmuColorInfo danmuColorInfo7 = new DanmuColorInfo();
danmuColorInfo7.setNormalImgRes(R.mipmap.danmu_color_seven_normal);
danmuColorInfo7.setSelectdImgRes(R.mipmap.danmu_color_seven_selected);
danmuColorInfo7.setSelected(false);
danmuColorInfo7.setColor("0x03a9f4");
datas.add(danmuColorInfo7);
DanmuColorInfo danmuColorInfo8 = new DanmuColorInfo();
danmuColorInfo8.setNormalImgRes(R.mipmap.danmu_color_eight_normal);
danmuColorInfo8.setSelectdImgRes(R.mipmap.danmu_color_eight_selected);
danmuColorInfo8.setSelected(false);
danmuColorInfo8.setColor("0x009688");
datas.add(danmuColorInfo8);
DanmuColorInfo danmuColorInfo9 = new DanmuColorInfo();
danmuColorInfo9.setNormalImgRes(R.mipmap.danmu_color_nine_normal);
danmuColorInfo9.setSelectdImgRes(R.mipmap.danmu_color_nine_selected);
danmuColorInfo9.setSelected(false);
danmuColorInfo9.setColor("0x259b24");
datas.add(danmuColorInfo9);
DanmuColorInfo danmuColorInfo10 = new DanmuColorInfo();
danmuColorInfo10.setNormalImgRes(R.mipmap.danmu_color_ten_normal);
danmuColorInfo10.setSelectdImgRes(R.mipmap.danmu_color_ten_selected);
danmuColorInfo10.setSelected(false);
danmuColorInfo10.setColor("0x8bc34a");
datas.add(danmuColorInfo10);
return datas;
}
}
package com.bokecc.vod.view;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import com.bokecc.vod.R;
import com.bokecc.vod.inter.OnDanmuSet;
import java.util.logging.Level;
public class DanmuSetDialog extends Dialog {
private Context context;
private OnDanmuSet onDanmuSet;
private int currentOpaqueness;
private int currentFontSizeLevel = 2;
private int currentDanmuSpeedLevel = 2;
private int currentDisplayArea;
private boolean isFullScreen = false;
public DanmuSetDialog(Context context,boolean isFullScreen, int currentOpaqueness, int currentFontSizeLevel, int currentDanmuSpeedLevel,int currentDisplayArea, OnDanmuSet onDanmuSet) {
super(context, R.style.SetVideoDialog);
this.context = context;
this.isFullScreen = isFullScreen;
this.currentOpaqueness = currentOpaqueness;
this.currentFontSizeLevel = currentFontSizeLevel;
this.currentDanmuSpeedLevel = currentDanmuSpeedLevel;
this.currentDisplayArea = currentDisplayArea;
this.onDanmuSet = onDanmuSet;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
init();
}
private void init() {
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.dialog_danmu_set, null);
setContentView(view);
ImageView iv_danmu_set_back = view.findViewById(R.id.iv_danmu_set_back);
iv_danmu_set_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
SeekBar sb_opaqueness = view.findViewById(R.id.sb_opaqueness);
final TextView tv_opaqueness = view.findViewById(R.id.tv_opaqueness);
sb_opaqueness.setProgress(currentOpaqueness);
sb_opaqueness.setMax(100);
tv_opaqueness.setText(currentOpaqueness + "%");
sb_opaqueness.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
tv_opaqueness.setText(i + "%");
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress();
if (onDanmuSet != null) {
onDanmuSet.setOpaqueness(progress);
}
}
});
final SeekBar sb_font_size = view.findViewById(R.id.sb_font_size);
final TextView tv_font_size = view.findViewById(R.id.tv_font_size);
sb_font_size.setMax(100);
if (currentFontSizeLevel == 0) {
sb_font_size.setProgress(0);
tv_font_size.setText("超小");
} else if (currentFontSizeLevel == 1) {
sb_font_size.setProgress(25);
tv_font_size.setText("小");
} else if (currentFontSizeLevel == 2) {
sb_font_size.setProgress(50);
tv_font_size.setText("正常");
} else if (currentFontSizeLevel == 3) {
sb_font_size.setProgress(75);
tv_font_size.setText("大");
} else if (currentFontSizeLevel == 4) {
sb_font_size.setProgress(100);
tv_font_size.setText("超大");
}
sb_font_size.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress();
if (progress >= 0 && progress < 13) {
sb_font_size.setProgress(0);
currentFontSizeLevel = 0;
tv_font_size.setText("超小");
} else if (progress >= 13 && progress < 25) {
sb_font_size.setProgress(25);
currentFontSizeLevel = 1;
tv_font_size.setText("小");
} else if (progress >= 25 && progress < 38) {
sb_font_size.setProgress(25);
currentFontSizeLevel = 1;
tv_font_size.setText("小");
} else if (progress >= 38 && progress < 50) {
sb_font_size.setProgress(50);
currentFontSizeLevel = 2;
tv_font_size.setText("正常");
} else if (progress >= 50 && progress < 63) {
sb_font_size.setProgress(50);
currentFontSizeLevel = 2;
tv_font_size.setText("正常");
} else if (progress >= 63 && progress < 75) {
sb_font_size.setProgress(75);
currentFontSizeLevel = 3;
tv_font_size.setText("大");
} else if (progress >= 75 && progress < 88) {
sb_font_size.setProgress(75);
currentFontSizeLevel = 3;
tv_font_size.setText("大");
} else if (progress >= 88 && progress <= 100) {
sb_font_size.setProgress(100);
currentFontSizeLevel = 4;
tv_font_size.setText("超大");
}
if (onDanmuSet != null) {
onDanmuSet.setFontSizeLevel(currentFontSizeLevel);
}
}
});
final SeekBar sb_danmu_speed = view.findViewById(R.id.sb_danmu_speed);
final TextView tv_danmu_speed = view.findViewById(R.id.tv_danmu_speed);
sb_font_size.setMax(100);
if (currentDanmuSpeedLevel == 0) {
sb_danmu_speed.setProgress(0);
tv_danmu_speed.setText("超慢");
} else if (currentDanmuSpeedLevel == 1) {
sb_danmu_speed.setProgress(25);
tv_danmu_speed.setText("慢");
} else if (currentDanmuSpeedLevel == 2) {
sb_danmu_speed.setProgress(50);
tv_danmu_speed.setText("正常");
} else if (currentDanmuSpeedLevel == 3) {
sb_danmu_speed.setProgress(75);
tv_danmu_speed.setText("快");
} else if (currentDanmuSpeedLevel == 4) {
sb_danmu_speed.setProgress(100);
tv_danmu_speed.setText("超快");
}
sb_danmu_speed.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {