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.29k stars 1.01k forks source link

v2 [@next, rc-18 published] #662

Closed dcvz closed 3 years ago

dcvz commented 5 years ago

v2.0.0

Changes

To update run yarn add react-native-track-player@next. Breaking changes are outlined below:

Migrating to RN 0.60

We've migrated to AndroidX, please follow migration instructions provided by the ReactNative team.

Exports Updated

PR: https://github.com/react-native-kit/react-native-track-player/pull/654 has changed the default export to only include methods on the player. State, Capability, PitchAlgorithm, TrackType and Event are now exported as enums.

import TrackPlayer, { State, Capability, TrackType } from '...'

Progress Hook Renamed

The hook useTrackPlayerProgress() has been fixed and renamed: useProgress(). The return has also been modified: bufferedPosition is now buffered.

@returns { position, duration, ~buffered~ }
t-tornado commented 3 years ago

The seekTo method still does not work on android. Is there any fix?

@t-tornado how did you use? Which version do you use? For me is working fine...

version 1.4.7

t-tornado commented 3 years ago

Has it been resolved in the new V2? @ithustle

ithustle commented 3 years ago

It 1.2.7 worked fine for me. Try 2.0.0-rc15 or 2.0.0-rc16

albert-kaygorodov commented 3 years ago

@dcvz can you pls bring playWhenReady: false back to .add method is ios/RNTrackPlayer/RNTrackPlayer.swift because the autoplay issue seems back after changing to indices from ids

seems the issue is still there:( playback gets started for me on iOS without hitting play

dcvz commented 3 years ago

I've published a new pre-release rc17. Here's a what's new:

I think we're down to the last bugs before being ready for an official v2.0.0! Please try this in your apps and report any issues you find!

dcvz commented 3 years ago

We'll keep an eye on this thread for more issues and try to fix them up. We appreciate any testing and reporting!

If no issues arise, we'll prepare to release the official v2.0.0 soon 🚀

Thanks @dcvz!

I stumbled across one other issue and meant to generate a simple repro case, but it's still on my todo list. The issue was a warning that I was trying to interact with an unmounted component, and I think the issue was that in this useEffect block we're not returning a callback to set savedHandler.current back to undefined.

Sorry this is a bit vague - I'll have a crack at a simple repro case this evening.

Did you get a chance to take a further look @simonwhitaker and reproduce in an example project? It could potentially be the use of useRef.

BjoernRave commented 3 years ago

what about the issue multiple people are having with playing/streaming audio on iOS? I created an issue with a reproduction a couple of days ago: https://github.com/DoubleSymmetry/react-native-track-player/issues/1198

simonwhitaker commented 3 years ago

We'll keep an eye on this thread for more issues and try to fix them up. We appreciate any testing and reporting!

If no issues arise, we'll prepare to release the official v2.0.0 soon 🚀

Thanks @dcvz! I stumbled across one other issue and meant to generate a simple repro case, but it's still on my todo list. The issue was a warning that I was trying to interact with an unmounted component, and I think the issue was that in this useEffect block we're not returning a callback to set savedHandler.current back to undefined. Sorry this is a bit vague - I'll have a crack at a simple repro case this evening.

Did you get a chance to take a further look @simonwhitaker and reproduce in an example project? It could potentially be the use of useRef.

I'm afraid not, sorry. I did spin up a simple demo project but I couldn't reproduce the issue.

shahidDev-RN commented 3 years ago

@dcvz how to do the shuffle functianality

dcvz commented 3 years ago

what about the issue multiple people are having with playing/streaming audio on iOS? I created an issue with a reproduction a couple of days ago: https://github.com/DoubleSymmetry/react-native-track-player/issues/1198

@BjoernRave ogg vorbis support is a known issue and something we want to fix after the v2 release.

dcvz commented 3 years ago

@dcvz how to do the shuffle functianality

this is not in v2 - we plan to add this once v2 is out! for now the only way would be to manage your own queue.

dcvz commented 3 years ago

I've published a new pre-release rc17. Here's a what's new:

  • revamped module for Windows by @tritao
  • fix bug when trying to add track at position 0 (by @austinried)
  • fix issue where track would auto start when adding to queue

I think we're down to the last bugs before being ready for an official v2.0.0! Please try this in your apps and report any issues you find!

I've made a small follow up pre-release rc18 fixing an issue where the playback-track-changed event would send null for some properties in iOS and undefined elsewhere. (reported by @ithustle )

ithustle commented 3 years ago

@dcvz and @Guichaguri I think that buffer is not working on Android when streaming type is hls... Could you, please, confirm that?

@dcvz , could you confirm that? on both android and iOS...

davidsalib commented 3 years ago

very excited for this update, thanks everybody for the contributions! is it possible to access the buffered data on device somehow? Don't think the current version allows for this, thought maybe V2 will allow for that?

ithustle commented 3 years ago

@dcvz, .getTrack() cause crash if none song is playing. .getCurrentTrack() return 0 if none song is playing. I think is bad because if a song is playing and if it is the first track of the queue the currentTrack position it will be 0 too. Remembering that zero it’s like false.

edgargrs commented 3 years ago

Hi everyone, I'm very excited about this update. Thanks for all good work here. 👍 Before you release the new version I would like to show you the Issue I found HERE. This is happens in the latest version(v2.0.0-rc18) and also in the previous version(v1.2.7). I created a repository to reproduce the issue.

dcvz commented 3 years ago

Thanks for the reports @ithustle and @edgargrs. We'll take a look soon :)

DennisdeWitNL commented 3 years ago

Edit: my mistake.

dcvz commented 3 years ago

Thanks everyone for the reports! Officially v2 is now out!

We've also gone through and mass cleaned the issues log in an effort to give us a better chance of maintaining this library and fixing new issues. If there's any issues with v2 please report them :)

We'll focus on stabilising any new issues + queue manipulations like shuffle and reordering.

afkcodes commented 3 years ago

@dcvz THanks man you certainly came from nowhere to save this project i will certainly try to update some of the android side stuff.

ithustle commented 3 years ago

Great news, @dcvz. However, I double checked on documentation but I've no see shuffle functions. Is there a plan to implement this one?

dcvz commented 3 years ago

@ithustle this was not part of v2, now that the release is out we'll be able to focus on more additions for queue management

DennisdeWitNL commented 3 years ago

This new version is not working, at all.

Once I loaded the app, I immediately get a red screen and the app fully crashes: "Argument 1 (NSNumber) of TrackPlayerModule.add must not be null"

Then iOS crashes: "Thread 6: Fatal error: Index out of range"

Any idea?

dcvz commented 3 years ago

@DennisdeWitNL are you migrating from a previous v2-rc? Or from 1.2.7?

DennisdeWitNL commented 3 years ago

@dcvz From 1.2.7. But even the documentation for version 2.0.0 doesn't work. I have no clue what to do, other than staying on 1.2.7 for now. :-)

dcvz commented 3 years ago

@DennisdeWitNL all methods that modify the queue were changed to be index based instead of based ok track ids.

Perhaps a migration guide will need to be written.

dcvz commented 3 years ago

@ithustle the last 2 things regarding getCurrentTrack() -- have been fixed. Could you give them a try?

DennisdeWitNL commented 3 years ago

@dcvz But is it a problem with my code, or is it broken out of the box already? Because even when I delete all functions that have to do with TrackPlayer, I still get this immediate crash. I assume there is a big bug that makes this module completely broken@v2.

DennisdeWitNL commented 3 years ago

I tried it out of the box - still not working. This is an issue with the module, not with my code.

dcvz commented 3 years ago

@DennisdeWitNL taking a look now. So you made an entirely new project. Added v2 and it's crashing? With what error!"?

ithustle commented 3 years ago

@ithustle the last 2 things regarding getCurrentTrack() -- have been fixed. Could you give them a try?

I'll update now to v2 and give to you a feedback

DennisdeWitNL commented 3 years ago

@dcvz "Argument 1 (NSNumber) of TrackPlayerModule.add must not be null" is the screen that pops up.

Then iOS crashes: "Thread 6: Fatal error: Index out of range" - it is in the updateMetadataForTrack public function. Xcode sends me to the react-native-track-player pod >> RNTrackPlayer >> let track = player.items[trackIndex.intValue] as! Track (line 513)

All I can think of, is I might have missed the update function somewhere and it is still firing.

How should I update the metadata properly in v2? I am currently using:

TrackPlayer.updateMetadataForTrack("stream", { I guess the problem is in “stream”. So how should I fix that? I can send you a ZIP-file or so if you need it. (Won’t publicly put it on Github.)

DennisdeWitNL commented 3 years ago

@dcvz I checked the log. Does this help you?

Compatibility Header/react_native_track_player-Swift.h:194:9: error: 'react_native_track_player/react_native_track_player.h' file not found

import <react_native_track_player/react_native_track_player.h>

    ^

error: could not build Objective-C module 'react_native_track_player'

ithustle commented 3 years ago

@ithustle the last 2 things regarding getCurrentTrack() -- have been fixed. Could you give them a try?

Yep, its fixed. For android return null For iOS return undefined

DennisdeWitNL commented 3 years ago

@dcvz It took me a few hours to figure out I was editing the wrong xcworkspace file. OMG, I am so dumb! :-))

However, the module crashes when I am updating the metadata with the artwork. How do I get a local artwork to work?

      const trackId = await TrackPlayer.getCurrentTrack();
      TrackPlayer.updateMetadataForTrack(trackId, {
        title: Artist,
        artist: Title,
        artwork: require('./Logo.jpg')

Makes the module crashing in Model MediaURL on line 32

        } else {
            let url = object as! String

It worked on 1.2.7, so I guess something has changed. Could you tell me the correct way to display a local artwork? Thanks! (other than that, everything seems to work!, great work!)

ithustle commented 3 years ago

@DennisdeWitNL, try to get relative path of artwork, like file:/// ... or the url

DennisdeWitNL commented 3 years ago

@ithustle How would that work? file:///Logo.png? I guess that won’t work. And I don’t want to install even more third party plugins to find a dynamic relative path.

I am trying to avoid URL for artwork, because that would mean the server could be offline. And if the server is offline, the app would fully crash. I am using a static image anyway (the logo of the app as the artwork), so why not keep it locally? :)

Edit: using file:// for loading a static image is not the correct way to do it, according to React Native. It should be the require-method, not file://. It worked fine at 1.2.7, so I still think something has changed.

dcvz commented 3 years ago

You're right @DennisdeWitNL -- I've fixed this now in https://github.com/DoubleSymmetry/react-native-track-player/pull/1223 which will go out with v2.0.1 later today!

DennisdeWitNL commented 3 years ago

@dcvz Is there also a way to solve the problem with the NowPlayingInfoProperty in the newest Xcode? On line 34, it says @available(iOS 10.3, *). According to Xcode, Enum cases with associated values cannot be marked potentially unavailable.

Same goes for line 119. There is says @available(iOS 11.0, *).

When I change it to iOS 10, the problem is solved.

DennisdeWitNL commented 3 years ago

@dcvz The module is broken in Android. Double Can Not Be Cast To String. Any idea's?

Java.lang.Double cannot be cast to Java.lang.String getString ReadableNativeArray.Java on line 102.

dcvz commented 3 years ago

@DennisdeWitNL your problem description doesn't have a lot of info. Is it a certain method that's failing?

Could you please try to run the example app and see if that fails for you?

DennisdeWitNL commented 3 years ago

@dcvz I have no idea what happened. I deleted the app, ran the app again in the simulator and the problem went away. Will report again when I see this problem again.

DennisdeWitNL commented 3 years ago

@dcvz An other app I recently updated to 2.0.1 and uploaded to Google Play Store, shows a similar crash. On 4000 users, the app crashes 66 times a day. I never saw this error in 1.2.7, so maybe you have an idea? What relevant code should I post in order for you to fix this?

java.lang.NullPointerException: 
  at com.facebook.react.bridge.ReadableNativeArray.getDouble (ReadableNativeArray.java:92)
  at com.facebook.react.bridge.JavaMethodWrapper$4.extractArgument (JavaMethodWrapper.java:64)
  at com.facebook.react.bridge.JavaMethodWrapper$4.extractArgument (JavaMethodWrapper.java:60)
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:356)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:151)
  at com.facebook.react.bridge.queue.NativeRunnable.run (Native Method)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
  at android.os.Looper.loop (Looper.java:246)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:226)
  at java.lang.Thread.run (Thread.java:923)

Note: the trackID’s are still a string in my code, not a number like 1,2,3 and such. Would that be the problem?

dcvz commented 3 years ago

@DennisdeWitNL twice already you've posted about issues that were not bugs in the library. This crash seems like you're using an invalid parameter type.

I'll be locking this thread now. If there's a concrete bug in the library please create a new issue. If you need help with debugging you should instead try through our discord community.