Skip to content

Commit

Permalink
[freeboxos] Fix media playing (openhab#17244)
Browse files Browse the repository at this point in the history
Fix openhab#17243

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo authored and matchews committed Oct 18, 2024
1 parent c2a1268 commit 0a88337
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ public enum MediaType {
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 {
Expand All @@ -77,6 +80,6 @@ public void sendToReceiver(String receiver, String password, Action action, Medi
}

private void sendToReceiver(String receiver, Request payload) throws FreeboxException {
post(payload, GenericResponse.class, receiver);
post(payload, receiver);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand Down Expand Up @@ -83,7 +84,11 @@ protected <F, T extends Response<F>> F post(Object payload, Class<T> clazz, Stri
}

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ protected void configureMediaSink() {
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()) {
Expand Down

0 comments on commit 0a88337

Please sign in to comment.