Skip to content

Commit

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

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo committed Aug 13, 2024
1 parent 1b23f2b commit 9bff92b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ 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) {
}

Expand All @@ -68,15 +68,16 @@ public MediaReceiverManager(FreeboxOsSession session, UriBuilder uriBuilder) thr

public void sendToReceiver(String receiver, String password, Action action, MediaType type)
throws FreeboxException {
sendToReceiver(receiver, new Request(password, action, type, null, 0));
sendToReceiver(receiver,
new Request(password, action.name().toLowerCase(), type.name().toLowerCase(), null, 0));
}

public void sendToReceiver(String receiver, String password, Action action, MediaType type, String url)
throws FreeboxException {
sendToReceiver(receiver, new Request(password, action, type, url, 0));
sendToReceiver(receiver, new Request(password, action.name().toLowerCase(), type.name().toLowerCase(), url, 0));
}

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

0 comments on commit 9bff92b

Please sign in to comment.