Ijkplayer: ijk如何播放assets和raw内的mp4视频

Created on 27 Sep 2016  ·  15Comments  ·  Source: bilibili/ijkplayer

need-more-information

All 15 comments

try this:

AssetManager am = getAssets();
AssetFileDescriptor afd = am.openFd("your_file_name");
FileDescriptor fd = afd.getFileDescriptor();
mediaPlayer.setDataSource(fd);

@mcxiaoke ijk 的API没有你发的这个,ijk里面是这个api public abstract void setDataSource(String path)

@mcxiaoke 我的ijk好久没更新了,(⊙o⊙)…

@mcxiaoke does ijkplayer support this function by now?
---from @bbcallen said setDataSourceFd was not a completed feature on May 11 ...

ffmpeg doesn't support seek() via setDataSourceFd().
But it's not difficult to modify ffmpeg to support it in libavformat/file.c

@bbcallen how can do that? pass a pipe fd like "pipe:23" into ffmpeg and modify file.c is ok? use asset_manager.h and asset_manager_jni.h ?

@tian9246 有更简单的方法你为什么不用呢:复制assets/raw文件到应用目录或者SD卡目录,然后再播放不行吗,只需复制一次

@mcxiaoke 场景需要 。。PD不能接受 解压漫长的过程 555.......

这个问题解决了吗?我也遇到了这个问题

这个问题解决了吗?我也遇到了这个问题,知道的大神麻烦告诉一下

try this:

AssetManager am = getAssets();
AssetFileDescriptor afd = am.openFd("your_file_name");
FileDescriptor fd = afd.getFileDescriptor();
mediaPlayer.setDataSource(fd);

我依旧是不可以。。同样的视频放在网上然后用ijkplayer播放就可以。。

@tian9246 有更简单的方法你为什么不用呢:复制assets/raw文件到应用目录或者SD卡目录,然后再播放不行吗,只需复制一次

没有找到直接播放的方法。。用了和这个朋友一样的方法播放了本地的视频。

String videoUrl = "android.resource://" + getPackageName() + "/" + R.raw.XX;
nicePlayer.setUp(videoUrl, null);
这种方式 用 AndroidMediaPlayer 可以播放

ijkpalyer可以播放asset、raw下的音视频,见下面文章
https://juejin.im/post/5bec0958e51d454c7d0f9a32

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZINK-FU picture ZINK-FU  ·  3Comments

yuraoff picture yuraoff  ·  3Comments

xuluming picture xuluming  ·  4Comments

aslgd picture aslgd  ·  4Comments

xSharkM picture xSharkM  ·  3Comments