-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android get URL of current track like iOS #35
Comments
I'm not against contributing. Will:
works ? |
Hi ! Yes we are missing some informations on the android side. We need url, duration and progress if possible on the events. Also on the method getStatus https://github.com/tlenclos/react-native-audio-streaming/blob/master/android/src/main/java/com/audioStreaming/ReactNativeAudioStreamingModule.java#L120. Feel free to open a PR, thanks ;) |
I managed to add url but I'm not abled to get duration and progress. So far my code in signal.java: @Override
public void playerPCMFeedBuffer(boolean isPlaying, int bufSizeMs, int bufCapacityMs) {
if (isPlaying) {
this.isPreparingStarted = false;
if (bufSizeMs < 500) {
this.isPlaying = false;
sendBroadcast(new Intent(Mode.BUFFERING_START));
//buffering
} else {
this.isPlaying = true;
Intent BroadcastIntent = new Intent(Mode.PLAYING);
BroadcastIntent.putExtra("url", this.streamingURL);
BroadcastIntent.putExtra("duration", bufCapacityMs / 1000);
BroadcastIntent.putExtra("progress", bufSizeMs / 1000);
sendBroadcast(BroadcastIntent);
//playing
}
} else {
//buffering
this.isPlaying = false;
sendBroadcast(new Intent(Mode.BUFFERING_START));
}
} and in eventReceiver.java: @Override
public void onReceive(Context context, Intent intent) {
WritableMap params = Arguments.createMap();
params.putString("status", intent.getAction());
if (intent.getAction().equals(Mode.METADATA_UPDATED)) {
params.putString("key", intent.getStringExtra("key"));
params.putString("value", intent.getStringExtra("value"));
}
if (intent.getAction().equals(Mode.PLAYING)) {
params.putString("url", intent.getStringExtra("url"));
params.putString("duration", intent.getStringExtra("duration"));
params.putString("progress", intent.getStringExtra("progress"));
}
this.module.sendEvent(this.module.getReactApplicationContextModule(), "AudioBridgeEvent", params);
} So far url works perfectly but I get null for both duration and progress. I'm pretty sure I'm not that far but I guess I need a bit more help. |
OKI. I was sending double and watching string. I'm openning a PR. |
The PR was rejected as the behaviour with progress was wrong. Basically it was not possible before we switch to a better android playing library. This is handled in #12 . So closing. |
Hey.
I'm instantiating a list of player on a react native page.
The goal is to display a list of question and let the user play the response of the question.
In peculiar if the user play a question, then click another question, it should stop the first and start the second.
When the user click on the question, onPress is called.
In ios this works fine because evt contain an url props (and also a duration that I ulse elsewhere but that is an other issue.
Is there a way on android to get the event current url ??
The text was updated successfully, but these errors were encountered: