Package com.castlabs.android.player
Class PlayerService.Binder
java.lang.Object
android.os.Binder
com.castlabs.android.player.PlayerService.Binder
- All Implemented Interfaces:
- IBinder
- Enclosing class:
- PlayerService
This is the binder that will be returned by when a service connection is bound to the
 player service.
- 
Nested Class SummaryNested classes/interfaces inherited from interface android.os.IBinderIBinder.DeathRecipient
- 
Field SummaryFields inherited from interface android.os.IBinderDUMP_TRANSACTION, FIRST_CALL_TRANSACTION, FLAG_ONEWAY, INTERFACE_TRANSACTION, LAST_CALL_TRANSACTION, LIKE_TRANSACTION, PING_TRANSACTION, TWEET_TRANSACTION
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleaninit(IPlayerView view) Initialises the service binder and eventually restores the PlayerController from the background.voidkillBackgroundPlayer(boolean removeNotification) Utility method that can be used to dispose an existing background player without connecting aPlayerView.voidrelease(IPlayerView playerView, boolean callDelegate) Disconnects the player controller from the player view.voidreleaseToBackground(IPlayerView playerView, int notificationId, Notification notification, boolean callDelegate) Disconnect the player controller from the player view and enable background audio playback by putting the service into foreground and showing the given notification.voidreleaseToBackground(IPlayerView playerView, int notificationId, Notification notification, boolean callDelegate, PlayerService.NotificationHandler notificationHandler) Disconnect the player controller from the player view and enable background audio playback by putting the service into foreground and showing the given notification.Methods inherited from class android.os.BinderattachInterface, clearCallingIdentity, clearCallingWorkSource, dump, dumpAsync, flushPendingCommands, getCallingPid, getCallingUid, getCallingUidOrThrow, getCallingUserHandle, getCallingWorkSourceUid, getInterfaceDescriptor, isBinderAlive, joinThreadPool, linkToDeath, pingBinder, queryLocalInterface, restoreCallingIdentity, restoreCallingWorkSource, setCallingWorkSourceUid, transact, unlinkToDeath
- 
Constructor Details- 
Binderpublic Binder()
 
- 
- 
Method Details- 
initInitialises the service binder and eventually restores the PlayerController from the background. You need to call this method when the service connection is established. The passed PlayerView will the correctly initialised and loaded PlayerController after this call. Note to ensure that recovering playback from a background controller, please make sure that you are not interacting with the views controller before this method is called. This call might reset the views player controller. After calling this method, you can callPlayerView.getPlayerController()to get a reference to a current controller. Please also note that this method does recover the player controller from a background playback session, but it does not automatically resume or open a stream if no background session was found. If a call to this method returnsfalse, you might want to either use the lifecycle delegate of the player view (seePlayerView.getLifecycleDelegate()) and callPlayerViewLifecycleDelegate.resume()to resume an existing session or callPlayerController.open(Bundle)to open a new session.- Parameters:
- view- The player view
- Returns:
- True if the player controller was restored from a background controller
 
- 
releaseDisconnects the player controller from the player view. IfcallDelegateis set totrue, the views lifecycle delegate (seePlayerView.getLifecycleDelegate())PlayerViewLifecycleDelegate.releasePlayer(boolean)will be called to fully release the controller (no background playback).- Parameters:
- playerView- The player view
- callDelegate- If- true,- PlayerViewLifecycleDelegate.releasePlayer(boolean)will be called
 
- 
releaseToBackgroundpublic void releaseToBackground(@NonNull IPlayerView playerView, int notificationId, @NonNull Notification notification, boolean callDelegate) Disconnect the player controller from the player view and enable background audio playback by putting the service into foreground and showing the given notification. IfcallDelegateis set totrue, the views lifecycle delegate (seePlayerView.getLifecycleDelegate())PlayerViewLifecycleDelegate.releasePlayer(boolean)will be called to fully release the controller (no background playback).- Parameters:
- playerView- The player view
- notificationId- The notification ID (see- Service.startForeground(int, Notification))
- notification- The notification (see- Service.startForeground(int, Notification))
- callDelegate- If- true,- PlayerViewLifecycleDelegate.releasePlayer(boolean)will be called
 
- 
releaseToBackgroundpublic void releaseToBackground(@NonNull IPlayerView playerView, int notificationId, @NonNull Notification notification, boolean callDelegate, @Nullable PlayerService.NotificationHandler notificationHandler) Disconnect the player controller from the player view and enable background audio playback by putting the service into foreground and showing the given notification. IfcallDelegateis set totrue, the views lifecycle delegate (seePlayerView.getLifecycleDelegate())PlayerViewLifecycleDelegate.releasePlayer(boolean)will be called to fully release the controller (no background playback).- Parameters:
- playerView- The player view
- notificationId- The notification ID (see- Service.startForeground(int, Notification))
- notification- The notification (see- Service.startForeground(int, Notification))
- callDelegate- If- true,- PlayerViewLifecycleDelegate.releasePlayer(boolean)will be called
- notificationHandler- Implementation of- PlayerService.NotificationHandleror- null
 
- 
killBackgroundPlayerpublic void killBackgroundPlayer(boolean removeNotification) Utility method that can be used to dispose an existing background player without connecting aPlayerView. This method can be used for example to remove the background player by clicking a button in the notification. This will dispose the background player, remove the service from the foreground, and remove the notification based on the passed parameter.- Parameters:
- removeNotification- if- true, the notification will be removed
 
 
-