Skip to content
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

Removed Android service #903

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,5 @@
package="com.guichaguri.trackplayer">

<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application>

<!-- The main service, handles playback, playlists and media buttons -->
<service android:name=".service.MusicService" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</service>

<!-- A receiver that will receive media buttons. Required on pre-lollipop devices -->
<receiver android:name="androidx.media.session.MediaButtonReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.guichaguri.trackplayer;

import androidx.annotation.NonNull;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
Expand All @@ -16,12 +17,14 @@
public class TrackPlayer implements ReactPackage {

@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
@NonNull
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
return Collections.singletonList(new MusicModule(reactContext));
}

@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
@NonNull
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
package com.guichaguri.trackplayer.module;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;

/**
* @author Guichaguri
*/
public class MusicEvents extends BroadcastReceiver {
public final class MusicEvents {

// Media Control Events
public static final String BUTTON_PLAY = "remote-play";
Expand All @@ -36,20 +27,4 @@ public class MusicEvents extends BroadcastReceiver {
public static final String PLAYBACK_METADATA = "playback-metadata-received";
public static final String PLAYBACK_ERROR = "playback-error";

private final ReactContext reactContext;

public MusicEvents(ReactContext reactContext) {
this.reactContext = reactContext;
}

@Override
public void onReceive(Context context, Intent intent) {
String event = intent.getStringExtra("event");
Bundle data = intent.getBundleExtra("data");

WritableMap map = data != null ? Arguments.fromBundle(data) : null;

reactContext.getJSModule(RCTDeviceEventEmitter.class).emit(event, map);
}

}
Loading