Skip to content

Commit 16fab63

Browse files
authored
Merge pull request #356 from smartdevicelink/feature/0198-media-skip-indicators
Add new API to SetMediaClockTimer
2 parents 0c79267 + ea6b478 commit 16fab63

3 files changed

Lines changed: 236 additions & 2 deletions

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/* eslint-disable camelcase */
2+
/*
3+
* Copyright (c) 2021, SmartDeviceLink Consortium, Inc.
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* Redistributions of source code must retain the above copyright notice, this
10+
* list of conditions and the following disclaimer.
11+
*
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following
14+
* disclaimer in the documentation and/or other materials provided with the
15+
* distribution.
16+
*
17+
* Neither the name of the SmartDeviceLink Consortium Inc. nor the names of
18+
* its contributors may be used to endorse or promote products derived
19+
* from this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
* POSSIBILITY OF SUCH DAMAGE.
32+
*/
33+
34+
import { Enum } from '../../util/Enum.js';
35+
36+
/**
37+
* @typedef {Enum} SeekIndicatorType
38+
* @property {Object} _MAP
39+
*/
40+
class SeekIndicatorType extends Enum {
41+
/**
42+
* Constructor for SeekIndicatorType.
43+
* @class
44+
* @since SmartDeviceLink 7.1.0
45+
*/
46+
constructor () {
47+
super();
48+
}
49+
50+
/**
51+
* Get the enum value for TRACK.
52+
* @returns {String} - The enum value.
53+
*/
54+
static get TRACK () {
55+
return SeekIndicatorType._MAP.TRACK;
56+
}
57+
58+
/**
59+
* Get the enum value for TIME.
60+
* @returns {String} - The enum value.
61+
*/
62+
static get TIME () {
63+
return SeekIndicatorType._MAP.TIME;
64+
}
65+
66+
/**
67+
* Get the value for the given enum key
68+
* @param {*} key - A key to find in the map of the subclass
69+
* @returns {*} - Returns a value if found, or null if not found
70+
*/
71+
static valueForKey (key) {
72+
return SeekIndicatorType._valueForKey(key, SeekIndicatorType._MAP);
73+
}
74+
75+
/**
76+
* Get the key for the given enum value
77+
* @param {*} value - A primitive value to find the matching key for in the map of the subclass
78+
* @returns {*} - Returns a key if found, or null if not found
79+
*/
80+
static keyForValue (value) {
81+
return SeekIndicatorType._keyForValue(value, SeekIndicatorType._MAP);
82+
}
83+
84+
/**
85+
* Retrieve all enumerated values for this class
86+
* @returns {*} - Returns an array of values
87+
*/
88+
static values () {
89+
return Object.values(SeekIndicatorType._MAP);
90+
}
91+
}
92+
93+
SeekIndicatorType._MAP = Object.freeze({
94+
'TRACK': 'TRACK',
95+
'TIME': 'TIME',
96+
});
97+
98+
export { SeekIndicatorType };

