Skip to content

Commit 070f149

Browse files
committed
Created SupportedMediaCommand and updated documentation links for Media and MediaStatus
1 parent 45bcb91 commit 070f149

3 files changed

Lines changed: 131 additions & 4 deletions

File tree

src/main/java/org/digitalmediaserver/cast/message/entity/Media.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@
4040
* Represents the media information.
4141
*
4242
* @see <a href=
43-
* "https://developers.google.com/cast/docs/reference/receiver/cast.receiver.media.MediaInformation">
44-
* https://developers.google.com/cast/docs/reference/receiver/cast.receiver.media.MediaInformation</a>
43+
* "https://web.archive.org/web/20170321153824/https://developers.google.com/cast/docs/reference/receiver/cast.receiver.media.MediaInformation">
44+
* Original definition</a>
45+
* @see <a href=
46+
* "https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.MediaInformation">
47+
* Updated definition</a>
4548
*/
4649
@Immutable
4750
public class Media {

src/main/java/org/digitalmediaserver/cast/message/entity/MediaStatus.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.digitalmediaserver.cast.message.enumeration.IdleReason;
3030
import org.digitalmediaserver.cast.message.enumeration.PlayerState;
3131
import org.digitalmediaserver.cast.message.enumeration.RepeatMode;
32+
import org.digitalmediaserver.cast.message.enumeration.SupportedMediaCommand;
3233
import org.digitalmediaserver.cast.util.Util;
3334

3435

@@ -37,8 +38,11 @@
3738
* etc.
3839
*
3940
* @see <a href=
40-
* "https://developers.google.com/cast/docs/reference/receiver/cast.receiver.media.MediaStatus">
41-
* https://developers.google.com/cast/docs/reference/receiver/cast.receiver.media.MediaStatus</a>
41+
* "https://web.archive.org/web/20170321214906/https://developers.google.com/cast/docs/reference/receiver/cast.receiver.media.MediaStatus">
42+
* Original definition</a>
43+
* @see <a href=
44+
* "https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.MediaStatus">
45+
* Updated definition</a>
4246
*/
4347
@Immutable
4448
public class MediaStatus {
@@ -385,6 +389,10 @@ public RepeatMode getRepeatMode() {
385389
}
386390

387391
/**
392+
* The sum of the codes for the various supported commends. Use
393+
* {@link SupportedMediaCommand#parseCommands(int)} to convert this value
394+
* into a set of {@link SupportedMediaCommand}s.
395+
*
388396
* @return The commands supported by this player.
389397
*/
390398
public int getSupportedMediaCommands() {
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright (C) 2025 Digital Media Server developers.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.digitalmediaserver.cast.message.enumeration;
17+
18+
import java.util.EnumSet;
19+
import javax.annotation.Nonnull;
20+
21+
22+
/**
23+
* Represents the {@code kSupportedMediaCommandXxx} constants, and offers a
24+
* static method to convert a given combined value into a set of
25+
* {@link SupportedMediaCommand}s.
26+
*/
27+
public enum SupportedMediaCommand {
28+
29+
/** {@code kSupportedMediaCommandPause} */
30+
PAUSE(1 << 0),
31+
32+
/** {@code kSupportedMediaCommandSeek} */
33+
SEEK(1 << 1),
34+
35+
/** {@code kSupportedMediaCommandStreamVolume} */
36+
STREAM_VOLUME(1 << 2),
37+
38+
/** {@code kSupportedMediaCommandStreamMute} */
39+
STREAM_MUTE(1 << 3),
40+
41+
/** {@code kSupportedMediaCommandSkipForward} */
42+
SKIP_FORWARD(1 << 4),
43+
44+
/** {@code kSupportedMediaCommandSkipBackward} */
45+
SKIP_BACKWARD(1 << 5),
46+
47+
/** {@code kSupportedMediaCommandQueueNext} */
48+
QUEUE_NEXT(1 << 6),
49+
50+
/** {@code kSupportedMediaCommandQueuePrev} */
51+
QUEUE_PREV(1 << 7),
52+
53+
/** {@code kSupportedMediaCommandQueueShuffle} */
54+
QUEUE_SHUFFLE(1 << 8),
55+
56+
/** {@code kSupportedMediaCommandSkipAd} */
57+
SKIP_AD(1 << 9),
58+
59+
/** {@code kSupportedMediaCommandQueueRepeatAll} */
60+
QUEUE_REPEAT_ALL(1 << 10),
61+
62+
/** {@code kSupportedMediaCommandQueueRepeatOne} */
63+
QUEUE_REPEAT_ONE(1 << 11),
64+
65+
/** {@code kSupportedMediaCommandEditTracks} */
66+
EDIT_TRACKS(1 << 12),
67+
68+
/** {@code kSupportedMediaCommandPlaybackRate} */
69+
PLAYBACK_RATE(1 << 13),
70+
71+
/** {@code kSupportedMediaCommandLike} */
72+
LIKE(1 << 14),
73+
74+
/** {@code kSupportedMediaCommandDislike} */
75+
DISLIKE(1 << 15),
76+
77+
/** {@code kSupportedMediaCommandFollow} */
78+
FOLLOW(1 << 16),
79+
80+
/** {@code kSupportedMediaCommandUnfollow} */
81+
UNFOLLOW(1 << 17),
82+
83+
/** {@code kSupportedMediaCommandStreamTransfer} */
84+
STREAM_TRANSFER(1 << 18);
85+
86+
private int code;
87+
88+
private SupportedMediaCommand(int code) {
89+
this.code = code;
90+
}
91+
92+
/**
93+
* @return The integer value assigned to this {@link SupportedMediaCommand}.
94+
*/
95+
public int getCode() {
96+
return code;
97+
}
98+
99+
/**
100+
* Parses a combined integer value into its individual components and
101+
* returns a set of corresponding {@link SupportedMediaCommand}.
102+
*
103+
* @param value the combined value.
104+
* @return The {@link EnumSet} of {@link SupportedMediaCommand}s.
105+
*/
106+
@Nonnull
107+
public static EnumSet<SupportedMediaCommand> parseCommands(int value) {
108+
EnumSet<SupportedMediaCommand> result = EnumSet.noneOf(SupportedMediaCommand.class);
109+
for (SupportedMediaCommand command : values()) {
110+
if ((value & command.code) != 0) {
111+
result.add(command);
112+
}
113+
}
114+
return result;
115+
}
116+
}

0 commit comments

Comments
 (0)