无法播放此视频错误

编程入门 行业动态 更新时间:2024-10-10 08:22:57
本文介绍了无法播放此视频错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 public class MainActivity extends AppCompatActivity { Button clk; VideoView videov; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); clk=(Button) findViewById(R.id.video); videov=(VideoView)findViewById(R.id.videoView); } public void videoplay(View v){ String videopath = "android.resource://"+getPackageName()+"+R.raw.movie"; Uri uri =Uri.parse(videopath); videov.setVideoURI(uri); videov.requestFocus(); videov.start(); } }

无法播放此视频错误...!看图片屏幕截图 怎么办? 按下播放按钮后,它说无法播放此视频.. !! 需要解决这个问题。

Can't play this video error...!! see the picture Screen Shot What to do ? After pressing play button it says cant play this video..!! Need solution of this problem.

推荐答案

前天我有同样的问题并尝试过几乎所有事情但没有做过取得任何成功。之后,我使用这个库,它工作正常。只需按照以下几个步骤操作:

Hi day before yesterday i had same problem and tried almost everything but didn't get any success. After that i used this library and it work fine. Just follow few steps:

Step1。将其添加到您的gradle中

Step1. Add it to your gradle

compile "fm.jiecao:jiecaovideoplayer:4.7.0"

Step2。将其添加为xml布局中的视频播放。

Step2. Add it as your video play in xml layout.

<fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard android:id="@+id/videoPlayer" android:layout_width="match_parent" android:layout_height="match_parent" />

第3步。从这里查看如何在课堂上使用此库,

Step 3. Check from here how to use this library in your class,

public class PlayVideoActivity extends BaseActivity { @BindView(R.id.videoPlayer) JCVideoPlayerStandard mVideoPlayer; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); restoreFromIntent(getIntent()); } @Override public int getLayout() { return R.layout.activity_play_video; } //create intent for this activity with all the necessary params public static Intent createIntent(Context context, String videoUrl) { Intent intent = new Intent(context, PlayVideoActivity.class); intent.putExtra(ValueConstants.VIDEO_URL, videoUrl); return intent; } // get video path from intent and play the video here private void restoreFromIntent(Intent intent) { String videoPath = intent.getExtras().getString(ValueConstants.VIDEO_URL); mVideoPlayer.setUp(videoPath , JCVideoPlayerStandard.SCREEN_LAYOUT_LIST, ""); } @Override public void onBackPressed() { if (JCVideoPlayer.backPress()) { return; } super.onBackPressed(); } @Override protected void onPause() { super.onPause(); JCVideoPlayer.releaseAllVideos(); } }

我身边还有一件额外的奖励。您也可以使用此库进行视频缓存。昨天我也发现了这一点。从互联网上播放一次。播放后也没有上网。

One more bonus thing from my side. You can do video cache also by using this library. Yesterday i found this also.One time play from internet.After it play without internet also.

更新回答:

以上示例我已经提供了从网址播放在线视频,但这个问题与视频路径问题有关。

Above example i have provided for playing online videos from url but this question have problem related to video path problem.

刚改变了这条路径:

String videopath = "android.resource://"+getPackageName()+"+R.raw.movie"; Uri uri =Uri.parse(videopath);

为此,

Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.yourvideo);

感谢希望这会对你有帮助。

Thanks hope this will help you.

更多推荐

无法播放此视频错误

本文发布于:2023-11-27 18:48:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639180.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法播放   错误   视频

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!