我正在尝试使用此播放器在android上播放本地mp4视频:
https://github.com/lipangit/JiaoZiVideoPlayer
我已经设法通过示例视频网址来使其正常工作:
jzvdStd.setUp(“ http://jzvd.nathen.cn/c6e3dc12a1154626b3476d9bf3bd7266/6b56c5f0dc31428083757a45764763b0-5287d2089db37e62345123a1be272f8b.mp4” ,“饺子闭眼”,Jzvd.SCREEN_WINDOW_NORMAL);
但是,当我将其更改为youtube链接或本地uri链接时,会显示视频加载失败错误:
this.allquestionsnew
答案 0 :(得分:1)
您可以尝试这个。
String path = getApplicationContext().getFilesDir().getAbsolutePath() + "/" + videoData.getVideoPath();
File file = new File(path);
Uri mp4VideoUri = Uri.fromFile(file);
try{
JZDataSource jzDataSource = null;
jzDataSource = new JZDataSource(mp4VideoUri);
jzDataSource.title = "your title";
jzvdStd.setUp(jzDataSource, JzvdStd.SCREEN_WINDOW_NORMAL);
jzvdStd.startVideo();
}catch (Exception e){
Log.d(TAG, e.toString());
}
答案 1 :(得分:0)
使用jzvd播放器并在屏幕上播放mp4的所有步骤。
添加依赖项
implementation 'cn.jzvd:jiaozivideoplayer:7.0.5'
添加到您的构建gradle> android标签
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
添加到xml文件
<cn.jzvd.JzvdStd
android:id="@+id/video_player"
android:layout_width="match_parent"
android:layout_height="match_parent" />
您的活动看起来像
public class ShowVideoActivity extends AppCompatActivity {
JzvdStd jzvdStd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_show_video);
jzvdStd = (JzvdStd) findViewById(R.id.video_player);
String videoLink = getIntent().getExtras().getString("videoLink");
jzvdStd.setUp(videoLink, "title", 0);
jzvdStd.setScreenFullscreen();
jzvdStd.backButton.setVisibility(View.GONE);
jzvdStd.batteryLevel.setVisibility(View.GONE);
jzvdStd.batteryTimeLayout.setVisibility(View.GONE);
jzvdStd.titleTextView.setVisibility(View.GONE);
jzvdStd.fullscreenButton.setVisibility(View.GONE);
jzvdStd.dismissBrightnessDialog();
jzvdStd.dismissVolumeDialog();
jzvdStd.dissmissControlView();
jzvdStd.dismissProgressDialog();
jzvdStd.startVideo();
RequestOptions requestOptions = new RequestOptions();
requestOptions.isMemoryCacheable();
Glide.with(jzvdStd.getContext())
.setDefaultRequestOptions(requestOptions)
.load(videoLink)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(jzvdStd.thumbImageView);
}
@Override
public void onBackPressed() {
if (Jzvd.backPress()) {
super.onBackPressed();
return;
}
super.onBackPressed();
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
protected void onPause() {
super.onPause();
Jzvd.releaseAllVideos();
}
}