lib/js/src/rpc/messages/SetMediaClockTimer.js

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable camelcase */
22
/*
3-
* Copyright (c) 2020, SmartDeviceLink Consortium, Inc.
3+
* Copyright (c) 2021, SmartDeviceLink Consortium, Inc.
44
* All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,7 @@
3434
import { AudioStreamingIndicator } from '../enums/AudioStreamingIndicator.js';
3535
import { FunctionID } from '../enums/FunctionID.js';
3636
import { RpcRequest } from '../RpcRequest.js';
37+
import { SeekStreamingIndicator } from '../structs/SeekStreamingIndicator.js';
3738
import { StartTime } from '../structs/StartTime.js';
3839
import { UpdateMode } from '../enums/UpdateMode.js';
3940

@@ -130,11 +131,51 @@ class SetMediaClockTimer extends RpcRequest {
130131
return this.getObject(AudioStreamingIndicator, SetMediaClockTimer.KEY_AUDIO_STREAMING_INDICATOR);
131132
}
132133

134+
/**
135+
* Set the ForwardSeekIndicator
136+
* @since SmartDeviceLink 7.1.0
137+
* @param {SeekStreamingIndicator} indicator - Used to control the forward seek button to either skip forward a set amount of time or to the next track. - The desired ForwardSeekIndicator.
138+
* @returns {SetMediaClockTimer} - The class instance for method chaining.
139+
*/
140+
setForwardSeekIndicator (indicator) {
141+
this._validateType(SeekStreamingIndicator, indicator);
142+
this.setParameter(SetMediaClockTimer.KEY_FORWARD_SEEK_INDICATOR, indicator);
143+
return this;
144+
}
145+
146+
/**
147+
* Get the ForwardSeekIndicator
148+
* @returns {SeekStreamingIndicator} - the KEY_FORWARD_SEEK_INDICATOR value
149+
*/
150+
getForwardSeekIndicator () {
151+
return this.getObject(SeekStreamingIndicator, SetMediaClockTimer.KEY_FORWARD_SEEK_INDICATOR);
152+
}
153+
154+
/**
155+
* Set the BackSeekIndicator
156+
* @since SmartDeviceLink 7.1.0
157+
* @param {SeekStreamingIndicator} indicator - Used to control the back seek button to either skip back a set amount of time or to the previous track. - The desired BackSeekIndicator.
158+
* @returns {SetMediaClockTimer} - The class instance for method chaining.
159+
*/
160+
setBackSeekIndicator (indicator) {
161+
this._validateType(SeekStreamingIndicator, indicator);
162+
this.setParameter(SetMediaClockTimer.KEY_BACK_SEEK_INDICATOR, indicator);
163+
return this;
164+
}
165+
166+
/**
167+
* Get the BackSeekIndicator
168+
* @returns {SeekStreamingIndicator} - the KEY_BACK_SEEK_INDICATOR value
169+
*/
170+
getBackSeekIndicator () {
171+
return this.getObject(SeekStreamingIndicator, SetMediaClockTimer.KEY_BACK_SEEK_INDICATOR);
172+
}
173+
133174
/**
134175
* Set the CountRate
135176
* @since SmartDeviceLink 7.1.0
136177
* @param {Number} rate - The value of this parameter is the amount that the media clock timer will advance per 1.0 seconds of real time. Values less than 1.0 will therefore advance the timer slower than real-time, while values greater than 1.0 will advance the timer faster than real-time. e.g. If this parameter is set to `0.5`, the timer will advance one second per two seconds real-time, or at 50% speed. If this parameter is set to `2.0`, the timer will advance two seconds per one second real-time, or at 200% speed. - The desired CountRate.
137-
* {'num_min_value': 0.1, 'num_max_value': 100.0}
178+
* {'default_value': 1.0, 'num_min_value': 0.1, 'num_max_value': 100.0}
138179
* @returns {SetMediaClockTimer} - The class instance for method chaining.
139180
*/
140181
setCountRate (rate) {
@@ -155,6 +196,8 @@ SetMediaClockTimer.KEY_START_TIME = 'startTime';
155196
SetMediaClockTimer.KEY_END_TIME = 'endTime';
156197
SetMediaClockTimer.KEY_UPDATE_MODE = 'updateMode';
157198
SetMediaClockTimer.KEY_AUDIO_STREAMING_INDICATOR = 'audioStreamingIndicator';
199+
SetMediaClockTimer.KEY_FORWARD_SEEK_INDICATOR = 'forwardSeekIndicator';
200+
SetMediaClockTimer.KEY_BACK_SEEK_INDICATOR = 'backSeekIndicator';
158201
SetMediaClockTimer.KEY_COUNT_RATE = 'countRate';
159202

160203
export { SetMediaClockTimer };
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/* eslint-disable camelcase */
2+
/*
3+
* Copyright (c) 2021, SmartDeviceLink Consortium, Inc.
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* Redistributions of source code must retain the above copyright notice, this
10+
* list of conditions and the following disclaimer.
11+
*
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following
14+
* disclaimer in the documentation and/or other materials provided with the
15+
* distribution.
16+
*
17+
* Neither the name of the SmartDeviceLink Consortium Inc. nor the names of
18+
* its contributors may be used to endorse or promote products derived
19+
* from this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
* POSSIBILITY OF SUCH DAMAGE.
32+
*/
33+
34+
import { RpcStruct } from '../RpcStruct.js';
35+
import { SeekIndicatorType } from '../enums/SeekIndicatorType.js';
36+
37+
/**
38+
* The seek next / skip previous subscription buttons' content
39+
*/
40+
class SeekStreamingIndicator extends RpcStruct {
41+
/**
42+
* Initalizes an instance of SeekStreamingIndicator.
43+
* @class
44+
* @param {object} parameters - An object map of parameters.
45+
* @since SmartDeviceLink 7.1.0
46+
*/
47+
constructor (parameters) {
48+
super(parameters);
49+
}
50+
51+
/**
52+
* Set the Type
53+
* @param {SeekIndicatorType} type - The desired Type.
54+
* @returns {SeekStreamingIndicator} - The class instance for method chaining.
55+
*/
56+
setType (type) {
57+
this._validateType(SeekIndicatorType, type);
58+
this.setParameter(SeekStreamingIndicator.KEY_TYPE, type);
59+
return this;
60+
}
61+
62+
/**
63+
* Get the Type
64+
* @returns {SeekIndicatorType} - the KEY_TYPE value
65+
*/
66+
getType () {
67+
return this.getObject(SeekIndicatorType, SeekStreamingIndicator.KEY_TYPE);
68+
}
69+
70+
/**
71+
* Set the SeekTime
72+
* @param {Number} time - If the type is TIME, this number of seconds may be present alongside the skip indicator. It will indicate the number of seconds that the currently playing media will skip forward or backward. - The desired SeekTime.
73+
* {'num_min_value': 1, 'num_max_value': 99}
74+
* @returns {SeekStreamingIndicator} - The class instance for method chaining.
75+
*/
76+
setSeekTime (time) {
77+
this.setParameter(SeekStreamingIndicator.KEY_SEEK_TIME, time);
78+
return this;
79+
}
80+
81+
/**
82+
* Get the SeekTime
83+
* @returns {Number} - the KEY_SEEK_TIME value
84+
*/
85+
getSeekTime () {
86+
return this.getParameter(SeekStreamingIndicator.KEY_SEEK_TIME);
87+
}
88+
}
89+
90+
SeekStreamingIndicator.KEY_TYPE = 'type';
91+
SeekStreamingIndicator.KEY_SEEK_TIME = 'seekTime';
92+
93+
export { SeekStreamingIndicator };

0 commit comments

Comments
 (0)