Skip to content

How to control APLayer? #4669

Closed Answered by evnchn
SHDocter asked this question in Q&A
Apr 27, 2025 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

@SHDocter Thank you.

Use ui.run_javascript to run JavaScript and invoke the JavaScript API of APlayer.

But you need to do the following:

  • Put the APlayer instance in the window (I think) for the other scripts to access it.
  • Use the@ui.page page decorator for ui.run_javascript to work properly as of now.
from nicegui import ui

aplayer_js = "https://cdn.jsdelivr.net/npm/[email protected]/dist/APlayer.min.js"
aplayer_css = "https://cdn.jsdelivr.net/npm/[email protected]/dist/APlayer.min.css"

@ui.page("/")
def main_page():
    ui.add_head_html(f'''
        <link rel="stylesheet" href="{aplayer_css}">
        <script src="{aplayer_js}"></script>
    ''')

    music_data = [
        {
            "…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@SHDocter
Comment options

@SHDocter
Comment options

Answer selected by SHDocter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants