Run AudioPlayer with url where Status Code 301

I use import { AudioPlayer } from ‘@amzn**/react-native-w3cmedia’;**

Some audio URLs return a 301 Moved Permanently status. After the redirect, the correct .mp3 file loads with a 206 Partial Content status. However, audio loading is very slow, and after loading, my application runs sluggishly and sometimes crashes. Do you think the redirect could be causing memory leaks?

My code for init player

import { AudioPlayer } from '@amzn/react-native-w3cmedia';

//////

  const preBufferAudio = useCallback(
    async (src: string) => {
      if (audioRef?.current == null) {
        audioRef.current = new AudioPlayer();
      }

      try {
        await audioRef?.current.initialize();
        audioRef.current.src = src;
        audioRef.current.autoplay = true;
        audioRef.current.load();

      } catch (error) {
        dispatch(
          errorAction({
            level: ErrorLevel.SILENT,
            type: ErrorType.GENERAL,
            message: (error as Error).message,
          }),
        );
      }
    },
    [audioSrc, dispatch],
  );

  useEffect(() => {
    const initAudio = async () => {
     if (audioSrc) await preBufferAudio(audioSrc);
    };

    initAudio();
  }, [audioSrc]);

/////

Hi @Viktor_Kravchuk ,

If it is a bug, please make sure to create a bug post under Bug Reports in future.

Could you please fill in the below details, to help us investigate the issue further?:

App Name:
App Link on Amazon Appstore (found through Developer Console → Actions column in App List → View on Amazon.com):

Bug Severity
Select one that applies

  • Impacts operation of app
  • Blocks current development
  • Improvement suggestion
  • Issue with documentation (If selected, please share the doc link and describe the issue)
  • Other

2. Steps to Reproduce

  1. [List the steps for reproducing the bug]
  2. [Any specific component or method call in React Native triggering the issue]

3. Observed Behavior

Explain what actually happened, noting any discrepancies or malfunctions.

<!-- Answer here -->

4. Expected Behavior

Describe what you expected the SDK to do under normal operation.

<!-- Answer here --> 

4.a Possible Root Cause & Temporary Workaround

Fill out anything you have tried. If you don’t know, N/A is acceptable

<!-- Answer here -->

5. Logs or crash report

(Please make sure to provide relevant logs as attachment and share VPKG file with your Amazon contact)

For crash issues, please refer this guide for faster troubleshooting: https://developer.amazon.com/docs/kepler-tv/detect-crash.html.

  • App/Device Logs
  • Crash Logs
  • Crash Report
  • For issues with Kepler Studio Extension, please share log files from below folders:
     ~/.vscode/extensions/amazon.kepler-extension-<version>/ExtensionLogs
     ~/.vscode/extensions/amazon.kepler-ui-extension-<version>/ExtensionLogs
    

6. Environment

Please fill out the fields related to your bug below:

  • SDK Version: Output of kepler --version
  • App State: [Foreground/Background]
  • OS Information
    Please ssh into the device via kepler exec vda shelland copy the output from cat /etc/os-releaseinto the answer section below. Note, if you don’t have a simulator running or device attached kepler exec vda shell will respond with vda: no devices/emulators found
    <!-- Answer here if applicable --> 
    

7. Example Code Snippet / Screenshots / Screengrabs

Include any relevant code or component setup in React Native that can help reproduce the bug.

import { ExampleComponent } from 'custom-sdk';

<ExampleComponent config={{ key: 'value' }} />

:backhand_index_pointing_right: Playback Issues


If this is a playback issue, please provide your VPKG and/or content URL, any pre-conditions (like geo-location) [Share privately with your Amazon contact] , and let us know if it’s x86 or arm7.


<!-- Describe your playback issue if applicable -->

Please share the following details in addition:_

  • Player SDK: [Bitmovin, Shaka, ...]
  • Player SDK Version: [e.g. 1.23]
    • Audio Codecs: [AAC, ...]
    • Video Codecs: [h.264, mp4]
    • Manifest Types: [m3u8, dash, etc ..]

