Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么加载本地视频资源 #32

Closed
RainSnowSnow opened this issue Aug 26, 2019 · 31 comments
Closed

怎么加载本地视频资源 #32

RainSnowSnow opened this issue Aug 26, 2019 · 31 comments
Assignees
Labels
wait confirm Sulution provided, wait to comfirm

Comments

@RainSnowSnow
Copy link

assets/videos/video.mp4: No such file or directory

@befovy
Copy link
Owner

befovy commented Aug 26, 2019

@RainSnowSnow
iOS or android ?
which version of ijkplayer you used? or maybe you used fijkplayer?

ijkplayer dosen't support assets on Android platform, but fijkplayer support.

@befovy befovy self-assigned this Aug 26, 2019
@befovy
Copy link
Owner

befovy commented Aug 26, 2019

Although asset is not supported in ijkplayer by default, you can add it by add your DataSource like this. @RainSnowSnow

https://github.com/befovy/fijkplayer/blob/master/android/src/main/java/com/befovy/fijkplayer/RawMediaDataSource.java

mIjkMediaPlayer.setDataSource(new RawMediaDataSource(is));

@RainSnowSnow
Copy link
Author

@befovy
我用的是fijkplayer,
错误提示:D/tv.danmaku.ijk.media.player.IjkMediaPlayer(18150): Couldn't open file on client side, trying server side
引入的方式是:
final FijkPlayer player = FijkPlayer();
final url="assets/videos/video.mp4";
@OverRide
void initState(){
super.initState();

player.setDataSource(url);

@befovy
Copy link
Owner

befovy commented Aug 27, 2019

fijkplayer 的 demo 有播放 asset 文件的例子

在 pubspec.yml 中加入

  assets:
    - assets/butterfly.mp4

使用方式如下

final url="asset:///assets/butterfly.mp4";
player.setDataSource(url);

scheme 是 “asset://”, 在后面path 中还有一个 “/” 。共3个“/”
只支持在 pubspec.yml 中引入的 asset 文件,其他还没有测试。

@befovy befovy transferred this issue from befovy/ijkplayer Aug 27, 2019
@RainSnowSnow
Copy link
Author

@befovy E/IJKMEDIA(22698): asset:///assets/video.mp4: Protocol not found 提示这个错误是啥意思

@befovy
Copy link
Owner

befovy commented Aug 27, 2019

@RainSnowSnow 是用的 0.1.0 版本吗?

@RainSnowSnow
Copy link
Author

@befovy 不是,用的 ^0.0.9

@befovy
Copy link
Owner

befovy commented Aug 27, 2019

这个在 0.1.0 才支持

@RainSnowSnow
Copy link
Author

@befovy
image
0.1.0的flutter run 报错

@befovy
Copy link
Owner

befovy commented Aug 27, 2019

implementation 'com.android.support:support-annotations:28.0.0'
有一个 dependencies 没安装。

gradle sync 跑一下试试。

另外提示怎么都是乱码?

@RainSnowSnow
Copy link
Author

@befovy
image
乱码的我也不大清楚,会不会是因为flutter sdk的版本低了

@befovy
Copy link
Owner

befovy commented Aug 27, 2019

不好意思 , gradle sync 不是终端命令。
在 android studio 上有个图标,作用是 gradle sync.
windows 命令行的话,应该是运行项目android 文件夹中的 gradlew.bat

@RainSnowSnow
Copy link
Author

@befovy
image是哪个啊

@befovy
Copy link
Owner

befovy commented Aug 27, 2019

我刚才试了一下,需要引入 androidx

gradle.properties文件里添加配置:

android.useAndroidX=true
android.enableJetifier=true

在android studio 编辑器中打开一个 android 目录下的文件,就会出现
image

@RainSnowSnow
Copy link
Author

@befovy
image
还是相同的错误

@befovy
Copy link
Owner

befovy commented Aug 27, 2019

是修改 gradle.properties ,不是 gradle-wrapper.properties

@RainSnowSnow
Copy link
Author

RainSnowSnow commented Aug 27, 2019

@befovy
image
视频出来了,但是播放过程中就报错

@befovy
Copy link
Owner

befovy commented Aug 27, 2019

好的,这个是 UI 上的问题。能提供一下视频吗? 我修改一下。

@RainSnowSnow
Copy link
Author

RainSnowSnow commented Aug 27, 2019

@RainSnowSnow
Copy link
Author

@befovy

@RainSnowSnow
Copy link
Author

RainSnowSnow commented Aug 27, 2019 via email

@befovy
Copy link
Owner

befovy commented Aug 27, 2019

那个压缩包用不了,能提供出现问题的视频吗 @RainSnowSnow

@RainSnowSnow
Copy link
Author

@befovy
image

请查收下邮箱,因为文件有上传格式限制,我发邮箱了

@befovy
Copy link
Owner

befovy commented Aug 27, 2019

发到我邮箱 befovy@gmail.com 吧,谢谢

@RainSnowSnow
Copy link
Author

@请注意查收

@befovy befovy closed this as completed in 36bec16 Aug 27, 2019
@befovy
Copy link
Owner

befovy commented Aug 27, 2019

@RainSnowSnow please upgrade to version 0.1.1
slide value out of range is fixed.

@befovy befovy reopened this Aug 27, 2019
@befovy befovy added the wait confirm Sulution provided, wait to comfirm label Aug 28, 2019
@RainSnowSnow
Copy link
Author

@befovy 在ios上展示的效果和安卓上一样么,因为我这边开发过程中暂时无法测试ios

@befovy
Copy link
Owner

befovy commented Aug 29, 2019

@RainSnowSnow 我测试过比较基础的内容,效果是一样的。但我无法帮你做更多的测试。
iOS可以使用模拟器测试,但是实际视频会显示为黑屏

@RainSnowSnow
Copy link
Author

@befovy
image,
当设置为非自动播放状态时,视频会一直处于加载状态,这属于正常的么

@befovy
Copy link
Owner

befovy commented Aug 29, 2019

建议使用 自定义 UI ,重写一个播放器控制面板
https://fijkplayer.befovy.com/docs/zh/custom-ui.html
默认的控制面板确实是这样的

@befovy
Copy link
Owner

befovy commented Aug 29, 2019

@RainSnowSnow 如果还有其他问题,请另开新的 issue, 这个我就先关了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wait confirm Sulution provided, wait to comfirm
Projects
None yet
Development

No branches or pull requests

2 participants