Add support for handling Player.OnResume event through TCP
As detailed in https://github.com/xbmc/xbmc/pull/13726#issuecomment-378188082, Kodi will stop using the event Player.OnPlay when resuming a video, sending a Player.OnResume event instead. This PR handles that change.
This commit is contained in:
parent
d3dcb4eb82
commit
de683826ad
|
@ -384,14 +384,17 @@ public class HostConnectionObserver
|
||||||
chainCallGetActivePlayers();
|
chainCallGetActivePlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPause(org.xbmc.kore.jsonrpc.notification.Player.OnPause
|
public void onResume(org.xbmc.kore.jsonrpc.notification.Player.OnResume notification) {
|
||||||
notification) {
|
|
||||||
// Just start our chain calls
|
// Just start our chain calls
|
||||||
chainCallGetActivePlayers();
|
chainCallGetActivePlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSpeedChanged(org.xbmc.kore.jsonrpc.notification.Player
|
public void onPause(org.xbmc.kore.jsonrpc.notification.Player.OnPause notification) {
|
||||||
.OnSpeedChanged notification) {
|
// Just start our chain calls
|
||||||
|
chainCallGetActivePlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSpeedChanged(org.xbmc.kore.jsonrpc.notification.Player.OnSpeedChanged notification) {
|
||||||
// Just start our chain calls
|
// Just start our chain calls
|
||||||
chainCallGetActivePlayers();
|
chainCallGetActivePlayers();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,16 +54,25 @@ public abstract class ApiNotification {
|
||||||
ObjectNode params = (ObjectNode)node.get(PARAMS_NODE);
|
ObjectNode params = (ObjectNode)node.get(PARAMS_NODE);
|
||||||
|
|
||||||
ApiNotification result = null;
|
ApiNotification result = null;
|
||||||
if (method.equals(Player.OnPause.NOTIFICATION_NAME)) {
|
switch (method) {
|
||||||
|
case Player.OnPause.NOTIFICATION_NAME:
|
||||||
result = new Player.OnPause(params);
|
result = new Player.OnPause(params);
|
||||||
} else if (method.equals(Player.OnPlay.NOTIFICATION_NAME)) {
|
break;
|
||||||
|
case Player.OnPlay.NOTIFICATION_NAME:
|
||||||
result = new Player.OnPlay(params);
|
result = new Player.OnPlay(params);
|
||||||
} else if (method.equals(Player.OnSeek.NOTIFICATION_NAME)) {
|
break;
|
||||||
|
case Player.OnResume.NOTIFICATION_NAME:
|
||||||
|
result = new Player.OnResume(params);
|
||||||
|
break;
|
||||||
|
case Player.OnSeek.NOTIFICATION_NAME:
|
||||||
result = new Player.OnSeek(params);
|
result = new Player.OnSeek(params);
|
||||||
} else if (method.equals(Player.OnSpeedChanged.NOTIFICATION_NAME)) {
|
break;
|
||||||
|
case Player.OnSpeedChanged.NOTIFICATION_NAME:
|
||||||
result = new Player.OnSpeedChanged(params);
|
result = new Player.OnSpeedChanged(params);
|
||||||
} else if (method.equals(Player.OnStop.NOTIFICATION_NAME)) {
|
break;
|
||||||
|
case Player.OnStop.NOTIFICATION_NAME:
|
||||||
result = new Player.OnStop(params);
|
result = new Player.OnStop(params);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -70,32 +70,33 @@ public class HostConnection {
|
||||||
* Interface that an observer must implement to be notified of player notifications
|
* Interface that an observer must implement to be notified of player notifications
|
||||||
*/
|
*/
|
||||||
public interface PlayerNotificationsObserver {
|
public interface PlayerNotificationsObserver {
|
||||||
public void onPropertyChanged(Player.OnPropertyChanged notification);
|
void onPropertyChanged(Player.OnPropertyChanged notification);
|
||||||
public void onPlay(Player.OnPlay notification);
|
void onPlay(Player.OnPlay notification);
|
||||||
public void onPause(Player.OnPause notification);
|
void onResume(Player.OnResume notification);
|
||||||
public void onSpeedChanged(Player.OnSpeedChanged notification);
|
void onPause(Player.OnPause notification);
|
||||||
public void onSeek(Player.OnSeek notification);
|
void onSpeedChanged(Player.OnSpeedChanged notification);
|
||||||
public void onStop(Player.OnStop notification);
|
void onSeek(Player.OnSeek notification);
|
||||||
|
void onStop(Player.OnStop notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface that an observer must implement to be notified of System notifications
|
* Interface that an observer must implement to be notified of System notifications
|
||||||
*/
|
*/
|
||||||
public interface SystemNotificationsObserver {
|
public interface SystemNotificationsObserver {
|
||||||
public void onQuit(System.OnQuit notification);
|
void onQuit(System.OnQuit notification);
|
||||||
public void onRestart(System.OnRestart notification);
|
void onRestart(System.OnRestart notification);
|
||||||
public void onSleep(System.OnSleep notification);
|
void onSleep(System.OnSleep notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface that an observer must implement to be notified of Input notifications
|
* Interface that an observer must implement to be notified of Input notifications
|
||||||
*/
|
*/
|
||||||
public interface InputNotificationsObserver {
|
public interface InputNotificationsObserver {
|
||||||
public void onInputRequested(Input.OnInputRequested notification);
|
void onInputRequested(Input.OnInputRequested notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ApplicationNotificationsObserver {
|
public interface ApplicationNotificationsObserver {
|
||||||
public void onVolumeChanged(Application.OnVolumeChanged notification);
|
void onVolumeChanged(Application.OnVolumeChanged notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -728,6 +729,18 @@ public class HostConnection {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else if (notificationName.equals(Player.OnResume.NOTIFICATION_NAME)) {
|
||||||
|
final Player.OnResume apiNotification = new Player.OnResume(params);
|
||||||
|
for (final PlayerNotificationsObserver observer :
|
||||||
|
playerNotificationsObservers.keySet()) {
|
||||||
|
Handler handler = playerNotificationsObservers.get(observer);
|
||||||
|
postOrRunNow(handler, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
observer.onResume(apiNotification);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if (notificationName.equals(Player.OnSeek.NOTIFICATION_NAME)) {
|
} else if (notificationName.equals(Player.OnSeek.NOTIFICATION_NAME)) {
|
||||||
final Player.OnSeek apiNotification = new Player.OnSeek(params);
|
final Player.OnSeek apiNotification = new Player.OnSeek(params);
|
||||||
for (final PlayerNotificationsObserver observer :
|
for (final PlayerNotificationsObserver observer :
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
package org.xbmc.kore.jsonrpc.notification;
|
package org.xbmc.kore.jsonrpc.notification;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.node.BooleanNode;
|
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
import org.xbmc.kore.jsonrpc.ApiNotification;
|
import org.xbmc.kore.jsonrpc.ApiNotification;
|
||||||
import org.xbmc.kore.jsonrpc.type.GlobalType;
|
import org.xbmc.kore.jsonrpc.type.GlobalType;
|
||||||
import org.xbmc.kore.utils.JsonUtils;
|
import org.xbmc.kore.utils.JsonUtils;
|
||||||
|
@ -79,6 +79,23 @@ public class Player {
|
||||||
public String getNotificationName() { return NOTIFICATION_NAME; }
|
public String getNotificationName() { return NOTIFICATION_NAME; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Player.OnResume notification
|
||||||
|
* Playback of a media item has been resumed. If there is no ID available extra information will be provided.
|
||||||
|
*/
|
||||||
|
public static class OnResume extends ApiNotification {
|
||||||
|
public static final String NOTIFICATION_NAME = "Player.OnResume";
|
||||||
|
|
||||||
|
public final NotificationsData data;
|
||||||
|
|
||||||
|
public OnResume(ObjectNode node) {
|
||||||
|
super(node);
|
||||||
|
data = new NotificationsData(node.get(NotificationsData.DATA_NODE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNotificationName() { return NOTIFICATION_NAME; }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player.OnSeek notification
|
* Player.OnSeek notification
|
||||||
* The playback position has been changed. If there is no ID available extra information will
|
* The playback position has been changed. If there is no ID available extra information will
|
||||||
|
|
Loading…
Reference in New Issue