bilibili / ijkplayer

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
GNU General Public License v2.0
32.52k stars 8.13k forks source link

ijk如何播放assets和raw内的mp4视频 #2043

Open LuckLe opened 8 years ago

mcxiaoke commented 8 years ago

try this:

AssetManager am = getAssets();
AssetFileDescriptor afd = am.openFd("your_file_name");
FileDescriptor fd = afd.getFileDescriptor();
mediaPlayer.setDataSource(fd);
LuckLe commented 8 years ago

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

mcxiaoke commented 8 years ago

@LuckLe https://github.com/Bilibili/ijkplayer/blob/master/android/ijkplayer/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/IMediaPlayer.java#L71

LuckLe commented 8 years ago

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

tian9246 commented 7 years ago

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

bbcallen commented 7 years ago

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

tian9246 commented 7 years ago

@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 ?

mcxiaoke commented 7 years ago

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

tian9246 commented 7 years ago

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

bingzhao0719 commented 7 years ago

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

jamin918 commented 7 years ago

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

Froyo91 commented 5 years ago

try this:

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

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

Froyo91 commented 5 years ago

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

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

598588152 commented 5 years ago

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

oncealong commented 5 years ago

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