Code Monkey home page Code Monkey logo

240201-asbplayer's Introduction

asbplayer

GitHub Workflow Status (with event) Github All Releases GitHub Sponsors Static Badge GitHub License

asbplayer is a browser-based media player and Chrome extension developed for language learners who learn their target language through subtitled media. With asbplayer, you can:

  • Easily create high-quality, multimedia flashcards out of subtitled videos.
  • Load text-selectable subtitles onto most video sources, including streaming sources.
  • Extract subtitles from popular streaming services like Netflix and YouTube.
  • Seek through subtitles using a navigable subtitle list.
  • Optimize language-learning efficiency using subtitled videos with playback modes like:
    • Condensed playback: Only play subtitled sections of a video.
    • Fast-forward playback: Fast-forward through unsubtitled sections of video.
    • Auto-pause: Automatically pause at the beginning or end of every subtitle.
  • Use customizable keyboard shortcuts to access most of asbplayer's features.

Thanks

Thank you to all of my sponsors:

... and to those who have donated privately.

Thank you to all those who have contributed to asbplayer:

Thank you to all those who have translated asbplayer:

  • Mana Tsutsumi (Japanese, initial translation)
  • Kai Böse (German)
  • Triline (Polish)
  • NeverWinterSwor (Simplified Chinese)
  • Yagxter (Brazilian Portuguese)
  • Leo Gonzalez (Spanish)

If you are a non-English native, and would like to help translate asbplayer, please contact me on Discord.

Getting Started

First, see if you can get started with one of the community guides.

Otherwise, the following steps will work for any language:

  1. Install a dictionary for your target language that allows you to do instant lookups. Popular ones are Yomitan for Japanese and VocabSieve for European languages.

  2. Install Anki, and create a deck and note type.

  3. Install the AnkiConnect plugin for Anki.

  4. Configure asbplayer to create cards via AnkiConnect using your deck and note type.

  5. Enhance a video using asbplayer and subtitle files.

    • For streaming video: After installing the Chrome extension, drag-and-drop a subtitle file into the streaming video you want to mine.
    • For local files: Drag-and-drop media/subtitle files into the asbplayer website.

    You may have to adjust the subtitle offset to get the subtitles in sync.

  6. When a subtitle appears that you want to mine, use Ctrl + Shift + X to open the flashcard creator.

  7. Fill in the definition and word fields and then export the card. To fill in the definition field you may use the dictionary you installed in step 1.

Community guides

Demos

Detailed usage

Enhancing streaming video with asbplayer features

