Commit 7219c362 authored by Hanruisong's avatar Hanruisong
Browse files

feat: 更新到v3.14.0

1.新增自定义Logo功能。
parent ebcabd06
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.13.0'
implementation 'com.bokecc:vod:3.14.0'
//必须引用commonLib
implementation 'com.bokecc:commonLib:0.1.12'
//必须引用
......
......@@ -37,6 +37,8 @@ public class DownloadInfo {
private int subtitleNum;
private String logoPath;
public DownloadInfo() {
......@@ -170,4 +172,12 @@ public class DownloadInfo {
public void setSubtitleNum(int subtitleNum) {
this.subtitleNum = subtitleNum;
}
public String getLogoPath() {
return logoPath;
}
public void setLogoPath(String logoPath) {
this.logoPath = logoPath;
}
}
package com.bokecc.vod.data;
public class LogoInfo {
private String fileName;
private String logoUrl;
public LogoInfo(String fileName, String logoUrl) {
this.fileName = fileName;
this.logoUrl = logoUrl;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getLogoUrl() {
return logoUrl;
}
public void setLogoUrl(String logoUrl) {
this.logoUrl = logoUrl;
}
}
......@@ -70,27 +70,43 @@ public class DownloadService extends Service {
VodDownloadManager.getInstance().setOnDownloadFinishListener(new VodDownloadManager.OnDownloadFinishListener() {
@Override
public void onDownloadFinish(final VodDownloadBean vodDownloadBean) {
DownloadInfo downloadInfo = new DownloadInfo();
downloadInfo.setVideoId(vodDownloadBean.getVideoId());
downloadInfo.setTitle(vodDownloadBean.getFileName());
downloadInfo.setFormat(vodDownloadBean.getFormat());
downloadInfo.setDownloadMode(vodDownloadBean.getDownloadMode());
downloadInfo.setVideoCover(vodDownloadBean.getVideoCover());
downloadInfo.setEnd(vodDownloadBean.getEnd());
downloadInfo.setStatus(vodDownloadBean.getStatus());
downloadInfo.setCreateTime(new Date());
downloadInfo.setDefinition(vodDownloadBean.getDefinition());
downloadInfo.setFirstSubtitleStatus(vodDownloadBean.getFirstSubtitleStatus());
downloadInfo.setSecondSubtitleStatus(vodDownloadBean.getSecondSubtitleStatus());
downloadInfo.setSubtitleNum(vodDownloadBean.getSubtitleNum());
DataSet.addDownloadInfo(downloadInfo);
if (onUpdateDownloadedView!=null){
onUpdateDownloadedView.updateDownloadedView(downloadInfo);
String fileName = vodDownloadBean.getFileName();
if (DataSet.hasDownloadInfo(fileName)){
DownloadInfo downloadInfo = DataSet.getDownloadInfo(fileName);
saveDownloadInfo(vodDownloadBean, downloadInfo);
DataSet.updateDownloadInfo(downloadInfo);
if (onUpdateDownloadedView!=null){
onUpdateDownloadedView.updateDownloadedView(downloadInfo);
}
}else {
DownloadInfo downloadInfo = new DownloadInfo();
saveDownloadInfo(vodDownloadBean, downloadInfo);
DataSet.addDownloadInfo(downloadInfo);
if (onUpdateDownloadedView!=null){
onUpdateDownloadedView.updateDownloadedView(downloadInfo);
}
}
}
});
}
private void saveDownloadInfo(VodDownloadBean vodDownloadBean, DownloadInfo downloadInfo) {
downloadInfo.setVideoId(vodDownloadBean.getVideoId());
downloadInfo.setTitle(vodDownloadBean.getFileName());
downloadInfo.setFormat(vodDownloadBean.getFormat());
downloadInfo.setDownloadMode(vodDownloadBean.getDownloadMode());
downloadInfo.setVideoCover(vodDownloadBean.getVideoCover());
downloadInfo.setEnd(vodDownloadBean.getEnd());
downloadInfo.setStatus(vodDownloadBean.getStatus());
downloadInfo.setCreateTime(new Date());
downloadInfo.setDefinition(vodDownloadBean.getDefinition());
downloadInfo.setFirstSubtitleStatus(vodDownloadBean.getFirstSubtitleStatus());
downloadInfo.setSecondSubtitleStatus(vodDownloadBean.getSecondSubtitleStatus());
downloadInfo.setSubtitleNum(vodDownloadBean.getSubtitleNum());
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
......
......@@ -5,6 +5,7 @@ import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -65,6 +66,7 @@ public class DownloadedFragment extends Fragment implements DownloadService.OnUp
intent.putExtra("isLocalPlay", true);
intent.putExtra("videoTitle", downloadInfo.getTitle());
intent.putExtra("format", downloadInfo.getFormat());
intent.putExtra("logoPath", downloadInfo.getLogoPath());
startActivity(intent);
}
......@@ -75,6 +77,7 @@ public class DownloadedFragment extends Fragment implements DownloadService.OnUp
intent.putExtra("isLocalPlay", true);
intent.putExtra("videoTitle", downloadInfo.getTitle());
intent.putExtra("format", downloadInfo.getFormat());
intent.putExtra("logoPath", downloadInfo.getLogoPath());
startActivity(intent);
}
......@@ -119,6 +122,14 @@ public class DownloadedFragment extends Fragment implements DownloadService.OnUp
subtitleSet.delete();
}
String logoPath = downloadInfo.getLogoPath();
if (!TextUtils.isEmpty(logoPath)){
File logoFile = new File(logoPath);
if (logoFile.exists()){
logoFile.delete();
}
}
updateListView();
}
});
......@@ -131,6 +142,11 @@ public class DownloadedFragment extends Fragment implements DownloadService.OnUp
private void initData() {
List<DownloadInfo> downloadInfos = DataSet.getDownloadInfos();
for (DownloadInfo downloadInfo : downloadInfos){
if (TextUtils.isEmpty(downloadInfo.getVideoId())){
downloadInfos.remove(downloadInfo);
}
}
downloadedInfos.addAll(downloadInfos);
videoListViewAdapter = new DownloadedViewAdapter(activity, downloadedInfos);
lv_downloaded.setAdapter(videoListViewAdapter);
......
......@@ -3,6 +3,7 @@ package com.bokecc.vod.download;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -17,9 +18,12 @@ import com.bokecc.sdk.mobile.download.VodDownloadManager;
import com.bokecc.sdk.mobile.util.HttpUtil;
import com.bokecc.vod.R;
import com.bokecc.vod.adapter.DownloadViewAdapter;
import com.bokecc.vod.data.DataSet;
import com.bokecc.vod.data.DownloadInfo;
import com.bokecc.vod.inter.DeleteFile;
import com.bokecc.vod.view.DeleteFileDialog;
import java.io.File;
import java.util.List;
/**
......@@ -69,6 +73,19 @@ public class DownloadingFragment extends Fragment {
public void deleteFile() {
DownloadOperator downloadOperator = (DownloadOperator) downloadAdapter.getItem(position);
VodDownloadManager.getInstance().deleteDownloadInfo(downloadOperator);
String fileName = downloadOperator.getVodDownloadBean().getFileName();
if (DataSet.hasDownloadInfo(fileName)) {
DownloadInfo downloadInfo = DataSet.getDownloadInfo(fileName);
DataSet.removeDownloadInfo(downloadInfo);
String logoPath = downloadInfo.getLogoPath();
if (!TextUtils.isEmpty(logoPath)) {
File logoFile = new File(logoPath);
if (logoFile.exists()) {
logoFile.delete();
}
}
}
updateListView();
initAllPause();
}
......@@ -83,9 +100,9 @@ public class DownloadingFragment extends Fragment {
btn_all_pause_or_start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isAllPause){
if (isAllPause) {
VodDownloadManager.getInstance().resumeAllDownload();
}else {
} else {
VodDownloadManager.getInstance().pauseAllDownload();
}
updateListView();
......
......@@ -97,7 +97,6 @@ import com.bokecc.sdk.mobile.play.OnQAMsgListener;
import com.bokecc.sdk.mobile.play.OnSendDanmuListener;
import com.bokecc.sdk.mobile.play.OnVisitMsgListener;
import com.bokecc.sdk.mobile.play.PlayInfo;
import com.bokecc.sdk.mobile.util.HttpUtil;
import com.bokecc.vod.ConfigUtil;
import com.bokecc.vod.HuodeApplication;
import com.bokecc.vod.R;
......@@ -107,6 +106,7 @@ import com.bokecc.vod.data.DanmuInfoParse;
import com.bokecc.vod.data.DataSet;
import com.bokecc.vod.data.Exercise;
import com.bokecc.vod.data.HuodeVideoInfo;
import com.bokecc.vod.data.LogoInfo;
import com.bokecc.vod.data.ObjectBox;
import com.bokecc.vod.data.Question;
import com.bokecc.vod.data.VibrationInfo;
......@@ -122,8 +122,10 @@ import com.bokecc.vod.inter.OnDanmuSet;
import com.bokecc.vod.inter.OnEditDanmuText;
import com.bokecc.vod.inter.SelectDefinition;
import com.bokecc.vod.inter.SelectVideo;
import com.bokecc.vod.utils.SaveLogoUtil;
import com.bokecc.vod.utils.MultiUtils;
import com.bokecc.vod.view.CheckNetworkDialog;
import com.bokecc.vod.view.CustomLogoView;
import com.bokecc.vod.view.DanmuSetDialog;
import com.bokecc.vod.view.DoExerciseDialog;
import com.bokecc.vod.view.EditDanmuTextDialog;
......@@ -412,6 +414,12 @@ public class MediaPlayActivity extends Activity implements View.OnClickListener,
private long playedTime = 0;
private boolean isPlayCompleted;
//自定义logo
private CustomLogoView clv_logo;
private String logoUrl = "";
private String logoPath;
private float xPosRate = 0.1f, yPosRate = 0.1f,logoWidthRate = 0.1f,logoHeightRate = 0.1f;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -442,6 +450,7 @@ public class MediaPlayActivity extends Activity implements View.OnClickListener,
videoTitle = getIntent().getStringExtra("videoTitle");
videoCover = getIntent().getStringExtra("videoCover");
format = getIntent().getStringExtra("format");
logoPath = getIntent().getStringExtra("logoPath");
isLocalPlay = getIntent().getBooleanExtra("isLocalPlay", false);
......@@ -561,6 +570,7 @@ public class MediaPlayActivity extends Activity implements View.OnClickListener,
iv_landscape_danmu_switch.setOnClickListener(this);
ll_landscape_danmu_set_send = findViewById(R.id.ll_landscape_danmu_set_send);
rl_danmu = findViewById(R.id.rl_danmu);
clv_logo = findViewById(R.id.clv_logo);
tv_video_title.setText(videoTitle);
iv_back.setOnClickListener(this);
......@@ -2169,6 +2179,7 @@ public class MediaPlayActivity extends Activity implements View.OnClickListener,
int downloadCount = 0;
int selectedCount = 0;
ArrayList<DownloadConfig> downloadConfigs = new ArrayList<>();
ArrayList<LogoInfo> logoInfos = new ArrayList<>();
for (int i = 0; i < videoList.size(); i++) {
HuodeVideoInfo videoInfo = videoList.get(i);
if (videoInfo.isSelectedDownload()) {
......@@ -2179,12 +2190,19 @@ public class MediaPlayActivity extends Activity implements View.OnClickListener,
DownloadConfig downloadConfig = new DownloadConfig(videoInfo.getVideoId(), verificationCode, videoTitle, 0, 0, videoCover);
downloadConfigs.add(downloadConfig);
downloadCount++;
if (!TextUtils.isEmpty(logoUrl)){
LogoInfo logoInfo = new LogoInfo(videoTitle, logoUrl);
logoInfos.add(logoInfo);
}
}
selectedCount++;
}
}
VodDownloadManager.getInstance().insertBatchDownload(downloadConfigs);
SaveLogoUtil.saveLogo(logoInfos);
if (downloadCount > 0) {
MultiUtils.showToast(activity, "文件已加入下载队列");
} else {
......@@ -2620,6 +2638,13 @@ public class MediaPlayActivity extends Activity implements View.OnClickListener,
DownloadConfig downloadConfig = new DownloadConfig(videoId, verificationCode, dowloadTitle, downloadMode, currentDefinition, videoCover);
VodDownloadManager.getInstance().insertDownload(downloadConfig);
}
ArrayList<LogoInfo> logoInfos = new ArrayList<>();
if (!TextUtils.isEmpty(logoUrl)){
LogoInfo logoInfo = new LogoInfo(dowloadTitle, logoUrl);
logoInfos.add(logoInfo);
}
SaveLogoUtil.saveLogo(logoInfos);
MultiUtils.showToast(activity, "文件已加入下载队列");
}
......@@ -2957,9 +2982,13 @@ public class MediaPlayActivity extends Activity implements View.OnClickListener,
}
}
}
//自定义logo
clv_logo.setCustomLogoInfo(logoUrl, xPosRate, yPosRate, logoWidthRate, logoHeightRate);
} else {
clv_logo.setCustomLogoInfo(logoPath, xPosRate, yPosRate, logoWidthRate, logoHeightRate);
setLandScape();
}
clv_logo.show();
//设置视频总时长
videoDuration = player.getDuration();
tv_video_time.setText(MultiUtils.millsecondsToMinuteSecondStr(videoDuration));
......@@ -3522,6 +3551,8 @@ public class MediaPlayActivity extends Activity implements View.OnClickListener,
if (pauseVideoAdDialog != null && pauseVideoAdDialog.isShowing()) {
pauseVideoAdDialog.updateView(isFullScreen);
}
clv_logo.refreshView();
}
//设置为全屏播放
......@@ -3575,6 +3606,8 @@ public class MediaPlayActivity extends Activity implements View.OnClickListener,
if (pauseVideoAdDialog != null && pauseVideoAdDialog.isShowing()) {
pauseVideoAdDialog.updateView(isFullScreen);
}
clv_logo.refreshView();
}
//设置横屏TextureView的宽和高,使视频高度和屏幕宽度一致
......
......@@ -96,7 +96,6 @@ import com.bokecc.sdk.mobile.play.OnQAMsgListener;
import com.bokecc.sdk.mobile.play.OnSendDanmuListener;
import com.bokecc.sdk.mobile.play.OnVisitMsgListener;
import com.bokecc.sdk.mobile.play.PlayInfo;
import com.bokecc.sdk.mobile.util.HttpUtil;
import com.bokecc.vod.ConfigUtil;
import com.bokecc.vod.HuodeApplication;
import com.bokecc.vod.R;
......@@ -106,6 +105,7 @@ import com.bokecc.vod.data.DanmuInfoParse;
import com.bokecc.vod.data.DataSet;
import com.bokecc.vod.data.Exercise;
import com.bokecc.vod.data.HuodeVideoInfo;
import com.bokecc.vod.data.LogoInfo;
import com.bokecc.vod.data.ObjectBox;
import com.bokecc.vod.data.Question;
import com.bokecc.vod.data.VibrationInfo;
......@@ -123,7 +123,9 @@ import com.bokecc.vod.inter.SelectDefinition;
import com.bokecc.vod.inter.SelectSpeed;
import com.bokecc.vod.inter.SelectVideo;
import com.bokecc.vod.utils.MultiUtils;
import com.bokecc.vod.utils.SaveLogoUtil;
import com.bokecc.vod.view.CheckNetworkDialog;
import com.bokecc.vod.view.CustomLogoView;
import com.bokecc.vod.view.DanmuSetDialog;
import com.bokecc.vod.view.DoExerciseDialog;
import com.bokecc.vod.view.EditDanmuTextDialog;
......@@ -413,6 +415,12 @@ public class SpeedPlayActivity extends Activity implements View.OnClickListener,
private long playedTime = 0;
private boolean isPlayCompleted;
//自定义logo
private CustomLogoView clv_logo;
private String logoUrl = "";
private String logoPath;
private float xPosRate = 0.1f, yPosRate = 0.1f,logoWidthRate = 0.1f,logoHeightRate = 0.1f;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -442,6 +450,7 @@ public class SpeedPlayActivity extends Activity implements View.OnClickListener,
videoTitle = getIntent().getStringExtra("videoTitle");
videoCover = getIntent().getStringExtra("videoCover");
format = getIntent().getStringExtra("format");
logoPath = getIntent().getStringExtra("logoPath");
isLocalPlay = getIntent().getBooleanExtra("isLocalPlay", false);
......@@ -555,6 +564,7 @@ public class SpeedPlayActivity extends Activity implements View.OnClickListener,
iv_landscape_danmu_switch.setOnClickListener(this);
ll_landscape_danmu_set_send = findViewById(R.id.ll_landscape_danmu_set_send);
rl_danmu = findViewById(R.id.rl_danmu);
clv_logo = findViewById(R.id.clv_logo);
tv_video_title.setText(videoTitle);
iv_back.setOnClickListener(this);
......@@ -2184,6 +2194,7 @@ public class SpeedPlayActivity extends Activity implements View.OnClickListener,
int downloadCount = 0;
int selectedCount = 0;
ArrayList<DownloadConfig> downloadConfigs = new ArrayList<>();
ArrayList<LogoInfo> logoInfos = new ArrayList<>();
for (int i = 0; i < videoList.size(); i++) {
HuodeVideoInfo videoInfo = videoList.get(i);
if (videoInfo.isSelectedDownload()) {
......@@ -2194,11 +2205,18 @@ public class SpeedPlayActivity extends Activity implements View.OnClickListener,
DownloadConfig downloadConfig = new DownloadConfig(videoInfo.getVideoId(), verificationCode, videoTitle, 0, 0, videoCover);
downloadConfigs.add(downloadConfig);
downloadCount++;
if (!TextUtils.isEmpty(logoUrl)){
LogoInfo logoInfo = new LogoInfo(videoTitle, logoUrl);
logoInfos.add(logoInfo);
}
}
selectedCount++;
}
}
VodDownloadManager.getInstance().insertBatchDownload(downloadConfigs);
SaveLogoUtil.saveLogo(logoInfos);
if (downloadCount > 0) {
MultiUtils.showToast(activity, "文件已加入下载队列");
} else {
......@@ -2639,6 +2657,13 @@ public class SpeedPlayActivity extends Activity implements View.OnClickListener,
DownloadConfig downloadConfig = new DownloadConfig(videoId, verificationCode, dowloadTitle, downloadMode, currentDefinition, videoCover);
VodDownloadManager.getInstance().insertDownload(downloadConfig);
}
ArrayList<LogoInfo> logoInfos = new ArrayList<>();
if (!TextUtils.isEmpty(logoUrl)){
LogoInfo logoInfo = new LogoInfo(dowloadTitle, logoUrl);
logoInfos.add(logoInfo);
}
SaveLogoUtil.saveLogo(logoInfos);
MultiUtils.showToast(activity, "文件已加入下载队列");
}
......@@ -2975,9 +3000,13 @@ public class SpeedPlayActivity extends Activity implements View.OnClickListener,
}
}
}
clv_logo.setCustomLogoInfo(logoUrl, xPosRate, yPosRate, logoWidthRate, logoHeightRate);
} else {
clv_logo.setCustomLogoInfo(logoPath, xPosRate, yPosRate, logoWidthRate, logoHeightRate);
setLandScape();
}
clv_logo.show();
//设置视频总时长
videoDuration = player.getDuration();
tv_video_time.setText(MultiUtils.millsecondsToMinuteSecondStr(videoDuration));
......@@ -3548,6 +3577,8 @@ public class SpeedPlayActivity extends Activity implements View.OnClickListener,
if (pauseVideoAdDialog != null && pauseVideoAdDialog.isShowing()) {
pauseVideoAdDialog.updateView(isFullScreen);
}
clv_logo.refreshView();
}
//设置为全屏播放
......@@ -3601,6 +3632,8 @@ public class SpeedPlayActivity extends Activity implements View.OnClickListener,
if (pauseVideoAdDialog != null && pauseVideoAdDialog.isShowing()) {
pauseVideoAdDialog.updateView(isFullScreen);
}
clv_logo.refreshView();
}
//设置横屏TextureView的宽和高,使视频高度和屏幕宽度一致
......
package com.bokecc.vod.utils;
import android.text.TextUtils;
import com.bokecc.sdk.mobile.util.HttpUtil;
import com.bokecc.sdk.mobile.util.SSLClient;
import com.bokecc.vod.data.DataSet;
import com.bokecc.vod.data.DownloadInfo;
import com.bokecc.vod.data.LogoInfo;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
public class SaveLogoUtil {
private static final int BUFFER_SIZE = 1024 * 30;
public static void saveLogo(final ArrayList<LogoInfo> logoInfos){
if (logoInfos!=null && logoInfos.size()>0){
new Thread(new Runnable() {
@Override
public void run() {
for (LogoInfo logoInfo:logoInfos){
downloadLogo(logoInfo);
}
}
}).start();
}
}
private static void downloadLogo(LogoInfo logoInfo){
String fileName = logoInfo.getFileName();
String logoUrl = logoInfo.getLogoUrl();
if (TextUtils.isEmpty(fileName) || TextUtils.isEmpty(logoUrl)){
return;
}
String format = ".jpg";
if (logoUrl.contains(".jpg")){
format = ".jpg";
}else if (logoUrl.contains(".jpeg")){
format = ".jpeg";
}else if (logoUrl.contains(".png")){
format = ".png";
}else if (logoUrl.contains(".gif")){
format = ".gif";
}
String downloadPath = MultiUtils.createDownloadPath();
String saveLogoPath = downloadPath + fileName + format;
File file = new File(saveLogoPath);
HttpURLConnection httpURLConnection = null;
RandomAccessFile randomAccessFile = null;
InputStream inputStream = null;
boolean isEnd = false;
long start = 0;
long end = 0;
if (file != null) {
long fileLength = file.length();
if (fileLength >= 0l) {
start = fileLength;
}
}
try {
URL url = new URL(logoUrl);
httpURLConnection = SSLClient.getUrlConnection(logoUrl, url);
httpURLConnection.setReadTimeout(5000);
httpURLConnection.setConnectTimeout(5000);
httpURLConnection.setRequestProperty("accept", "*/*");
httpURLConnection.setRequestProperty("connection", "Keep-Alive");
httpURLConnection.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
httpURLConnection.setRequestProperty("Accept-Language", "zh-CN");
if (start > 0) {
httpURLConnection.setRequestProperty("Range", (new StringBuilder("bytes=")).append(start).append("-").toString());
}
httpURLConnection.setRequestMethod("GET");
httpURLConnection.connect();
int responseCode = httpURLConnection.getResponseCode();
if (responseCode == 416) {
saveLogoPath(fileName,saveLogoPath);
return;
}
if (responseCode >= 400){
return;
}
String contentLength = httpURLConnection.getHeaderField("Content-Length");
end = start + Long.parseLong(contentLength);
randomAccessFile = new RandomAccessFile(file, "rwd");
randomAccessFile.seek(start);
inputStream = httpURLConnection.getInputStream();
byte[] buffer = new byte[BUFFER_SIZE];