思路 android studio
1:发送请求获取服务器所有视频的路径
2:根据路径获取视频的第一帧
3:使用(RecyclerView) 存放图片 在适配器中添加事件 传给 播放的activate
4:在播放的activate 使用(VideoView) 播放 差不多了 贴代码
后台 myeclipse servlet oracle 操作数据库 mybatis
android studio 端 MainActivity 写的不严谨 但是不影响使用
package wlt.com.video;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import wlt.com.video.adapter.Listadapter;
import wlt.com.video.bean.VideoVo;
public class MainActivity extends AppCompatActivity {
private RecyclerView recyclerView;
private Listadapter listadapte;
private LinearLayoutManager layoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.list);
recyclerView = (RecyclerView) this.findViewById(R.id.recy);
StaggeredGridLayoutManager manager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
alert();
recyclerView.setLayoutManager(manager);
final List<VideoVo> lise = setdate();
listadapte = new Listadapter(MainActivity.this, lise);
listadapte.notifyDataSetChanged();
recyclerView.setAdapter(listadapte);
listadapte.setMyonitemClick(new Listadapter.MyonitemClick() {
@Override
public void MyOnitemClicks(int positoin) {
Intent intent = new Intent(MainActivity.this, StatcVideo.class);
//这里将视频的路径传过去
intent.putExtra("url", lise.get(positoin).getV_url());
startActivity(intent);
}
});
// recyclerView.addItemDecoration(new SprxxxxxxxxxxxxKK(3));
//添加事件
}
public void alert(){
final ProgressDialog dialog = new ProgressDialog(MainActivity.this);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
// 设置ProgressDialog 标题
dialog.setTitle("溪瑶视频");
// 设置ProgressDialog 提示信息
dialog.setMessage("视频正在加载中……");
// 设置ProgressDialog 标题图标
dialog.setIcon(R.drawable.ic_launcher_background);
// 设置ProgressDialog 进度条进度
//dialog.setProgress(100);
// 设置ProgressDialog 的进度条是否不明确
dialog.setIndeterminate(false);
// 设置ProgressDialog 是否可以按退回按键取消
dialog.setCancelable(true);
dialog.setButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int i) {
// 点击“取消”按钮取消对话框
dialog.cancel();
}
})