[freeboxos] Fix media playing (#17244)

Fix #17243

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
lolodomo 2024-08-13 20:23:06 +02:00 committed by Ciprian Pascu
parent 032ec127e6
commit 59207c9e0e
3 changed files with 12 additions and 5 deletions

View File

@ -54,8 +54,11 @@ public class MediaReceiverManager extends ListableRest<Receiver, MediaReceiverMa
UNKNOWN
}
private static record Request(String password, Action action, MediaType mediaType, @Nullable String media,
private static record Request(String password, String action, String mediaType, @Nullable String media,
int position) {
Request(String password, Action action, MediaType mediaType, @Nullable String media, int position) {
this(password, action.name().toLowerCase(), mediaType.name().toLowerCase(), media, position);
}
}
public MediaReceiverManager(FreeboxOsSession session, UriBuilder uriBuilder) throws FreeboxException {
@ -77,6 +80,6 @@ public class MediaReceiverManager extends ListableRest<Receiver, MediaReceiverMa
}
private void sendToReceiver(String receiver, Request payload) throws FreeboxException {
post(payload, GenericResponse.class, receiver);
post(payload, receiver);
}
}

View File

@ -20,6 +20,7 @@ import java.util.List;
import javax.ws.rs.core.UriBuilder;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.freeboxos.internal.api.FreeboxException;
import org.openhab.binding.freeboxos.internal.api.PermissionException;
import org.openhab.binding.freeboxos.internal.api.Response;
@ -83,7 +84,11 @@ public class RestManager {
}
protected void post(String... pathElements) throws FreeboxException {
session.execute(buildUri(pathElements), POST, GenericResponse.class, null);
post(null, pathElements);
}
protected <F> void post(@Nullable F payload, String... pathElements) throws FreeboxException {
session.execute(buildUri(pathElements), POST, GenericResponse.class, payload);
}
protected <F, T extends Response<F>> F put(Class<T> clazz, F payload, String... pathElements)

View File

@ -118,8 +118,7 @@ public abstract class ApiConsumerHandler extends BaseThingHandler implements Api
private void startAudioSink(Receiver receiver) {
FreeboxOsHandler bridgeHandler = checkBridgeHandler();
// Only video and photo is supported by the API so use VIDEO capability for audio
Boolean isAudioReceiver = receiver.capabilities().get(MediaType.VIDEO);
if (reg == null && bridgeHandler != null && isAudioReceiver != null && isAudioReceiver.booleanValue()) {
if (reg == null && bridgeHandler != null && Boolean.TRUE.equals(receiver.capabilities().get(MediaType.VIDEO))) {
ApiConsumerConfiguration config = getConfig().as(ApiConsumerConfiguration.class);
String callbackURL = bridgeHandler.getCallbackURL();
if (!config.password.isEmpty() || !receiver.passwordProtected()) {