Q: Would you like to be contacted to share your latest VPKG compiled with latest SDK:

[Y/N] [Share privately with your Amazon contact]

Q: VPN or Login needed to verify functionality in VPKG?

[Y/N] [Share privately with your Amazon contact]

Q: If applicable, please provide your media/content url
If this is created dynamically, tokenized, etc please provide a way for us to access it

[N/A or Content / Media Url for testing] [Share privately with your Amazon contact]

Q: Are there any special headers required to reproduce the issue you are facing?

[N/A or Insert Headers]

Additionally please provide the following if possible
Provide Screenshots / Screengrabs / Logs. Please include as much information as you can that will help debug.

<!-- Answer here if applicable --> 

:backhand_index_pointing_right: Additional Context


Any Additional Context you would like to provide?
Add any other relevant information, such as recent updates to the SDK, dependencies, or device OS that may affect the bug.

<!-- Answer here if applicable  --> 

Thanks,
Rohit

Hi @Viktor_Kravchuk ,

Could you please share the audio urls which are returning 301 as well as 206 codes?
Also, could you please share the vpkg and logs if any with your Amazon contact? This will help us to investigate further on this issue.

Thanks,
Rohit

I tried launch vega-audio-sample and use link with long audio https://ia801004.us.archive.org/18/items/iliadsofhomer_2510_librivox/iliad_30_homer_64kb.mp3 (57 min it’s without redirecting).

I can see long loading before start. @Amz_Rsk Could you help me - How can I start playing immediately like in browser?

1 Like

hello @Amz_Rsk

I just wanted to highlight that this issue has now become a release blocker for one of our customers.
It would be greatly appreciated if you could suggest a possible way to fix it.

Adding @jogashu for visibility — really hoping to get your support on this.

Thanks in advance,

cc: @Viktor_Kravchuk @riders
thanks.

kepleraudioreferenceapp_armv7.vpkg.txt (4.5 МБ)
There is demo app with long buffering. (First card on the Home screen)

used mp3 https://ia801004.us.archive.org/18/items/iliadsofhomer_2510_librivox/iliad_30_homer_64kb.mp3

Hi @Vitalii_Rurenko , @Viktor_Kravchuk ,

Thanks for sharing more details.
I have escalated this to our team to check on.

Regards,
Rohit

Hi @Viktor_Kravchuk ,

The sample vpkg file you shared seems to be corrupt. Our team was not able to use it.
Also, the team tried changing the content for “Rise UP” with the attached URL in sample audio app and the audio start in ~ 2 seconds.

Sharing some logs from our reproduction:
sampleaudiologs.txt (609.6 KB)

Could you please share your correct vpkg and logs over direct message to me (do not share vpkg here) please for our team to investigate and reproduce?

Thanks,
Rohit

Hello @Amz_Rsk I have sent vpkg file and video recording that and video recording when audio started after 1 minute waityng, on direct message.

Hi @Amz_Rsk do you think we can have some solutions based on the vpkg sent by @Viktor_Kravchuk .

cc: @jogashu

Hi @Viktor_Kravchuk /@Vitalii_Rurenko ,

Thank you for sharing the details.
I have already forwarded the video recording, vpkg to our team to reproduce and investigate.
Will update you once we here back from them.

Thanks,
Rohit

1 Like

I have had suggestion try to use @amzn/keplerscript-audio-lib for low level control audio playback. I tryed to use AudioPlaybackStream.writeAsync()
and AudioPlaybackStreamBuilder - from this lib,
but it doen’t work with .mp3 files.
Have any experience with implementation audio player with @amzn/keplerscript-audio-lib?

hi @Amz_Rsk
Could you please share any updates about this ticket?

Thanks,

Hey @Vitalii_Rurenko

I tried playing “Echoes of Albion” abum where “Rise UP” is the first track using the shared vpkg and the playback started within 5 seconds.
Could you please share logs and device information so we can check further?

Warm regards,
Ivy