Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Play video from asset or raw folder #355

Closed
ntgx opened this issue Sep 5, 2016 · 6 comments
Closed

Play video from asset or raw folder #355

ntgx opened this issue Sep 5, 2016 · 6 comments

Comments

@ntgx
Copy link

ntgx commented Sep 5, 2016

Tried to play a video in my raw folder like this

String path = "android.resource://"+  getPackageName() + '/' + R.raw.test;
videoView.setUp(path, JCVideoPlayerStandard.SCREEN_LAYOUT_DETAIL, "Test Video");

but it doesn't work and shows this error in the logcat "Protocol not found"

I tried to follow the instructions linked on the readme bilibili/ijkplayer#1013 but it's from a dependency project and the discussion is not very clear on how it applies to this library. Either way i tried some things they mentioned but that didn't work either

Uri uri = Uri.parse(path);
        if(uri.getScheme().equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
            AssetFileDescriptor fileDescriptor = null;
            try {
                fileDescriptor = getContentResolver().openAssetFileDescriptor(uri, "r");
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            IMediaDataSource dataSource = new RawDataSourceProvider(fileDescriptor);
            if(fileDescriptor != null)
                JCMediaManager.instance().mediaPlayer.setDataSource(dataSource);
            else{

                return ;
            }
        }

All my searches on how to do this have ended up with closed issues with no clear explanation. Maybe how to do this can be added in the sample app?

Also found this comment on the dependency project "Playback of asset file is not a completed feature, for now." bilibili/ijkplayer#1303 so if it's not supported yet maybe it should be removed from the readme

@YuJunKui1995
Copy link

Play video in assets you should copy to local path first.Try by myself like thistextureview will stop on first frame and error on logcat
没懂你什么意思 参见 主页这个解释

@lipangit
Copy link
Owner

lipangit commented Sep 6, 2016

I think somthing wrong with ijkplayer, ijkplayer should make function complete, should not let other people config before use.

@ntgx
Copy link
Author

ntgx commented Sep 6, 2016

@YuJunKui2016 you're just repeating what's stated in the readme it doesn't work
@lipangit you're right...the admin himself said this on one of the issues "Playback of asset file is not a completed feature, for now." bilibili/ijkplayer#1303
Perhaps there's something we can do to allow it to play local files? I'll look into it...

@lipangit
Copy link
Owner

5.0+support assert video

@LSDsl
Copy link

LSDsl commented Dec 28, 2017

@lipangit How? I tried use url "file:///android_asset/test.mp4", but this not work.

@lipangit
Copy link
Owner

Play video in asset folder, see demo ActivityApiCustomMediaPlayer.java, it will show you how to custom video player

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants