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

AnkiDroid API how can i add cards with sound? #5139

Closed
snailp4el opened this issue Nov 29, 2018 · 6 comments
Closed

AnkiDroid API how can i add cards with sound? #5139

snailp4el opened this issue Nov 29, 2018 · 6 comments
Labels

Comments

@snailp4el
Copy link

Reproduction Steps

I am creating an android application and i need add some cards with sound. I use AnkiDroid API to do this. In example i did not find out how to do it.

Expected Result

Please can you give some example.

Actual Result
Debug info

Refer to the support page if you are unsure where to get the "debug info".

Research

Enter an [ x ] character to confirm the points below:

[ ] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid

[ ] I have checked the manual and the FAQ and could not find a solution to my issue

[ ] I have searched for similar existing issues here and on the user forum

@timrae
Copy link
Member

timrae commented Nov 29, 2018

You'd have to make a proposal to extend the API to accept to media, reach an agreement with us on the details, and then implement it and submit a PR.

@snailp4el
Copy link
Author

You'd have to make a proposal to extend the API to accept to media, reach an agreement with us on the details, and then implement it and submit a PR.

how can i do it?

@mikehardy
Copy link
Member

Think of the API you'd want that the CardContentProvider doesn't have (or maybe we need a MediaProvider to manipulate media then you just reference it using standard CardContentProvider API?). Submit that here for review and we hopefully agree it sounds good. Start implementing it on your github fork and we move from there?

@snailp4el
Copy link
Author

Think of the API you'd want that the CardContentProvider doesn't have (or maybe we need a MediaProvider to manipulate media then you just reference it using standard CardContentProvider API?). Submit that here for review and we hopefully agree it sounds good. Start implementing it on your github fork and we move from there?

I afraid to say something stupid). I understand that i can just send audio file to External storage and create link for this file. But i don't know how to send this file proper way.

@mikehardy
Copy link
Member

Hey - no worries on asking silly questions or proposing things that don't work. I'm currently the king of that here, but I can handle a partner ;-)

As far as I know there is simply no "proper way" in existence right now, to store media in the Anki collection via published APIs.

If you tried to use external storage privileges to just drop the file in the directory that would work mostly, but it is possible for people to change the AnkiDroid collection storage directory. I bet it is rare, but it is possible. So that will fail sometimes.

I am also not sure whether AnkiDroid would correctly detect the change (new file in filesystem) or not - that would need testing.

If you wanted to do the slightly improper but fast way of storing the file by filesystem commands then at minimum you would want an API to get the directory, and you'd want to test that AnkiDroid synced the new media file to Ankiweb correctly.

I think the "proper" way to do it would be to have a "storeMedia" API in the CardContentProvider (or similar) where you sent the data to the AnkiDroid API via an Android ContentProvider and AnkiDroid added it programmatically.

I hope this helps?

@snailp4el
Copy link
Author

Thank you for a hint.
I solved it this way.
May by it is not good solution but it works fine.

public ArrayList getExternalFolderPath(String folderName){

    ArrayList<String> arrayList = new ArrayList<>();

    //get all storages in phone
    File externalStorages[] = getExternalFilesDirs(null);

    for (File es: externalStorages){
        String exF = es.toString();

        //cut out what don't need
        exF = exF.split("/Android/data")[0];

        File file = new File(exF);
        File[] files = file.listFiles();
        for (File f: files){
            Log.i(TAG, "getAnkiExternalFolder()" + f.toString());
            //add in array the path
            if(f.toString().contains(folderName)){
                arrayList.add(f.toString());
            }
        }
    }
    return arrayList;
}

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

No branches or pull requests

4 participants