是什么VideoView的setVideoPath和setVideoURI之间的区别 [英] What is the difference between VideoView's setVideoPath and setVideoURI

查看:4078
本文介绍了是什么VideoView的setVideoPath和setVideoURI之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VideoView 有指定的视频播放的两种不同方式:

VideoView has two different ways of specifying which video to play:

  • setVideoPath(String path)
  • setVideoUri(Uri uri)

两者有什么之间的差异时,应一方或另一方使用吗?

What is the difference between the two and when should one or the other be used?

推荐答案

看源$ C ​​$ C,没有什么是你传递的类型不同分开

Look at the source code, nothing is different apart from the type you pass.

/**
 * Sets video path.
 *
 * @param path the path of the video.
 */
public void setVideoPath(String path) {
    setVideoURI(Uri.parse(path));
}
/**
 * Sets video URI.
 *
 * @param uri the URI of the video.
 */
public void setVideoURI(Uri uri) {
    setVideoURI(uri, null);
}

时使用 setVideoPath 它创建乌里为你,所以使用任何你想要的 - 这取决于你有一个乌里字符串路径。

Is you use setVideoPath it creates the Uri for you, so use whichever you want - depending on if you have a Uri or String path.

<一个href=\"https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/widget/VideoView.java\" rel=\"nofollow\">https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/widget/VideoView.java

这篇关于是什么VideoView的setVideoPath和setVideoURI之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