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

Created the AnkiMediaQueue for JavaScript media support #604

Closed

Conversation

evandrocoan
Copy link
Contributor

@evandrocoan evandrocoan commented May 3, 2020

JavaScript media support should be a great addition to Anki in cases the standard player is somehow not working:

  1. https://anki.tenderapp.com/discussions/ankidesktop/41235-how-to-add-video-saved-in-my-mac-to-my-deck-or-cards
  2. https://anki.tenderapp.com/discussions/ankidesktop/41438-error-on-database
  3. https://anki.tenderapp.com/discussions/ankidesktop/41106-card-audio-playback-changes-bug-in-212x
  4. https://anki.tenderapp.com/discussions/ankidesktop/41344-o-audio-dos-meus-flash-cards-no-esta-funcionando

The pull-request ankitects/anki-manual#128 Created the ankimedia documentation section on src/media.md, adds documentation for this feature. The ankimedia object implementation and automated integration tests are split in a second repository, https://github.com/evandrocoan/AnkiMediaQueue, and shipped with Anki only the build typescript file.

@evandrocoan evandrocoan force-pushed the javascript_playback_support branch 5 times, most recently from 85f06b5 to a778a19 Compare May 3, 2020 07:07
@dae
Copy link
Member

dae commented May 4, 2020

Thanks Evandro. I'm currently focused on backend changes, but I'll leave this around like #540 to return to at a future date when things are not so busy.

@evandrocoan evandrocoan force-pushed the javascript_playback_support branch 6 times, most recently from 0011e21 to a9d5a1d Compare May 9, 2020 00:35
@evandrocoan evandrocoan force-pushed the javascript_playback_support branch 11 times, most recently from 3786a70 to 7599c75 Compare May 20, 2020 22:19
@evandrocoan evandrocoan force-pushed the javascript_playback_support branch 7 times, most recently from 8df974a to f42a07b Compare June 3, 2020 00:25
CONFLICT (content): Merge conflict in qt/ts/tsconfig.json
CONFLICT (modify/delete): qt/ts/package.json deleted in HEAD and modified
CONFLICT (modify/delete): qt/ts/package-lock.json deleted in HEAD and modified
CONFLICT (content): Merge conflict in qt/Makefile
This helps in cases when a [sound:file.mp3] is used without its
|fileonly option.
autoscroll. When Anki finds a `#answer` on the answer, it
automatically scrolls to answer. But disabling this was
breaking this ankimedia.ts logic. Then, allow to create other
elements as answer-audio to keep this plugin functionality.
this file should almost never change and its build and tests
is quite time consuming.

The files were moved to https://github.com/evandrocoan/AnkiMediaQueue
playing between different notes.

# Conflicts:
#	qt/aqt/reviewer.py
for Anki filling .src audio replacing ' ' with %20
which breaks everything as .add() still being called with spaces ' '
instead of %20. Then, try both variations in case some day Anki fixes
its interface and stop replacing ' ' with %20.

# Conflicts:
#	qt/aqt/data/web/js/vendor/ankimedia.js
@evandrocoan evandrocoan changed the title WIP: Created the AnkiMediaQueue for JavaScript media support Created the AnkiMediaQueue for JavaScript media support Jan 14, 2023
@evandrocoan
Copy link
Contributor Author

evandrocoan commented Jan 14, 2023

Hello @dae , I would say this pull-request should be good to be merged. I updated the first post. The changes to the Anki code are minimal (hooks to control the page media). The implementation itself is all contained inside the ankimedia object. It would be nice if the pull-request is not squashed, as reviewing locally with git (as with the smargit tool) is way better than opening the original pull-request on GitHub).

As the whole thing is my implementation, I want you to know that I am not burdening you with maintaining it. I explained on the documentation page that this feature comes without support from the Anki team. Still, I am open to supporting this with my issue tracker on the second repository and applying pull requests to fix the code on Anki if required.

I checked, and the HTML media added still works on the Anki web version of anki (as it is just HTML). What does not work is the automatic playing of the ankimedia object control (as it is not included in the Anki Web version). Integrating it with the Anki web, and Android should be simple enough. Include the ankimedia.js and call its few hooks before showing a question as done with the anki desktop integration.

I am open to helping/maintaining any problems you may have with the use of ankimedia elsewhere on inside anki desktop. I think it should be pretty stable as:

  1. I developed it with extensive automated testing, so all interfaces are also tested outside Anki in a vanilla chromium browser.
  2. I Have been using it for the last years since I started this pull-request and have fixed many problems I encountered.

If someone misses some new integration with Anki, you can point out can look into how to integrate it. Its Javascript playback would be a pretty addition to Anki and would work as an alternative to mpv or mplayer.

@dae
Copy link
Member

dae commented Jan 16, 2023

Hi Evandro,

I haven't forgotten about this, and such an API is still something that might be nice to support in the future. It's something I'd like to give a proper amount of thought and attention to before deciding on though, as despite any warnings/disclaimers you give users, once the functionality is made available, people will depend on it, and it will be difficult to make changes if we later decide that the implementation is not optimal. I'd hoped that almost 3 years later I wouldn't be feeling so swamped by the todo list, but sadly there are still too many things to do and not enough time :-(

In the mean time, is this something that could perhaps be done in an add-on? I'd be open to a PR that adds any required hooks so you don't need to monkeypatch the eval calls in.

@evandrocoan
Copy link
Contributor Author

Hi. Thanks for looking into it. Yes, it can be added in an addon, as the integration require some hooks. As an Addon, it should give people more chances to use it before adding it to the main Anki code.

Should I close this pull request after adding the addon hooks?

@dae
Copy link
Member

dae commented Jan 16, 2023

I don't mind either way - if/when I have time to explore this more deeply in the future, I can reach out whether or not the PR is open.

@dae
Copy link
Member

dae commented Mar 20, 2024

Closing this now - while JS-based audio is still something I'd like to tackle at one point, it will likely require a new implementation.

@dae dae closed this Mar 20, 2024
@evandrocoan evandrocoan deleted the javascript_playback_support branch March 24, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants