doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.25k stars 1k forks source link

PLS URL not working on Android #2239

Closed glopez-askit closed 5 months ago

glopez-askit commented 8 months ago

Describe the Bug I have the following streaming URL for my radio station:

https://cast6.my-control-panel.com/stream/unica/stream.pls

I'm attempting to use the react-native-track-player library to play audio from this URL. I've implemented it as follows:

  // ...
  const initPlayer = async (audio: string) => {
    await TrackPlayer.setupPlayer();

    await TrackPlayer.updateOptions({
      android: {
        appKilledPlaybackBehavior:
          AppKilledPlaybackBehavior.StopPlaybackAndRemoveNotification,
      },
      capabilities: [Capability.Play, Capability.Pause],
      compactCapabilities: [Capability.Play, Capability.Pause],
      notificationCapabilities: [Capability.Play, Capability.Pause],
    });

    TrackPlayer.add({
      url: audio,
      title: 'My Stream',
      artist: 'My Stream',
      artwork: require('@assets/logo.png'),
      type: TrackType.HLS,
    });
  };
  // ...

And in the service.stream.js section:

//...

export const PlaybackService = async function() {
  const listenerService = new ListenerService();

  TrackPlayer.addEventListener(Event.PlaybackState, ({ state }) => {
    if ([State.Playing, State.Paused].includes(state)) {
      listenerService.register(state === State.Playing);
    }
  });

  TrackPlayer.addEventListener(Event.RemotePlay, () => {
    TrackPlayer.play();
  });

  TrackPlayer.addEventListener(Event.RemotePause, () => {
    TrackPlayer.pause();
  });

  TrackPlayer.addEventListener(Event.PlaybackError, event => {
    console.log(event);
  });
};

The issue arises when pressing the play button on Android, and the console displays the following message:

{"code": "android-parsing-manifest-malformed", "message": "Source error"}

Strangely, this issue only occurs on Android; the configuration works perfectly on iOS.

Steps To Reproduce

  1. Press the play button on Android.

Code To Reproduce Unfortunately, I can't provide a simple code example to replicate the bug.

Replicable on Example App? I'm unsure if this bug can be replicated in the React Native Track Player Example App.

Environment Info:

System:
  OS: macOS 14.2.1
  CPU: (8) arm64 Apple M2
  Memory: 117.11 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.15.0
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.19
    path: /usr/local/bin/yarn
  npm:
    version: 9.5.0
    path: /usr/local/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK:
    API Levels:
      - "32"
      - "33"
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
    System Images:
      - android-28 | Google APIs ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-33 | Google APIs Intel x86_64 Atom
      - android-34 | Google Play ARM 64 v8a
      - android-UpsideDownCake-ext5 | Google APIs ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2022.1 AI-221.6008.13.2211.9619390
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.2
    wanted: 0.73.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

"react-native-track-player": "^4.0.1"
Running on Simulator (Android)

How I can Help

What can you do to help resolve this? I need to confirm if the library truly supports the format of my streaming URL.

Have you investigated the underlying JS or Swift/Android code causing this bug? Yes.

Can you create a Pull Request with a fix? No.

lovegaoshi commented 8 months ago

RNTP on android uses exoplayer; see https://developer.android.com/media/media3/exoplayer/supported-formats https://github.com/google/ExoPlayer/issues/1947

PLS is probably not supported out of the box

glopez-askit commented 8 months ago

RNTP on android uses exoplayer; see https://developer.android.com/media/media3/exoplayer/supported-formats google/ExoPlayer#1947

PLS is probably not supported out of the box

Thank you very much, but I have even tried with the address that contains the PLS file, and the error is the same.

[playlist]
numberofentries=1
File1=https://cast6.my-control-panel.com/proxy/unica/stream
Title1=
Length1=-1
version=2

The address is https://cast6.my-control-panel.com/proxy/unica/stream, it's working on iOS, the problem is Android.

lovegaoshi commented 8 months ago

ru sure? i put https://cast6.my-control-panel.com/proxy/unica/stream in place of https://github.com/doublesymmetry/react-native-track-player/blob/47b2d08033563ef4d7e76a7f061c244ac3dba1ec/example/src/assets/data/playlist.json#L3 and it works fine.

AmmarKhan21 commented 8 months ago

ru sure? i put https://cast6.my-control-panel.com/proxy/unica/stream in place of

https://github.com/doublesymmetry/react-native-track-player/blob/47b2d08033563ef4d7e76a7f061c244ac3dba1ec/example/src/assets/data/playlist.json#L3

and it works fine.

Hi i tried but diidm't work i am having same issue. getting output {"buffered": 0, "duration": 0, "position": 0}

here is code await TrackPlayer.add([ { id: 1, url: "https://cast6.my-control-panel.com/proxy/unica/stream.mp3", // Load media from the network title: "Avaritia", artist: "deadmau5", album: "while(1<2)", genre: "Progressive House, Electro House", date: "2014-05-20T07:00:00+00:00", // RFC 3339 currentIndex: index, // artwork: "http://example.com/cover.png", // Load artwork from the network //duration: 402, // Duration in seconds }, ]); await TrackPlayer.play();

lovegaoshi commented 8 months ago

weell dont add .mp3 just use the stream url

On Tue, Jan 23, 2024, 12:39 PM Ammar khan @.***> wrote:

ru sure? i put https://cast6.my-control-panel.com/proxy/unica/stream in place of

https://github.com/doublesymmetry/react-native-track-player/blob/47b2d08033563ef4d7e76a7f061c244ac3dba1ec/example/src/assets/data/playlist.json#L3

and it works fine.

Hi i tried but diidm't work i am having same issue. getting output {"buffered": 0, "duration": 0, "position": 0}

here is code await TrackPlayer.add([ { id: 1, url: "https://cast6.my-control-panel.com/proxy/unica/stream.mp3", // Load media from the network title: "Avaritia", artist: "deadmau5", album: "while(1<2)", genre: "Progressive House, Electro House", date: "2014-05-20T07:00:00+00:00", // RFC 3339 currentIndex: index, // artwork: "http://example.com/cover.png", // Load artwork from the network //duration: 402, // Duration in seconds }, ]); await TrackPlayer.play();

— Reply to this email directly, view it on GitHub https://github.com/doublesymmetry/react-native-track-player/issues/2239#issuecomment-1906880458, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZMOVVVJNZKOLVUYHQ4MCNDYQANWTAVCNFSM6AAAAABCGEQYGOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBWHA4DANBVHA . You are receiving this because you commented.Message ID: @.*** com>

AmmarKhan21 commented 8 months ago

https://cast6.my-control-panel.com/proxy/unica/stream

weell dont add .mp3 just use the stream url On Tue, Jan 23, 2024, 12:39 PM Ammar khan @.> wrote: ru sure? i put https://cast6.my-control-panel.com/proxy/unica/stream in place of https://github.com/doublesymmetry/react-native-track-player/blob/47b2d08033563ef4d7e76a7f061c244ac3dba1ec/example/src/assets/data/playlist.json#L3 and it works fine. Hi i tried but diidm't work i am having same issue. getting output {"buffered": 0, "duration": 0, "position": 0} here is code await TrackPlayer.add([ { id: 1, url: "https://cast6.my-control-panel.com/proxy/unica/stream.mp3", // Load media from the network title: "Avaritia", artist: "deadmau5", album: "while(1<2)", genre: "Progressive House, Electro House", date: "2014-05-20T07:00:00+00:00", // RFC 3339 currentIndex: index, // artwork: "http://example.com/cover.png", // Load artwork from the network //duration: 402, // Duration in seconds }, ]); await TrackPlayer.play(); — Reply to this email directly, view it on GitHub <#2239 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZMOVVVJNZKOLVUYHQ4MCNDYQANWTAVCNFSM6AAAAABCGEQYGOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBWHA4DANBVHA . You are receiving this because you commented.Message ID: @. com>

Hi just tried without .mp3 still didn't worked: await TrackPlayer.add([ { id: 1, url: "https://cast6.my-control-panel.com/proxy/unica/stream", // Load media from the network title: "Avaritia", artist: "deadmau5", album: "while(1<2)", genre: "Progressive House, Electro House", date: "2014-05-20T07:00:00+00:00", // RFC 3339 currentIndex: index, // artwork: "http://example.com/cover.png", // Load artwork from the network //duration: 402, // Duration in seconds }, ]); await TrackPlayer.play();

          **Hi can you  telll me which version you are  using for this package? i'm using  ^4.0.1**
image
lovegaoshi commented 8 months ago

whelp. this url works with the example app and i suggest you to also fork the example, use your url to rule out any device issues or your app setup first

On Tue, Jan 23, 2024, 12:50 PM Ammar khan @.***> wrote:

https://cast6.my-control-panel.com/proxy/unica/stream

weell dont add .mp3 just use the stream url … <#m-7224350574644903054> On Tue, Jan 23, 2024, 12:39 PM Ammar khan @.> wrote: ru sure? i put https://cast6.my-control-panel.com/proxy/unica/stream https://cast6.my-control-panel.com/proxy/unica/stream in place of https://github.com/doublesymmetry/react-native-track-player/blob/47b2d08033563ef4d7e76a7f061c244ac3dba1ec/example/src/assets/data/playlist.json#L3 https://github.com/doublesymmetry/react-native-track-player/blob/47b2d08033563ef4d7e76a7f061c244ac3dba1ec/example/src/assets/data/playlist.json#L3 and it works fine. Hi i tried but diidm't work i am having same issue. getting output {"buffered": 0, "duration": 0, "position": 0} here is code await TrackPlayer.add([ { id: 1, url: "https://cast6.my-control-panel.com/proxy/unica/stream.mp3 https://cast6.my-control-panel.com/proxy/unica/stream.mp3", // Load media from the network title: "Avaritia", artist: "deadmau5", album: "while(1<2)", genre: "Progressive House, Electro House", date: "2014-05-20T07:00:00+00:00", // RFC 3339 currentIndex: index, // artwork: "http://example.com/cover.png http://example.com/cover.png", // Load artwork from the network //duration: 402, // Duration in seconds }, ]); await TrackPlayer.play(); — Reply to this email directly, view it on GitHub <#2239 (comment) https://github.com/doublesymmetry/react-native-track-player/issues/2239#issuecomment-1906880458>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZMOVVVJNZKOLVUYHQ4MCNDYQANWTAVCNFSM6AAAAABCGEQYGOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBWHA4DANBVHA https://github.com/notifications/unsubscribe-auth/AZMOVVVJNZKOLVUYHQ4MCNDYQANWTAVCNFSM6AAAAABCGEQYGOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBWHA4DANBVHA . You are receiving this because you commented.Message ID: @. com>

Hi just tried without .mp3 still didn't worked: await TrackPlayer.add([ { id: 1, url: "https://cast6.my-control-panel.com/proxy/unica/stream", // Load media from the network title: "Avaritia", artist: "deadmau5", album: "while(1<2)", genre: "Progressive House, Electro House", date: "2014-05-20T07:00:00+00:00", // RFC 3339 currentIndex: index, // artwork: "http://example.com/cover.png", // Load artwork from the network //duration: 402, // Duration in seconds }, ]); await TrackPlayer.play();

      **Hi can you  telll me which version you are  using for this package? i'm using  ^4.0.1**

image.png (view on web) https://github.com/doublesymmetry/react-native-track-player/assets/62397964/9b834423-6d37-4a97-b355-b4f631a3fe4a

— Reply to this email directly, view it on GitHub https://github.com/doublesymmetry/react-native-track-player/issues/2239#issuecomment-1906895422, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZMOVVRNWHT5HN34ZO5XN2LYQAPAFAVCNFSM6AAAAABCGEQYGOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBWHA4TKNBSGI . You are receiving this because you commented.Message ID: @.*** com>

lovegaoshi commented 8 months ago

actually seeing your screenshot does it not work? its a stream so the log in ur screenshot looks normal

AmmarKhan21 commented 8 months ago

actually seeing your screenshot does it not work? its a stream so the log in ur screenshot looks normal

Nope by default even there is no track it shows all content 0. So surely its bug in 4.1 i just verify by down the version to 3.2 and there same ur that you proved and also check with mine url its also working at that version.

So anybody who is having same issue like playing audio using url doesn't not work on android but working on iOS you can downgrade to 3.2 its working there

And also I'm requesting the this package manager please have a look and please fix the issue i wasted alot of time on it.Hopefully we see the fix soon thanks.

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 5 months ago

This issue was closed because it has been stalled for 7 days with no activity.