]> git.basschouten.com Git - openhab-addons.git/blob
3613c79a646e18e46aefd4d48de557a337745b63
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.lgwebos.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.lgwebos.internal.handler.LGWebOSHandler;
17 import org.openhab.binding.lgwebos.internal.handler.core.CommandConfirmation;
18 import org.openhab.core.library.types.PlayPauseType;
19 import org.openhab.core.library.types.RewindFastforwardType;
20 import org.openhab.core.types.Command;
21 import org.openhab.core.types.RefreshType;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 /**
26  * Handles commands of a Player Item.
27  *
28  *
29  * @author Sebastian Prehn - Initial contribution
30  */
31 @NonNullByDefault
32 public class MediaControlPlayer extends BaseChannelHandler<CommandConfirmation> {
33     private final Logger logger = LoggerFactory.getLogger(MediaControlPlayer.class);
34
35     @Override
36     public void onReceiveCommand(String channelId, LGWebOSHandler handler, Command command) {
37         if (RefreshType.REFRESH == command) {
38             // nothing to do
39         } else if (PlayPauseType.PLAY == command) {
40             handler.getSocket().play(getDefaultResponseListener());
41         } else if (PlayPauseType.PAUSE == command) {
42             handler.getSocket().pause(getDefaultResponseListener());
43         } else if (RewindFastforwardType.FASTFORWARD == command) {
44             handler.getSocket().fastForward(getDefaultResponseListener());
45         } else if (RewindFastforwardType.REWIND == command) {
46             handler.getSocket().rewind(getDefaultResponseListener());
47         } else {
48             logger.info("Only accept PlayPauseType, RewindFastforwardType, RefreshType. Type was {}.",
49                     command.getClass());
50         }
51     }
52
53     // TODO: playstatesubscription
54 }