Install the Chrome extension. There are a number of ways to enhance streaming video with asbplayer:

  1. Drag-and-drop a subtitle file into the video element you want to enhance.
  2. Load a subtitle file into the asbplayer website and click on the camera in the bottom right to pick a video element to enhance. This is the recommended way to load BluRay subtitle files onto streaming video.
  3. Use Ctrl + Shift + F to select a video element to enhance. From the dialog that appears you can choose whether to load an auto-detected subtitle track or an empty one.
  4. Open the side panel (` button or Open Side Panel from the extension popup). When a video element is on screen, click on the Load Subtitles button to open the same subtitle track selector in (3).

asbplayer features will then be accessible for that video.

Enhancing local video files with asbplayer features

Drag-and-drop media and subtitle files into the asbplayer website to load them. asbplayer features will then be accessible for those files. Not all media files may be compatible - see the Browser Compatibility section.

Keyboard shortcuts

Keyboard shortcuts are customizable from the asbplayer website settings. Once asbplayer has been bound to a video, you can use the keyboard shortcuts to access most of asbplayer's features.

Creating Anki flashcards

Make sure Anki and AnkiConnect are installed. Integration with AnkiConnect can be configured in the settings as in this video.

When a subtitle that you want to mine appears, use Ctrl + Shift + X to open the flashcard creator.

See the keyboard shortcuts for other ways to interact with and create cards.

Adjusting Anki flashcards

All text fields can be edited from the flashcard creator prior to flashcard creation.

Adjust the selected time interval for the card using the slider at the bottom of the export dialog. The newly selected time interval can be applied to the card using the buttons available in the sentence and audio sections of the card. See this video for a demo.

Adjusting subtitle offset

Use Ctrl + Left/Right to adjust subtitle offset so that the previous/next subtitle appears at the current timestamp. Then use Ctrl + Shift + Left/Right for finer adjustment by 100ms increments.

If you are using the asblayer website, you can also use the Subtitle Offset text field available in the controls UI.

Subtitle track detection for streaming video

Use Ctrl + Shift + F to see auto-detected subtitle tracks for streaming video. Below are the sites where automatic subtitle detection is supported:

  • Netflix
  • Youtube
  • Disney Plus (known issue: subtitles sometimes off by ~5 seconds)
  • Hulu
  • TVer
  • Bandai Channel
  • Amazon Prime (known issue: subtitles sometimes off by ~30 seconds)

Ctrl + Shift + F also allows you to load an empty subtitle track so that you can extract audio and screenshots from streaming video without loading subtitles.

Extension side panel UI

Most of the extension features detailed above can be accessed through the extension's side panel UI. The side panel can be opened with the ` button or Open Side Panel from the extension popup.

Audio track selection for mkv files

An audio track selector will appear for mkv files if experimental web platform features are enabled from chrome://flags. Note that enabling this flag may cause issues with other features of asbplayer, such as card creation through the Chrome extension.

One-click mining flow

The asbplayer website can be setup to support one-click mining workflows by integrating with other tools via its WebSocket interface and a locally-running proxy that intercepts AnkiConnect traffic. Below are steps to set up such a workflow using Yomitan:

  1. Install Go.
  2. Clone this repository and start the AnkiConnect proxy server:
    cd scripts/anki-connect-proxy
    go run main.go
    
  3. Enable asbplayer's WebSocket client from the website settings.
  4. Point Yomitan at the proxy by configuring http://127.0.0.1:8766 for the AnkiConnect URL.
  5. Configure Yomitan to use the same note type you have configured for asbplayer.
  6. Using Yomitan's + button on asbplayer subtitles will now trigger the flashcard creator with word and definition fields pre-populated by Yomitan.

See the proxy's example configuration file for how to further configure it.

WebSocket interface

The asbplayer website can be controlled remotely through a WebSocket connection, which enables one-click mining flows with the right setup. Currently asbplayer responds to one type of payload:

{
    "command": "mine-subtitle",
    // Message ID to correlate with asbplayer's response
    "messageId": "10281760-d787-4356-8572-f698d8ff3884",
    "body": {
        // 0 = "None", 1 = "Show anki dialog", 2 = "Update last card", 3 = "Export card"
        "postMineAction": 1,
        // Key-value pairs corresponding to an Anki note type
        "fields": {
            "key1": "value1",
            "key2": "value2"
        }
    }
}

Response:

{
    "command": "response",
    // Same message ID received in request
    "messageId": "10281760-d787-4356-8572-f698d8ff3884",
    "body": {
        // Whether the command was successfully published to the website
        "published": true
    }
}

Common issues

asbplayer can't connect to Anki. It shows an error message e.g. 'Failed to fetch.'

  • If you're using Brave, make sure asbplayer isn't being blocked by Shield.
  • Make sure that asbplayer is allowed by AnkiConnect, as in this video.
  • Make sure that the origin you add to the AnkiConnect settings is exactly https://killergerah.github.io with no slash at the end (and not https://killergerah.github.io/asbplayer).
  • Check that your browser or an ad blocker isn't blocking the request. A good place to start is by opening your browser's developer console and looking for errors.
  • As of this writing enabling experimental web platform features is known to cause this issue. Try disabling this flag from chrome://flags.
  • On later versions of macOS, AnkiConnect will not respond when Anki is backgrounded. See "Notes for MacOS Users" on the AnkiConnect developer's website.

When using the 'update last card' feature, the card does not update in Anki.

  • Make sure Anki's card browser is closed when using 'update last card.' There is a known issue with AnkiConnect where cards will not appear to update when the card browser is open.

When loading a local file asbplayer either shows a black screen, or doesn't play audio.

My popup dictionary extension (e.g. Yomitan) doesn't work on the side panel

  • Chrome does not allow other extension scripts to be injected into extension UI, so there is no fix for this. If you want to scan text with other extensions then you will need to do it from the subtitles displayed inside the video element, or from the subtitle list on the asbplayer website.

asbplayer isn't detecting streaming video.

  • Try refreshing both the asbplayer tab and the video in the other tab.
  • Make sure that in the extension details, the extension has access to all sites.

Keyboard shortcuts aren't working.

  • Check the the keyboard shortcut settings.
  • If you are using the extension:
    • Check chrome://extensions/shortcuts.
    • Try refreshing the page and loading subtitles again.
    • Try uninstalling and reinstalling the extension, and restarting Chrome.
    • Make sure the extension isn't installed twice.

asbplayer isn't including audio/screenshot in flashcards.

  • If you're mining streaming video via the Chrome extension, make sure that the streaming video tab is selected and in the foreground when you use a mining keyboard shortcut

asbplayer isn't properly cropping screenshots from streaming video.

  • Make sure the browser zoom setting is at 100%.
  • You can disable cropping altogether using the extension settings menu.

Browser compatibility

The asbplayer application and extension have only been tested on the latest version Chrome and likely work on other Chromium-based browsers.

Local video file playback is supported only for codecs supported by the browser. The latest versions of Chrome can decode H.265 video as long as hardware acceleration is enabled. The animebook readme has a detailed explanation of this and links to browsers that have good compatibility.

Contributing

Pull requests are welcome! However, to reduce back-and-forth during review ideally consult with me on the corresponding issue or on Discord before attempting changes to UI/UX. When making changes, format code according to the Prettier config and attempt to match the style of surrounding code.

Building and running

# Install yarn
npm install --global yarn

# Make sure you're on yarn 3
yarn set version 3.2.0

# Install dependencies
yarn

# Starts the development server for the website
yarn workspace @project/client run start

# Build the extension to extension/dist
yarn workspace @project/extension buildDev

If you have problems building try deleting node_modules and re-running yarn.

Contact

Submit bugs or feature requests from the issues page. Join the Discord server to talk with me and other language learners.

Donations

If you've benefited from asbplayer, please consider supporting my work via Github Sponsors or Ko-fi.

240201-asbplayer's People

Contributors

killergerbah avatar zyphdoz avatar renji-xd avatar artjomsr avatar matiasislaa avatar cyphar avatar alexbofa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.