Friday, 24 December 2021

Audio not playing on the front: Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME

I am having a problem with audio playback at the front. This problem is only present when deploying to prod. When launched locally, audio is played. When I launch it on production, when I play audio (via the a tag), I get the following message: Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME.

Can you please tell me which way to look, where to look for a solution? I've already googled everything and zero information. I would be extremely grateful. Thank you.

Backend on Flask:

import os
from flask import Flask, Response, request
from flask_cors import CORS

app = Flask(name)
CORS(app)

def generate_wav(path: str, count_read=65536):    
    with open(path, "rb") as fio:
        data = fio.read(count_read)
        while data:
            yield data
            data = fio.read(count_read)

@app.route("/get-wav")
def get_wav():
    path = request.args.get('path')    
    return Response(generate_wav(path), mimetype="audio/x-wav")

Frontend, working version (local):

<audio controls>
    <source src="localhost:5000/get-wav?path=/full_path/file.wav" type="audio/wave">
    <p>
        Your browser does not support HTML5 <code>audio</code>.
        To listen, click on <a href="localhost:5000/get-wav?path=/full_path/file.wav">link</a>
    </p>
</audio>

Frontend, non-working version on prod (another computer):

<audio controls>
    <source src="external_address.com/get-wav?path=/full_path/file.wav" type="audio/wav">
    <p>
        Your browser does not support HTML5 <code>audio</code>.
        To listen, click on <a href="external_address.com/get-wav?path=/full_path/file.wav">link</a>
    </p>
</audio>


from Audio not playing on the front: Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME

No comments:

Post a Comment