Issue with displaying Wavesurfer.js waveform in custom Shopify section

Greetings to the Stockoverflow Community,

I am facing a challenge with integrating WaveSurfer.js into a customized section on my Shopify store. Even though I have successfully implemented the section, the waveform visualization is not appearing.

Link to the test page:

Description of the Problem: The WaveSurfer.js library is intended to generate visual audio waveforms on the provided page, but while the audio files can be played, the waveform remains invisible. The console logs indicate that WaveSurfer is ready and there are no direct errors pointing to WaveSurfer.js itself. However, there are repeated notifications about third-party cookies being blocked, although it's uncertain if this is related.

Below is the Liquid/JavaScript snippet where WaveSurfer is initialized and expected to load and display waveforms:

(WaveSurfer.js is loaded via my theme.liquid. It was also previously loaded in the section liquid itself with

<script src="https://unpkg.com/wavesurfer.js"></script>
)

liquidCopy code
<!-- WaveSurfer Initialization -->
<script>
document.addEventListener('DOMContentLoaded', function() {
    var players = {};

    {% for block in section.blocks %}
        players['{{ block.id }}'] = WaveSurfer.create({
            container: '#wave-{{ block.id }}',
            waveColor: '#4F4A85',
            progressColor: '#383351',
            cursorColor: 'transparent',
            barWidth: 2,
            height: 60,
            responsive: true,
            autoCenter: true
        });

        players['{{ block.id }}'].load('{{ block.settings.audio_url }}');

        players['{{ block.id }}'].on('ready', function() {
            console.log('WaveSurfer is ready for block ' + '{{ block.id }}');
        });

        players['{{ block.id }}'].on('error', function(e) {
            console.error('WaveSurfer error:', e);
        });
    {% endfor %}

    window.togglePlay = function(blockId) {
        var player = players[blockId];
        if (player) {
            player.playPause();
        }
    };
});
</script>

I would greatly appreciate any guidance or recommendations to address this issue, especially if anyone has encountered similar difficulties with WaveSurfer.js or has insights on how warnings about third-party cookies may affect JavaScript functionality.

Thank you in advance for your assistance!

Ensured that the wavesurfer.min.js script is correctly loaded in the site's theme files and globally accessible. Confirmed that the initialization script for WaveSurfer is appropriately connected to each audio block and verified that it executes after the DOM is fully loaded. Verified that there are no visible browser console errors directly linked to the operation of WaveSurfer. Tested in multiple browsers to eliminate any browser-specific issues.

Answer №1

Your base.css file contains the following rule:

a:empty,
ul:empty,
dl:empty,
div:empty,
section:empty,
article:empty,
p:empty,
h1:empty,
h2:empty,
h3:empty,
h4:empty,
h5:empty,
h6:empty {
  display: none;
}

This rule is causing a conflict with WaveSurfer's rendering, as mentioned in this comment

An easy solution would be to add the following CSS rule:

