Commit 63ea7af0 authored by zhangww's avatar zhangww
Browse files

3.16.6

1.添加自定义跑马灯数据源
2.添加视频播放状态
3.bug fix
parent 73940fe1
...@@ -61,7 +61,7 @@ dependencies { ...@@ -61,7 +61,7 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.9.0' implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.squareup.picasso:picasso:2.5.2' implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.bokecc:CCVOD:3.16.5' implementation 'com.bokecc:CCVOD:3.16.6'
implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.umeng.umsdk:common:9.4.0' implementation 'com.umeng.umsdk:common:9.4.0'
......
package com.bokecc.vod; package com.bokecc.vod;
import android.content.Context; import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4; import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
......
{
"loop": -1,
"type": "image",
"text": {
"content": "跑马灯",
"font_size": 50,
"color": "#e8cea0"
},
"image": {
"image_url": "https://console.bokecc.com/img/logo.9ba43539.png",
"width": 228,
"height": 60
},
"action": [
{
"index": 0,
"duration": 3000,
"start": {
"xpos": 0.012,
"ypos": 0,
"alpha": 0.8
},
"end": {
"xpos": 0.912,
"ypos": 0.823,
"alpha": 0.8
}
},
{
"index": 1,
"duration": 5000,
"start": {
"xpos": 0.312,
"ypos": 0.823,
"alpha": 0.8
},
"end": {
"xpos": 0.912,
"ypos": 0.123,
"alpha": 0.2
}
}
]
}
\ No newline at end of file
...@@ -11,6 +11,7 @@ public class ConfigUtil { ...@@ -11,6 +11,7 @@ public class ConfigUtil {
* 391E6E3340A00767 * 391E6E3340A00767
*/ */
public static final String USER_ID = "391E6E3340A00767"; public static final String USER_ID = "391E6E3340A00767";
/** /**
* 可以替换为自己的API_KEY * 可以替换为自己的API_KEY
* T8WdOUuvFEiOsou1xjDr4U73v12M7iNa * T8WdOUuvFEiOsou1xjDr4U73v12M7iNa
......
...@@ -8,6 +8,7 @@ import android.widget.Toast; ...@@ -8,6 +8,7 @@ import android.widget.Toast;
import androidx.multidex.MultiDexApplication; import androidx.multidex.MultiDexApplication;
import com.bokecc.common.application.ApplicationData;
import com.bokecc.sdk.mobile.download.VodDownloadManager; import com.bokecc.sdk.mobile.download.VodDownloadManager;
import com.bokecc.sdk.mobile.drm.DRMServer; import com.bokecc.sdk.mobile.drm.DRMServer;
import com.bokecc.sdk.mobile.play.InitializeManager; import com.bokecc.sdk.mobile.play.InitializeManager;
...@@ -20,6 +21,7 @@ import com.umeng.commonsdk.UMConfigure; ...@@ -20,6 +21,7 @@ import com.umeng.commonsdk.UMConfigure;
/** /**
* HuodeApplication * HuodeApplication
*
* @author Zhang * @author Zhang
*/ */
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
......
...@@ -18,6 +18,7 @@ import androidx.appcompat.app.AppCompatActivity; ...@@ -18,6 +18,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.bokecc.sdk.mobile.core.Core;
import com.bokecc.vod.adapter.PlayVideoAdapter; import com.bokecc.vod.adapter.PlayVideoAdapter;
import com.bokecc.vod.data.DataSet; import com.bokecc.vod.data.DataSet;
import com.bokecc.vod.data.DataUtil; import com.bokecc.vod.data.DataUtil;
...@@ -45,15 +46,17 @@ import java.io.InputStreamReader; ...@@ -45,15 +46,17 @@ import java.io.InputStreamReader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.ExecutionException;
/**
* MainActivity
*
* @author CC
*/
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private HeadGridView gv_video_list;
private PlayVideoAdapter playVideoAdapter; private PlayVideoAdapter playVideoAdapter;
private ImageView iv_account_info, iv_upload, iv_download, iv_main_img; private ImageView ivMainImg;
private View headView; private LinearLayout llRetry;
private LinearLayout ll_retry;
private String verificationCode;
private Button btn_retry;
private static final String[] PERMISSIONS_STORAGE = { private static final String[] PERMISSIONS_STORAGE = {
Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE}; Manifest.permission.WRITE_EXTERNAL_STORAGE};
...@@ -66,10 +69,8 @@ public class MainActivity extends AppCompatActivity { ...@@ -66,10 +69,8 @@ public class MainActivity extends AppCompatActivity {
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
MultiUtils.setStatusBarColor(this, R.color.transparent, true); MultiUtils.setStatusBarColor(this, R.color.transparent, true);
initView(); initView();
//初始化数据库和下载数据 没有开通授权播放和下载功能的账号 verificationCode可为空值 //初始化数据库和下载数据 没有开通授权播放和下载功能的账号 verificationCode可为空值
verificationCode = MultiUtils.getVerificationCode(); String verificationCode = MultiUtils.getVerificationCode();
//初始化上传数据库 //初始化上传数据库
UploadController.init(); UploadController.init();
//申请存储权限 //申请存储权限
...@@ -78,15 +79,12 @@ public class MainActivity extends AppCompatActivity { ...@@ -78,15 +79,12 @@ public class MainActivity extends AppCompatActivity {
} else { } else {
MultiUtils.createDownloadPath(); MultiUtils.createDownloadPath();
} }
//启动下载service //启动下载service
Intent intent = new Intent(this, DownloadService.class); Intent intent = new Intent(this, DownloadService.class);
startService(intent); startService(intent);
//启动上传service //启动上传service
Intent uploadIntent = new Intent(this, UploadService.class); Intent uploadIntent = new Intent(this, UploadService.class);
startService(uploadIntent); startService(uploadIntent);
//请求数据 //请求数据
initData(); initData();
} }
...@@ -101,25 +99,22 @@ public class MainActivity extends AppCompatActivity { ...@@ -101,25 +99,22 @@ public class MainActivity extends AppCompatActivity {
private void initView() { private void initView() {
gv_video_list = findViewById(R.id.gv_video_list); HeadGridView gvVideoList = findViewById(R.id.gv_video_list);
iv_account_info = findViewById(R.id.iv_account_info); ImageView ivAccountInfo = findViewById(R.id.iv_account_info);
iv_upload = findViewById(R.id.iv_upload); ImageView ivUpload = findViewById(R.id.iv_upload);
iv_download = findViewById(R.id.iv_download); ImageView ivDownload = findViewById(R.id.iv_download);
ll_retry = findViewById(R.id.ll_retry); llRetry = findViewById(R.id.ll_retry);
btn_retry = findViewById(R.id.btn_retry); Button btnRetry = findViewById(R.id.btn_retry);
headView = LayoutInflater.from(MainActivity.this).inflate(R.layout.headview_main, null); View headView = LayoutInflater.from(MainActivity.this).inflate(R.layout.headview_main, null);
iv_main_img = headView.findViewById(R.id.iv_main_img); ivMainImg = headView.findViewById(R.id.iv_main_img);
gv_video_list.addHeaderView(headView); gvVideoList.addHeaderView(headView);
videoDatas = new ArrayList<>(); videoDatas = new ArrayList<>();
//配置自己的视频时取消这行注释 //TODO 配置自己的视频时取消这行注释
// videoDatas = DataUtil.getVideoList(); // videoDatas = DataUtil.getVideoList();
playVideoAdapter = new PlayVideoAdapter(MainActivity.this, videoDatas); playVideoAdapter = new PlayVideoAdapter(MainActivity.this, videoDatas);
gv_video_list.setAdapter(playVideoAdapter); gvVideoList.setAdapter(playVideoAdapter);
iv_main_img.setImageResource(R.mipmap.iv_default_img); ivMainImg.setImageResource(R.mipmap.iv_default_img);
gvVideoList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
gv_video_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
showKnowledge = position == 0; showKnowledge = position == 0;
...@@ -127,8 +122,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -127,8 +122,7 @@ public class MainActivity extends AppCompatActivity {
selectPlayer(item); selectPlayer(item);
} }
}); });
ivMainImg.setOnClickListener(new View.OnClickListener() {
iv_main_img.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (videoDatas != null && videoDatas.size() > 0) { if (videoDatas != null && videoDatas.size() > 0) {
...@@ -138,36 +132,31 @@ public class MainActivity extends AppCompatActivity { ...@@ -138,36 +132,31 @@ public class MainActivity extends AppCompatActivity {
} }
} }
}); });
ivAccountInfo.setOnClickListener(new View.OnClickListener() {
iv_account_info.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
startActivity(new Intent(MainActivity.this, AccountInfoActivity.class)); startActivity(new Intent(MainActivity.this, AccountInfoActivity.class));
} }
}); });
ivDownload.setOnClickListener(new View.OnClickListener() {
iv_download.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
startActivity(new Intent(MainActivity.this, DownloadListActivity.class)); startActivity(new Intent(MainActivity.this, DownloadListActivity.class));
} }
}); });
ivUpload.setOnClickListener(new View.OnClickListener() {
iv_upload.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
startActivity(new Intent(MainActivity.this, UploadManageActivity.class)); startActivity(new Intent(MainActivity.this, UploadManageActivity.class));
} }
}); });
btnRetry.setOnClickListener(new View.OnClickListener() {
btn_retry.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
ll_retry.setVisibility(View.GONE); llRetry.setVisibility(View.GONE);
initData(); initData();
} }
}); });
} }
...@@ -216,13 +205,16 @@ public class MainActivity extends AppCompatActivity { ...@@ -216,13 +205,16 @@ public class MainActivity extends AppCompatActivity {
private void initData() { private void initData() {
//TODO 配置自己的视频时取消这行注释
// videoDatas = DataUtil.getVideoList(); // videoDatas = DataUtil.getVideoList();
new Thread(new Runnable() { Core.getInstance().getExecutorSupplier()
@Override .forBackgroundTasks()
public void run() { .execute(new Runnable() {
request(); @Override
} public void run() {
}).start(); request();
}
});
} }
private void request() { private void request() {
...@@ -268,7 +260,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -268,7 +260,7 @@ public class MainActivity extends AppCompatActivity {
playVideoAdapter.notifyDataSetChanged(); playVideoAdapter.notifyDataSetChanged();
HuodeVideoInfo huodeVideoInfo = videoDatas.get(0); HuodeVideoInfo huodeVideoInfo = videoDatas.get(0);
if (huodeVideoInfo != null) { if (huodeVideoInfo != null) {
MultiUtils.showCornerVideoCover(iv_main_img, huodeVideoInfo.getVideoCover()); MultiUtils.showCornerVideoCover(ivMainImg, huodeVideoInfo.getVideoCover());
} }
} }
}); });
...@@ -276,7 +268,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -276,7 +268,7 @@ public class MainActivity extends AppCompatActivity {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
ll_retry.setVisibility(View.VISIBLE); llRetry.setVisibility(View.VISIBLE);
} }
}); });
e.printStackTrace(); e.printStackTrace();
...@@ -288,7 +280,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -288,7 +280,7 @@ public class MainActivity extends AppCompatActivity {
e.printStackTrace(); e.printStackTrace();
} }
} }
if (connection != null) {//关闭连接 if (connection != null) {
connection.disconnect(); connection.disconnect();
} }
} }
......
...@@ -15,72 +15,75 @@ import com.bokecc.vod.utils.MultiUtils; ...@@ -15,72 +15,75 @@ import com.bokecc.vod.utils.MultiUtils;
import java.util.List; import java.util.List;
public class DownloadedViewAdapter extends BaseAdapter{ /**
* DownloadedViewAdapter
*
* @author CC
*/
public class DownloadedViewAdapter extends BaseAdapter {
private List<DownloadInfo> downloadInfos; private final List<DownloadInfo> downloadInfoArray;
private Context context; private final Context context;
public DownloadedViewAdapter(Context context, List<DownloadInfo> downloadInfos){ public DownloadedViewAdapter(Context context, List<DownloadInfo> downloadInfoArray) {
this.context = context; this.context = context;
this.downloadInfos = downloadInfos; this.downloadInfoArray = downloadInfoArray;
} }
@Override @Override
public int getCount() { public int getCount() {
return downloadInfos.size(); return downloadInfoArray.size();
} }
@Override @Override
public Object getItem(int position) { public Object getItem(int position) {
return downloadInfos.get(position); return downloadInfoArray.get(position);
} }
@Override @Override
public long getItemId(int position) { public long getItemId(int position) {
return position; return position;
} }
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
DownloadInfo downloadInfo = downloadInfos.get(position); DownloadInfo downloadInfo = downloadInfoArray.get(position);
ViewHolder holder = null; ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = View.inflate(context, R.layout.item_downloaded_video, null);
holder.tvFileSize = convertView.findViewById(R.id.tv_filesize);
holder.titleView = convertView.findViewById(R.id.downloaded_title);
holder.ivVideoCover = convertView.findViewById(R.id.iv_video_cover);
holder.tvSubtitleState = convertView.findViewById(R.id.tv_subtitle_state);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.titleView.setText(downloadInfo.getTitle());
long end = downloadInfo.getEnd();
if (end > 0) {
holder.tvFileSize.setVisibility(View.VISIBLE);
holder.tvFileSize.setText(Formatter.formatFileSize(context, downloadInfo.getEnd()));
} else {
holder.tvFileSize.setVisibility(View.INVISIBLE);
}
MultiUtils.showVideoCover(holder.ivVideoCover, downloadInfo.getVideoCover());
int firstSubtitleStatus = downloadInfo.getFirstSubtitleStatus();
if (firstSubtitleStatus == 2) {
holder.tvSubtitleState.setVisibility(View.VISIBLE);
holder.tvSubtitleState.setText("下载字幕失败");
} else {
holder.tvSubtitleState.setVisibility(View.INVISIBLE);
}
return convertView;
}
if (convertView == null) { public static class ViewHolder {
holder = new ViewHolder(); public TextView titleView;
convertView = View.inflate(context, R.layout.item_downloaded_video, null); public TextView tvFileSize;
holder.tv_filesize = convertView.findViewById(R.id.tv_filesize); public TextView tvSubtitleState;
holder.titleView = convertView.findViewById(R.id.downloaded_title); public ImageView ivVideoCover;
holder.iv_video_cover = convertView.findViewById(R.id.iv_video_cover); }
holder.tv_subtitle_state = convertView.findViewById(R.id.tv_subtitle_state);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.titleView.setText(downloadInfo.getTitle());
long end = downloadInfo.getEnd();
if (end>0){
holder.tv_filesize.setVisibility(View.VISIBLE);
holder.tv_filesize.setText(Formatter.formatFileSize(context, downloadInfo.getEnd()));
}else {
holder.tv_filesize.setVisibility(View.INVISIBLE);
}
MultiUtils.showVideoCover(holder.iv_video_cover,downloadInfo.getVideoCover());
int firstSubtitleStatus = downloadInfo.getFirstSubtitleStatus();
if (firstSubtitleStatus==2){
holder.tv_subtitle_state.setVisibility(View.VISIBLE);
holder.tv_subtitle_state.setText("下载字幕失败");
}else {
holder.tv_subtitle_state.setVisibility(View.INVISIBLE);
}
return convertView;
}
public class ViewHolder {
public TextView titleView;
public TextView tv_filesize;
public TextView tv_subtitle_state;
public ImageView iv_video_cover;
}
} }
...@@ -13,11 +13,8 @@ import androidx.fragment.app.FragmentManager; ...@@ -13,11 +13,8 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter; import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
import com.bokecc.sdk.mobile.download.DownloadConfig;
import com.bokecc.sdk.mobile.download.VodDownloadManager;
import com.bokecc.sdk.mobile.util.HttpUtil;
import com.bokecc.vod.R;
import com.bokecc.vod.ConfigUtil; import com.bokecc.vod.ConfigUtil;
import com.bokecc.vod.R;
import com.bokecc.vod.utils.MultiUtils; import com.bokecc.vod.utils.MultiUtils;
......
...@@ -14,7 +14,6 @@ import androidx.annotation.Nullable; ...@@ -14,7 +14,6 @@ import androidx.annotation.Nullable;
import com.bokecc.sdk.mobile.download.VodDownloadBean; import com.bokecc.sdk.mobile.download.VodDownloadBean;
import com.bokecc.sdk.mobile.download.VodDownloadManager; import com.bokecc.sdk.mobile.download.VodDownloadManager;
import com.bokecc.sdk.mobile.util.HttpUtil;
import com.bokecc.vod.data.DataSet; import com.bokecc.vod.data.DataSet;
import com.bokecc.vod.data.DownloadInfo; import com.bokecc.vod.data.DownloadInfo;
import com.bokecc.vod.utils.MultiUtils; import com.bokecc.vod.utils.MultiUtils;
...@@ -26,174 +25,174 @@ import java.util.TimerTask; ...@@ -26,174 +25,174 @@ import java.util.TimerTask;
/** /**
* DownloadService,用于支持后台下载 * DownloadService,用于支持后台下载
* *
*