如何将 VLC 媒体播放器嵌入我的 Android 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22073970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:30:03  来源:igfitidea点击:

How to embed VLC media player to my Android App

androidvideolibvlc

提问by fercis

Is there a way to embed VLC media player to Android Application? I have several issues:

有没有办法将 VLC 媒体播放器嵌入到 Android 应用程序中?我有几个问题:

1) I have a video streaming Camera (from RTSP) and I cannot play its stream on my regular videoview panel (Sorry this video cannot be played error). However, I installed the VLC application for Android (beta version) and I was able to play it. 2) My main objective is to port a desktop java application which uses VLC plugin to Android. I want to accomplish this task with minimum effort (I have some time issues).

1) 我有一个视频流摄像头(来自 RTSP),我无法在我的常规视频视图面板上播放它的流(对不起,这个视频无法播放错误)。但是,我安装了适用于 Android(测试版)的 VLC 应用程序,并且能够播放它。2)我的主要目标是将使用 VLC 插件的桌面 Java 应用程序移植到 Android。我想以最少的努力完成这项任务(我有一些时间问题)。

Another alternative, is there a way to embed codecs used by VLC to my application? Because with my videoview, the result varies according to the format of the video. I can play some other videos streamed through RTSP on my videoview.

另一种选择,有没有办法将 VLC 使用的编解码器嵌入到我的应用程序中?因为对于我的视频视图,结果根据视频的格式而有所不同。我可以在我的视频视图上播放通过 RTSP 流式传输的其他一些视频。

I search through internet and found a "libvlc" but also some notes about that libvlc for android is not complete (but those notes belong to a past time, even in stackoverflow).

我通过互联网搜索并找到了一个“libvlc”,但也发现了一些关于 android 的 libvlc 的注释不完整(但这些注释属于过去的时间,即使在 stackoverflow 中)。

回答by Maruku

Yes, if you already have the vlc-sdk.7z (libVLC for android), hereis the sample project to embedded VLC into your android apps.

是的,如果您已经拥有 vlc-sdk.7z(适用于 android 的 libVLC),这里是将 VLC 嵌入您的 android 应用程序的示例项目。

If you do not have libVLC, hereare the steps to build one. (After "sh compile.sh" finished, "make vlc-sdk.7z" to create the vlc-sdk.7z and unzip to the demo project.

如果你没有libVLC,这里是构建一个步骤。(“sh compile.sh”完成后,“make vlc-sdk.7z”创建vlc-sdk.7z并解压到demo工程。

I put the vlc-sdk.7z(only armeabi-v7a is included) herefor testing.

我将 vlc-sdk.7z(仅包含 armeabi-v7a)放在这里进行测试。

回答by Caleb_Allen

Maruku has given a great answer.

丸子给出了很好的答案。

In addition, if you don't want to compile libVLC on your own machine, mrmaffen has kindly thrown it up onto maven central. So in your .gradle file include

此外,如果您不想在自己的机器上编译 libVLC,mrmaffen 已将其扔到 maven central 上。所以在你的 .gradle 文件中包括

compile "de.mrmaffen:vlc-android-sdk:1.9.8"

Keep in mind that LibVLC may not be 100% updated because you aren't compiling the source yourself.

请记住,LibVLC 可能不会 100% 更新,因为您不是自己编译源代码。

More info can be found here on GitHub

可以在GitHub 上找到更多信息

回答by Hai Phan

2019 sees introduction of a VLCVideoLayout component that greatly simplifies the code required to embed VLC into android.

2019 年引入了 VLCVideoLayout 组件,该组件极大地简化了将 VLC 嵌入到 android 中所需的代码。

https://code.videolan.org/videolan/libvlc-android-samples

https://code.videolan.org/videolan/libvlc-android-samples

The libVLC is provided by the official VideoLAN project hosted on BinTray. See the build.gradle files for the link to the Maven repo and the package name/version.

libVLC 由托管在 BinTray 上的官方 VideoLAN 项目提供。请参阅 build.gradle 文件以获取指向 Maven 存储库和包名称/版本的链接。

https://code.videolan.org/videolan/libvlc-android-samples/blob/master/build.gradle#L18https://code.videolan.org/videolan/libvlc-android-samples/blob/master/java_sample/build.gradle#L34

https://code.videolan.org/videolan/libvlc-android-samples/blob/master/build.gradle#L18 https://code.videolan.org/videolan/libvlc-android-samples/blob/master/java_sample /build.gradle#L34

回答by Ravi Kumar

The libVLC is provided by the official VideoLAN project hosted on BinTray. You can directly use the library as a dependency without having to compile it.

libVLC 由托管在 BinTray 上的官方 VideoLAN 项目提供。您可以直接将库用作依赖项,而无需编译它。

add maven url "https://dl.bintray.com/videolan/Android" to your project-level Gradle file as shown below:

将 maven url " https://dl.bintray.com/videolan/Android"添加到您的项目级 Gradle 文件中,如下所示:

allprojects {
 repositories {
      google()
      jcenter()
      maven {
        url "https://maven.google.com";
        }
      maven { url "https://dl.bintray.com/videolan/Android" }
  }
}

and in your app-level Gradle file, add the libVLC dependency

并在您的应用程序级 Gradle 文件中,添加 libVLC 依赖项

implementation 'org.videolan.android:libvlc-all:<latest-version-here>'

Get the latest libVLC version from the below official VLC GitHub repository.

从以下官方 VLC GitHub 存储库获取最新的 libVLC 版本。

find the string "libvlcVersion" to get the latest version.

找到字符串“libvlcVersion”以获取最新版本。

https://github.com/videolan/vlc-android/blob/master/build.gradle#L33

https://github.com/videolan/vlc-android/blob/master/build.gradle#L33

回答by Dmitriy Pavlukhin

Some other answers link to outdated versions, however actual for 2019.03 is LibVlc for all platforms 3.1.8. This is .aar version, you may add it to your project with these instructionsand use.

其他一些答案链接到过时的版本,但实际 2019.03 是LibVlc for all platform 3.1.8。这是 .aar 版本,您可以使用这些说明将其添加到您的项目中并使用。

However if all-version is too large(over 70MB), hereis armv7 version, and hereif x86.

但是,如果所有版本太大(超过 70MB),这里是 armv7 版本,这里是 x86。

回答by CHirag RAmi

Step 1 : install Linux

第一步:安装Linux

Step 2 : install ndk and sdk

第 2 步:安装 ndk 和 sdk

Step 3 : change your directory path upto compile.sh

第 3 步:将您的目录路径更改为 compile.sh

then compile.sh run through your Linux terminal and generate apk

然后 compile.sh 通过你的 Linux 终端运行并生成 apk

Compile - Run - Enjoy

编译-运行-享受