.waveform div:empty {
  display: block;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I use AJAX to automatically populate a dropdown menu with cities in a PHP MVC application?

Within a PHP MVC setup, there is a file named city.php in the model section which defines a city class. The city class contains a method called getCitiesByProvince('ProvinceId') that retrieves all cities for a given province. When a user picks ...

ReactJS form submissions failing to detect empty input values

My goal is to use react to console.log the input value. Below is the code I've created: import React from 'react'; import ReactDOM from 'react-dom'; class App extends React.Component{ constructor() { super(); this.proce ...

Access and retrieve data from a string using XPath with JavaScript

My HTML page content is stored as a string shown below: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1>This is a Heading</h1> <p>This is a paragraph.</p> </ ...

Retrieve the index of a v-for loop and then send it as a parameter to a specific function

When working with a select element generated by a v-for loop in Vue, it is important to be able to retrieve the index of the selected option. This way, you can use that index in a function for further processing. However, I have been struggling to achieve ...

Is there a way to hide the borders between cells within these divs?

I am working on an application screen using Vue.js and facing an issue with the divisions between cells. I want to hide these divisions so that the lines of the items appear continuous. I attempted to modify the classes of the columns to "col-md" and "col ...

Utilizing various Firestore requests at varying intervals using the useEffect hook in React

useEffect(async() => { await getWord(); const interval = setInterval(() =>{ time2 = time2 - 1; if (time2 == 0) { clearInterval(interval); let dataURL = canvasRef.current.toDataURL(); const db = firebase.firestore(); ...

All Event Monitor

Is it possible to use Event Listeners in jQuery to display information when a specific word is clicked? For example, showing a definition when a word is clicked. Thanks, Adam. I need help with creating a feature where clicking on a person's name in a ...

Incorporating the angular UI router effectively by reusing the same templateUrl and controller multiple times

Exploring the AngularUI Router framework for the first time, I am curious about how to enhance the code snippet below. Everything is functioning well at the moment, but as the project progresses, it will feature 20 questions or more. I want to avoid repea ...

Setting up Socket.io results in numerous transport polling GET requests being initiated

I have set up an express.js server-side and followed the socket.io guide. However, I am facing issues with the socket connection not being successful, and there seems to be a high number of unexpected GET requests like this: https://i.stack.imgur.com/GDGg ...

Create a new variable to activate a function within the parent component in Vue

I want to invoke a function in the parent component from its child component. In my Vue project, I have designed a reusable component that can be used across multiple pages. After the function is executed in this component, I aim to call a specific functi ...

Only the initial upload file is being passed through the Apollo Express server, with the remaining files missing in action

Currently, I am utilizing the apollo-express server with GraphQL. One issue I am encountering involves a mutation where I pass files from the front-end to the back-end. Strangely, I receive the file:{} object only for the first file - for the others, I rec ...

Optimizing Nginx for caching server-side rendered (SSR) web pages developed using React and Next.js

After creating an application where some pages are rendered on the server side, I noticed that something wasn't right. When viewing the requested pages in my browser, everything seemed normal. However, when I sent a CURL request to the page and saved ...

What is the solution for resolving the problem of the cursor jumping to the end when converting numbers in JavaScript?

After exploring the inquiries regarding converting digits in JavaScript, such as What's the solution and the right way to convert digits in JavaScript? and How to convert numbers in JavaScript, and problems with commands to remove non-numeric characte ...

A step-by-step guide on modifying the box-shadow color using jquery

I have developed some JavaScript code that adjusts the box-shadow of buttons to be a darker version of their background color. This allows users to dynamically change the button background colors. The current code successfully changes the box shadow based ...

Storing files offline in Firefox 3.5 with file:// protocol

While experimenting with the code for offline storage in Firefox 3.5, I referred to a tutorial on . When the page loads, I am prompted with a dialog asking to store data, but after clicking Allow, the dialog does not disappear. The application functions co ...

Is it possible to implement CSS code from a server request into a React application?

With a single React app that hosts numerous customer websites which can be customized in various ways, I want to enable users to apply their own CSS code to their respective sites. Since users typically don't switch directly between websites, applying ...

How can I retrieve the height of a dynamically generated div in Angular and pass it to a sibling component?

My setup consists of a single parent component and 2 child components structured as follows: Parent-component.html <child-component-1 [id]="id"></child-component-1> <child-component-2></child-component-2> The child-compo ...

Retrieve the id of the anchor tag that was selected upon clicking, and then dynamically change the content of another div

Seeking guidance on how to dynamically change the content of a div element based on which anchor tag is clicked. Below is the HTML structure and JavaScript function I have attempted: HTML: <div> <a id="a1" href="javascript: changeDiv();">tag1 ...

Leveraging Angular to dynamically adjust the height of ng-if child elements based on parent

I'm struggling with a few things in my current setup. I have a view that consists of 3 states - intro, loading, and completed. My goal is to create a sliding animation from left to right as the user moves through these states. Here is the basic struc ...

Experiencing complications when retrieving API information in my React component

There is a json file available: {"area":[{"id":"1","name":"abc","address":"223 "},{"id":"2","name":"xyz","address":"123 "}] I am trying to fetch and display the data in my component using react and redux. Although I have successfully loaded the url with ...