### Start Audiobookshelf Service Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/7.migration_and_backups.md Use this command to start the Audiobookshelf service when installed via systemd. ```bash systemctl start audiobookshelf.service ``` -------------------------------- ### Install Audiobookshelf Package Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/4.linux-install-rpm.md After activating the repository, install the Audiobookshelf package using dnf. All necessary dependencies will be installed automatically. ```bash dnf install audiobookshelf ``` -------------------------------- ### Start and Enable Audiobookshelf Service Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/4.linux-install-rpm.md Use systemctl to start the Audiobookshelf service and ensure it runs automatically on system boot. ```bash systemctl start audiobookshelf.service systemctl enable audiobookshelf.service ``` -------------------------------- ### Start Audiobookshelf Docker Container Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/7.migration_and_backups.md Use this command to start the Audiobookshelf Docker container. ```bash docker start ``` -------------------------------- ### Audiobookshelf Command-Line Configuration Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/5.linux-install-nix.md Example of how to run the audiobookshelf executable with specified metadata, configuration, port, and host. ```bash audiobookshelf --metadata "$(pwd)/metadata" \ --config "$(pwd)/config" \ --port 8000 \ --host 0.0.0.0 ``` -------------------------------- ### Install NPM Packages Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/README.md Install the necessary Node.js packages for the project. ```bash npm install ``` -------------------------------- ### Start Chromecast Receiver Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/static/chromecast/sample_receiver.html Adds a listener for the system ready event and then starts the Chromecast receiver context. This should be the last step in the receiver setup. ```javascript context.addEventListener(cast.framework.system.EventType.READY, () => { console.log('Ready') }); context.start() ``` -------------------------------- ### Declarative NixOS Installation Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/5.linux-install-nix.md Add audiobookshelf to your system's packages for declarative installation. ```nix environment.systemPackages = [ pkgs.audiobookshelf ]; ``` -------------------------------- ### Run Local Development Server Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/README.md Start a local development server for the Audiobookshelf website. The site will be available at http://localhost:3000. ```bash npm run dev ``` -------------------------------- ### Activate Audiobookshelf Repository Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/3.inux-install-deb.md Installs necessary packages, adds the GPG key, and configures the Audiobookshelf repository for apt. ```bash sudo apt install gnupg curl wget -O- https://advplyr.github.io/audiobookshelf-ppa/KEY.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/adb-archive-keyring.gpg sudo curl -s -o /etc/apt/sources.list.d/audiobookshelf.list https://advplyr.github.io/audiobookshelf-ppa/audiobookshelf.list ``` -------------------------------- ### Clone Audiobookshelf Web Repository Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/README.md Clone the repository to start contributing. Ensure Node.js version 20 is installed. ```bash git clone https://github.com/audiobookshelf/audiobookshelf-web.git cd audiobookshelf-web ``` -------------------------------- ### Install Audiobookshelf Package Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/3.inux-install-deb.md Updates the apt package list and installs the Audiobookshelf package. ```bash sudo apt update sudo apt install audiobookshelf ``` -------------------------------- ### Navigate to Audiobookshelf Base Path (Service) Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/7.migration_and_backups.md Change directory to the Audiobookshelf installation path when running as a service. ```bash cd /usr/share/audiobookshelf ``` -------------------------------- ### Podman CLI Installation Command Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/10. podman.md This command pulls the latest Audiobookshelf image and runs it as a detached container using Podman. Remember to customize volume paths and the timezone. ```bash podman pull ghcr.io/advplyr/audiobookshelf podman run -d \ -p 13378:80 \ -v :/config \ -v :/metadata \ -v :/audiobooks \ -v :/books \ -v :/podcasts \ --name audiobookshelf \ -e TZ="America/Toronto" \ ghcr.io/advplyr/audiobookshelf ``` -------------------------------- ### Docker Compose Configuration for Audiobookshelf Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/1.docker-windows.md This is an example docker-compose.yml file for deploying Audiobookshelf. Ensure you update the volume paths and optionally the user UID/GID to match your system configuration. ```yaml version: "3.7" services: audiobookshelf: image: "ghcr.io/advancingu/audiobookshelf:latest" container_name: "audiobookshelf" ports: - "13378:8080" volumes: - :/audiobooks - :/config restart: unless-stopped user: ":" ``` -------------------------------- ### Start Nginx Proxy Manager Container Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/14.nginxproxymanager-docker.md Command to start the Nginx Proxy Manager container in detached mode. ```bash docker compose up -d ``` -------------------------------- ### Make Authenticated Request with cURL Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/20.api-keys.md This example demonstrates how to fetch library data from the Audiobookshelf API using cURL, including the necessary Authorization header with your API key. ```bash curl -H "Authorization: Bearer " \ https://your-server:port/api/libraries ``` -------------------------------- ### Update Audiobookshelf with Docker Compose Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/updating/2.docker-compose-install.md Run these commands to pull the latest image, stop the current container, and start a new one with the updated image. ```bash docker compose pull docker compose down docker compose up --detach ``` -------------------------------- ### Make Authenticated Request with JavaScript Fetch API Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/20.api-keys.md This JavaScript example shows how to use the Fetch API to retrieve library data, ensuring the Authorization header is correctly set with your API key. ```javascript const response = await fetch("https://your-server:port/api/libraries", { headers: { Authorization: "Bearer ", }, }); const data = await response.json(); ``` -------------------------------- ### Stop Audiobookshelf Service Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/7.migration_and_backups.md Use this command to stop the Audiobookshelf service when installed via systemd. ```bash systemctl stop audiobookshelf.service ``` -------------------------------- ### Get Local IPv4 Address Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/1.docker-windows.md Use this PowerShell command to find your local IPv4 address for accessing Audiobookshelf on your network. ```powershell Get-NetIPAddress -AddressFamily IPV4 ``` -------------------------------- ### Set Receiver State Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/static/chromecast/sample_receiver.html Manages the receiver's UI state by adding or removing the 'active' class to the body. It also handles starting or clearing the backdrop interval based on the state. ```javascript function setState(state) { if (state === 'idle') { if (!backdropInterval) setBackdropInterval() } else if (backdropInterval) { console.log('Clear backdrop interval') clearInterval(backdropInterval) backdropInterval = null } document.body.className = state } ``` -------------------------------- ### Create Audiobookshelf Directory Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/14.nginxproxymanager-docker.md Commands to create a directory for Audiobookshelf and navigate into it. ```bash mkdir /mnt/audiobookshelf cd /mnt/audiobookshelf ``` -------------------------------- ### Unzip Backup File (Service/Docker) Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/7.migration_and_backups.md Navigate to the backups directory and unzip the backup file. Replace \'\' with the actual date of the backup. ```bash cd metadata/backups unzip .audiobookshelf ``` -------------------------------- ### Activate Audiobookshelf RPM Repository Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/4.linux-install-rpm.md Run this command to add the Audiobookshelf RPM repository to your system. This command dynamically selects the correct repository URL based on your RHEL version. ```bash dnf install -y "https://github.com/lkiesow/audiobookshelf-rpm/raw/el$(rpm -E %rhel)/audiobookshelf-repository-1-1.el$(rpm -E %rhel).noarch.rpm" ``` -------------------------------- ### Navigate to Audiobookshelf Base Path (Docker) Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/7.migration_and_backups.md Change directory to the location of your Docker Compose file when using Docker. ```bash cd ``` -------------------------------- ### Podman Quadlet Container Configuration Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/10. podman.md Use this Quadlet file for Podman version 4.4+ to run Audiobookshelf as a container. Ensure you replace placeholder paths with your actual directory locations and adjust SELinux contexts if necessary. ```ini # audiobookshelf.container [Container] ContainerName=audiobookshelf Image=ghcr.io/advplyr/audiobookshelf:latest AutoUpdate=registry NoNewPrivileges=true PublishPort=13378:80 Volume=:/audiobooks Volume=:/books Volume=:/podcasts Volume=:/config Volume=:/metadata [Service] Restart=always [Install] WantedBy=default.target ``` -------------------------------- ### Enable Audiobookshelf Systemd Service Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/5.linux-install-nix.md Enable the audiobookshelf systemd service declaratively in your NixOS configuration. ```nix services.audiobookshelf.enable = true; ``` -------------------------------- ### Recreate Container with Podman Run Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/updating/3. podman-install.md Stop, remove, and re-create the Audiobookshelf container with the latest image using `podman run`. Ensure to replace placeholder paths with your actual configuration and data directories. ```bash podman stop audiobookshelf podman rm audiobookshelf podman run -d \ -p 13378:80 \ -v :/config \ -v :/metadata \ -v :/audiobooks \ -v :/books \ -v :/podcasts \ --name audiobookshelf \ -e TZ="America/Toronto" \ ghcr.io/advplyr/audiobookshelf ``` -------------------------------- ### Replace SQLite Database (Service/Docker) Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/7.migration_and_backups.md Copy the restored SQLite database file to the configuration directory. ```bash cp audiobookshelf.sqlite ../../config/audiobookshelf.sqlite ``` -------------------------------- ### Replace Authors and Items Folders (Service/Docker) Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/7.migration_and_backups.md Copy the restored authors and items directories to their respective locations. ```bash cp -r metadata-authors ../authors cp -r metadata-items ../items ``` -------------------------------- ### Configure Audiobookshelf Service Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/4.linux-install-rpm.md Edit the configuration file to set paths and network options for Audiobookshelf. Modify HOST to '0.0.0.0' to listen on all network interfaces. ```javascript METADATA_PATH=/var/lib/audiobookshelf/metadata CONFIG_PATH=/var/lib/audiobookshelf/config PORT=13378 HOST=127.0.0.1 ``` -------------------------------- ### Restart Rootless Container Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/updating/3. podman-install.md Restart the Audiobookshelf container using systemd for user services after pulling a new image. ```bash systemctl --user restart audiobookshelf ``` -------------------------------- ### Audiobookshelf Default Configuration Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/3.inux-install-deb.md Shows the default configuration file for the Audiobookshelf service, specifying paths for metadata, config, and ffmpeg, as well as the default port. ```javascript METADATA_PATH=/usr/share/audiobookshelf/metadata CONFIG_PATH=/usr/share/audiobookshelf/config FFMPEG_PATH=/usr/lib/audiobookshelf-ffmpeg/ffmpeg FFPROBE_PATH=/usr/lib/audiobookshelf-ffmpeg/ffprobe TONE_PATH=/usr/lib/audiobookshelf-ffmpeg/tone PORT=13378 ``` -------------------------------- ### Restart Rootful Container Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/updating/3. podman-install.md Restart the Audiobookshelf container using systemd for system services after pulling a new image. ```bash sudo systemctl restart audiobookshelf ``` -------------------------------- ### Nginx Reverse Proxy Configuration for Audiobookshelf Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/5.linux-install-nix.md Configure Nginx as a reverse proxy to serve Audiobookshelf, including SSL and WebSocket support. ```nix services.nginx = { enable = true; recommendedProxySettings = true; virtualHosts."your.hostname.org" = { forceSSL = true; # Optional, but highly recommended locations."/" = { proxyPass = "http://127.0.0.1:${builtins.toString config.services.audiobookshelf.port}"; proxyWebsockets = true; extraConfig = '' proxy_redirect http:// $scheme://; ''; }; useACMEHost = "[attribute name from security.acme.certs]"; # Optional, but highly recommended }; }; ``` -------------------------------- ### Create Nginx Proxy Manager Directory Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/14.nginxproxymanager-docker.md Command to create a directory for Nginx Proxy Manager configuration. ```bash nano compose.yml ``` -------------------------------- ### Pull New Image for Rootless Containers Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/updating/3. podman-install.md Use this command to pull the latest Audiobookshelf image when running rootless containers. ```bash podman pull ghcr.io/advplyr/audiobookshelf ``` -------------------------------- ### Pull New Image for Rootful Containers Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/updating/3. podman-install.md Use this command with sudo to pull the latest Audiobookshelf image when running rootful containers. ```bash sudo podman pull ghcr.io/advplyr/audiobookshelf ``` -------------------------------- ### Docker Compose Configuration Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/2.docker-compose-install.md Use this configuration in your `docker-compose.yml` file. Remember to replace placeholder paths with your actual directory paths and remove the angle brackets. ```yaml services: audiobookshelf: image: ghcr.io/advplyr/audiobookshelf:latest ports: - 13378:80 volumes: - :/audiobooks - :/podcasts - :/config - :/metadata environment: - TZ=America/Toronto ``` -------------------------------- ### Create Audiobookshelf Docker Compose File Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/14.nginxproxymanager-docker.md This compose file configures the Audiobookshelf container. It joins the existing 'nginx' network and uses specified volume paths for data persistence. Adjust volume paths as needed. ```yaml version: "3.7" services: audiobookshelf: container_name: audiobookshelf-server image: ghcr.io/advplyr/audiobookshelf:latest #ports: # - 13378:80 volumes: - /mnt/audiobookshelf/data/audiobooks:/audiobooks - /mnt/audiobookshelf/data/podcasts:/podcasts - /mnt/audiobookshelf/data/config:/config - /mnt/audiobookshelf/data/metadata:/metadata networks: - nginx restart: unless-stopped networks: nginx: name: nginx_default external: true ``` -------------------------------- ### Create Nginx Proxy Manager Docker Compose File Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/14.nginxproxymanager-docker.md Use this compose file to set up the Nginx Proxy Manager container. Ensure paths in the volumes section are adjusted to your system. ```yaml version: '3.8' services: app: image: 'jc21/nginx-proxy-manager:latest' restart: unless-stopped ports: - '80:80' - '81:81' - '443:443' volumes: - ./data:/data - ./letsencrypt:/etc/letsencrypt ``` -------------------------------- ### Copy audio data and rewrite metadata with ffmpeg Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/17.ffprobe.md Use this command to copy the audio data and rewrite metadata, which can fix corrupt metadata or header issues. Ensure filenames with spaces are quoted. ```bash ffmpeg -i input.mp3 -c copy output.mp3 ``` ```bash ffmpeg -i "original file.m4b" -c copy "new file.m4b" ``` -------------------------------- ### Restart Audiobookshelf Service Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/3.inux-install-deb.md Restarts the Audiobookshelf systemd service after configuration changes. ```bash sudo systemctl restart audiobookshelf.service ``` -------------------------------- ### Configure Queue Manager Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/static/chromecast/sample_receiver.html Configures the Queue Manager for the player. Setting queue status limit to false allows for an unlimited number of queue items. ```javascript const playerManager = context.getPlayerManager() const queueManager = playerManager.getQueueManager() queueManager.setQueueStatusLimit(false) ``` -------------------------------- ### Docker Run Command Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/2.docker-compose-install.md An alternative command for users who prefer to use `docker run` directly. Ensure you replace placeholder paths with your actual directory paths. ```bash docker pull ghcr.io/advplyr/audiobookshelf docker run -d \ -p 13378:80 \ -v :/config \ -v :/metadata \ -v :/audiobooks \ -v :/podcasts \ --name audiobookshelf \ -e TZ="America/Toronto" \ ghcr.io/advplyr/audiobookshelf ``` -------------------------------- ### Automatic Podman Update Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/updating/3. podman-install.md Execute this command to automatically update the container if the AutoUpdate policy is set to 'registry'. ```bash podman auto-update ``` -------------------------------- ### Check Audiobookshelf Service Status Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/docs/install/4.linux-install-rpm.md Verify the current status of the Audiobookshelf service. ```bash systemctl status audiobookshelf.service ``` -------------------------------- ### Format Date and Transform Columns in Power Query Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/18.power-query.md Demonstrates formatting dates to UK format, selecting specific columns, removing unwanted columns, renaming columns for clarity, and converting time formats. ```powerquery dateFormattedUK = Table.TransformColumns(dateFormatted, {{"date", each DateTime.ToText(_, "dd/MM/yyyy"), type text}}), // Select the desired fields selectedFields = Table.SelectColumns(dateFormattedUK, {"mediaType", "title", "subtitle","author", "displayTitle", "displayAuthor", "Duration (HH:MM:SS)", "date", "dayOfWeek", "timeListening"}), // Remove wrong column #"Removed Columns" = Table.RemoveColumns(selectedFields,{"author"}), //Rename Columns to make it easier #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"displayTitle", "episode Title or Book Title"}, {"displayAuthor", "Author"}, {"date", "Date Listened"}, {"Duration (HH:MM:SS)", "Duration of Title (HH:MM:SS)"}, {"timeListening", "Listening Time (Seconds)"}}), // Convert Listening Time to HH:MM:SS format listeningTimeFormatted = Table.AddColumn(#"Renamed Columns", "Listening Time (HH:MM:SS)", each let totalSeconds = [#"Listening Time (Seconds)"], hours = Number.RoundDown(totalSeconds / 3600), remainingSeconds = totalSeconds - hours * 3600, minutes = Number.RoundDown(remainingSeconds / 60), seconds = Number.Round(remainingSeconds - minutes * 60, 0), formattedListeningTime = Text.From(hours) & ":" & Text.From(minutes) & ":" & Text.From(seconds) in formattedListeningTime ), //Convert Date Listened to Date Format #"Changed Type" = Table.TransformColumnTypes(listeningTimeFormatted,{{"Date Listened", type date}, {"Duration of Title (HH:MM:SS)", type time}, {"Listening Time (HH:MM:SS)", type time}}) in #"Changed Type" ``` -------------------------------- ### Stop Audiobookshelf Docker Container Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/7.migration_and_backups.md Use this command to stop the Audiobookshelf Docker container. ```bash docker stop ``` -------------------------------- ### Power Query M Code for Audiobookshelf Data Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/18.power-query.md This M code defines the steps to connect to the Audiobookshelf API, authenticate, retrieve listening sessions, and transform the data into a usable table format. It includes parameterization for User ID, API Key, items per page, and server address. ```m let // Get the values of parameters User_ID = Text.From(#"User_ID"), Bearer_Key = Text.From(#"Bearer_Key"), ItemsPerPage = Text.From(#"ItemsPerPage"), ABS_Server = Text.From(#"ABS_Server"), // Construct the API URL apiUrl = "https://" & ABS_Server & "/api/users/" & User_ID & "/listening-sessions?itemsPerPage=" & ItemsPerPage, // Set the headers with the Bearer Token headers = [#"Authorization" = "Bearer " & Bearer_Key], // Make the GET request response = Web.Contents(apiUrl, [Headers=headers]), // Convert the response to JSON jsonResponse = Json.Document(response), // Extract 'sessions' field sessions = jsonResponse[sessions], // Convert 'sessions' list to a table sessionsTable = Table.FromList(sessions, Splitter.SplitByNothing()), // Expand the record fields expandedFields = Table.ExpandRecordColumn(sessionsTable, "Column1", {"id", "userId", "libraryId", "libraryItemId", "bookId", "episodeId", "mediaType", "mediaMetadata", "chapters", "displayTitle", "displayAuthor", "coverPath", "duration", "playMethod", "mediaPlayer", "deviceInfo", "serverVersion", "date", "dayOfWeek", "timeListening", "startTime", "currentTime", "startedAt", "updatedAt"}), // Expand the 'mediaMetadata' record expandedMediaMetadata = Table.ExpandRecordColumn(expandedFields, "mediaMetadata", {"title", "subtitle", "author", "releaseDate"}), // Convert duration to HH:MM:SS format durationFormatted = Table.AddColumn(expandedMediaMetadata, "Duration (HH:MM:SS)", each let totalSeconds = [duration], hours = Number.RoundDown(totalSeconds / 3600), remainingSeconds = totalSeconds - hours * 3600, minutes = Number.RoundDown(remainingSeconds / 60), seconds = Number.RoundDown(remainingSeconds - minutes * 60), formattedDuration = Text.From(hours) & ":" & Text.From(minutes) & ":" & Text.From(seconds) in formattedDuration ), // Convert date to DateTime type first, and then to UK format dateFormatted = Table.TransformColumns(durationFormatted, {{"date", each DateTime.FromText(_, "en-GB"), type datetime}}) ``` -------------------------------- ### Re-encode an audio file with ffmpeg Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/17.ffprobe.md If a file is still unplayable after attempting to fix metadata, try re-encoding the entire file. This can help resolve issues with corrupted audio data or unsupported codecs. ```bash ffmpeg -i input.mp3 output.mp3 ``` -------------------------------- ### Custom Message Listener for Cover Updates Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/static/chromecast/sample_receiver.html Listens for custom messages on a specific channel to update server details, particularly the list of cover images, and then triggers the backdrop interval update. ```javascript const CUSTOM_CHANNEL = 'urn:x-cast:com.audiobookshelf.cast' context.addCustomMessageListener(CUSTOM_CHANNEL, (customEvent) => { var data = customEvent.data || {} if (typeof data === 'string') { data = JSON.parse(data) } console.log('Custom message', data) if (data.covers && data.covers.length) { serverDetails.covers = data.covers || [] setBackdropInterval() } }) ``` -------------------------------- ### Set Backdrop Interval for Idle State Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/static/chromecast/sample_receiver.html Sets an interval to periodically update the backdrop image when the receiver is in an idle state. This function relies on `serverDetails.covers` being populated. ```javascript function setBackdropInterval() { if (!serverDetails.covers.length) { return } console.log('Set Backdrop interval') clearInterval(backdropInterval) backdropInterval = setInterval(() => { var coverUrl = serverDetails.covers[currentCoverIndex] console.log('Updating backdrop image', coverUrl) var backdropel = document.getElementById('idle-backdrop') backdropel.style.backgroundImage = `url(${coverUrl})` var backdropimageEl = document.getElementById('backdrop-image') backdropimageEl.src = coverUrl currentCoverIndex++ if (currentCoverIndex >= serverDetails.covers.length) currentCoverIndex = 0 }, 5000) } ``` -------------------------------- ### Include API Key in Authorization Header Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/20.api-keys.md When making authenticated requests, include your API key in the Authorization header using the Bearer schema. This is a standard practice for token-based authentication. ```bash Authorization: Bearer ``` -------------------------------- ### Initialize Chromecast Receiver Context Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/static/chromecast/sample_receiver.html Initializes the Cast Receiver Context and sets the debug logger level. This is a fundamental step for any Chromecast receiver application. ```javascript const context = cast.framework.CastReceiverContext.getInstance() context.setLoggerLevel(cast.framework.LoggerLevel.DEBUG) ``` -------------------------------- ### Player Data Binder Event Listener Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/static/chromecast/sample_receiver.html Binds UI updates to player state changes. This listener updates the body class to 'idle' or 'active' based on the player's current state. ```javascript const playerData = {}; const playerDataBinder = new cast.framework.ui.PlayerDataBinder(playerData); playerDataBinder.addEventListener( cast.framework.ui.PlayerDataEventType.STATE_CHANGED, e => { switch (e.value) { case cast.framework.ui.State.LAUNCHING: case cast.framework.ui.State.IDLE: setState('idle') break; case cast.framework.ui.State.LOADING: case cast.framework.ui.State.BUFFERING: case cast.framework.ui.State.PAUSED: case cast.framework.ui.State.PLAYING: setState('active') break; } }); ``` -------------------------------- ### Bypass SSO Redirect URL Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/11.oidc_authentication.md Use this URL to manually access local login if SSO redirect is misconfigured or causing issues. ```text https://abs.yoursite.com/login/?autoLaunch=0 ``` -------------------------------- ### Send Queue Status Check Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/static/chromecast/sample_receiver.html Broadcasts the current queue status to all connected senders. This is useful for synchronizing queue information. ```javascript function sendCheckQueueItems() { var items = queueManager.getItems() var currentItem = queueManager.getCurrentItem() || {} console.log(`Queue has ${items.length} items. Current item is ${currentItem.itemId} with index ${queueManager.getCurrentItemIndex()}`) playerManager.broadcastStatus(true, 1, { type: 'checkQueue' }, true) } ``` -------------------------------- ### OIDC Redirect URIs Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/content/guides/11.oidc_authentication.md These URIs are required by your OIDC provider for callback handling. The first is for the website, and the second is for the mobile app. ```text https://abs.yoursite.com/auth/openid/callback https://abs.yoursite.com/auth/openid/mobile-redirect ``` -------------------------------- ### Load Message Interceptor Source: https://github.com/audiobookshelf/audiobookshelf-web/blob/master/static/chromecast/sample_receiver.html Intercepts LOAD messages sent to the receiver. This can be used for custom logic before media playback begins. ```javascript playerManager.setMessageInterceptor( cast.framework.messages.MessageType.LOAD, request => { console.log('Message intercept', request) return request }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.