]> git.basschouten.com Git - openhab-addons.git/blob
f4b5f1579344dbb1b485baf2a5917703ca2fcea5
[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.omnilink.internal;
14
15 import java.util.Arrays;
16 import java.util.Optional;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19
20 /**
21  * The {@link AudioPlayer} defines some methods that are used to
22  * interface with an OmniLink Audio Player.
23  *
24  * @author Brian O'Connell - Initial contribution
25  */
26 @NonNullByDefault
27 public enum AudioPlayer {
28     NUVO(1, 6, 8, 7, 9, 10),
29     NUVO_GRAND_ESSENTIA_SIMPLESE(2, 6, 8, 7, 9, 10),
30     NUVO_GRAND_GRAND_CONCERTO(3, 6, 6, 6, 9, 10),
31     RUSSOUND(4, 6, 8, 7, 11, 12),
32     XANTECH(6, 13, 15, 14, 16, 17),
33     SPEAKERCRAFT(7, 45, 44, 46, 42, 43),
34     PROFICIENT(8, 45, 44, 46, 42, 43);
35
36     private final int featureCode;
37     private final int playCommand;
38     private final int pauseCommand;
39     private final int stopCommand;
40     private final int previousCommand;
41     private final int nextCommand;
42
43     AudioPlayer(int featureCode, int playCommand, int pauseCommand, int stopCommand, int previousCommand,
44             int nextCommand) {
45         this.featureCode = featureCode;
46         this.playCommand = playCommand;
47         this.pauseCommand = pauseCommand;
48         this.stopCommand = stopCommand;
49         this.previousCommand = previousCommand;
50         this.nextCommand = nextCommand;
51     }
52
53     public int getPlayCommand() {
54         return playCommand;
55     }
56
57     public int getPauseCommand() {
58         return pauseCommand;
59     }
60
61     public int getStopCommand() {
62         return stopCommand;
63     }
64
65     public int getPreviousCommand() {
66         return previousCommand;
67     }
68
69     public int getNextCommand() {
70         return nextCommand;
71     }
72
73     public static Optional<AudioPlayer> getAudioPlayerForFeatureCode(int featureCode) {
74         return Arrays.stream(values()).filter(v -> v.featureCode == featureCode).findAny();
75     }
76 }