Skip to content

Commit 377f6a3

Browse files
'additional scene item methods'
1 parent 30d652e commit 377f6a3

File tree

13 files changed

+382
-46
lines changed

13 files changed

+382
-46
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## 5.0.0+13
4+
5+
* scene items
6+
* GetSceneItemLocked
7+
* SetSceneItemLocked
8+
* cli
9+
* scene items
10+
* GetSceneItemList
11+
* GetSceneItemLocked
12+
* SetSceneItemLocked
13+
* tests
14+
* scene items
15+
* GetSceneItemList
16+
* GetSceneItemLocked
17+
* SetSceneItemLocked
18+
319
## 5.0.0+12
420

521
* dependency bumps

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ In your project add the dependency:
4545
```yml
4646
dependencies:
4747
...
48-
obs_websocket: ^5.0.0+12
48+
obs_websocket: ^5.0.0+13
4949
```
5050
5151
For help getting started with dart, check out these [guides](https://dart.dev/guides).
@@ -202,8 +202,8 @@ For any of the items that have an [x] from the list below, a high level helper c
202202
- [ ] [SetSceneItemTransform](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#setsceneitemtransform)
203203
- [x] [GetSceneItemEnabled](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#getsceneitemenabled) - Gets the enable state of a scene item.
204204
- [x] [SetSceneItemEnabled](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#setsceneitemenabled) - Sets the enable state of a scene item.
205-
- [ ] [GetSceneItemLocked](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#getsceneitemlocked)
206-
- [ ] [SetSceneItemLocked](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#setsceneitemlocked)
205+
- [x] [GetSceneItemLocked](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#getsceneitemlocked) - Gets the lock state of a scene item.
206+
- [x] [SetSceneItemLocked](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#setsceneitemlocked) - Sets the lock state of a scene item.
207207
- [x] [GetSceneItemIndex](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#getsceneitemindex) - Gets the index position of a scene item in a scene.
208208
- [x] [SetSceneItemIndex](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#setsceneitemindex) - Sets the index position of a scene item in a scene.
209209
- [ ] [GetSceneItemBlendMode](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#getsceneitemblendmode)
@@ -515,13 +515,14 @@ Global options:
515515
-p, --passwd=<string> The OBS websocket password, only required if enabled in OBS
516516
517517
Available commands:
518-
authorize Generate an authentication file for an OBS connection
519-
config Config Requests
520-
general General commands
521-
listen Generate OBS events to stdout
522-
send Send a low-level websocket request to OBS
523-
sources Commands that manipulate OBS sources
524-
stream Commands that manipulate OBS streams
525-
ui Commands that manipulate the OBS user interface.
526-
version Display the package name and version
518+
authorize Generate an authentication file for an OBS connection
519+
config Config Requests
520+
general General commands
521+
listen Generate OBS events to stdout
522+
scene-items Scene Items Requests
523+
send Send a low-level websocket request to OBS
524+
sources Commands that manipulate OBS sources
525+
stream Commands that manipulate OBS streams
526+
ui Commands that manipulate the OBS user interface.
527+
version Display the package name and version
527528
```

bin/README.md

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,16 @@ Global options:
7575
-p, --passwd=<string> The OBS websocket password, only required if enabled in OBS
7676
7777
Available commands:
78-
authorize Generate an authentication file for an OBS connection
79-
config Config Requests
80-
general General commands
81-
listen Generate OBS events to stdout
82-
send Send a low-level websocket request to OBS
83-
sources Commands that manipulate OBS sources
84-
stream Commands that manipulate OBS streaming
85-
version Display the package name version
78+
authorize Generate an authentication file for an OBS connection
79+
config Config Requests
80+
general General commands
81+
listen Generate OBS events to stdout
82+
scene-items Scene Items Requests
83+
send Send a low-level websocket request to OBS
84+
sources Commands that manipulate OBS sources
85+
stream Commands that manipulate OBS streams
86+
ui Commands that manipulate the OBS user interface.
87+
version Display the package name and version
8688
```
8789

8890
| command | description |
@@ -309,6 +311,69 @@ Usage: obs listen [arguments]
309311
[vendors] Subscription value to receive the VendorEvent event.
310312
```
311313

314+
### scene-items
315+
316+
```sh
317+
obs scene-items --help
318+
```
319+
320+
```text
321+
Scene Items Requests
322+
323+
Usage: obs scene-items <subcommand> [arguments]
324+
-h, --help Print this usage information.
325+
326+
Available subcommands:
327+
get-scene-item-list Gets the lock state of a scene item.
328+
get-scene-item-locked Gets the lock state of a scene item.
329+
set-scene-item-locked Sets the lock state of a scene item.
330+
```
331+
332+
## scene-items get-scene-item-list
333+
334+
```sh
335+
obs scene-items get-scene-item-list --help
336+
```
337+
338+
```text
339+
Gets a list of all scene items in a scene.
340+
341+
Usage: obs scene-items get-scene-item-list [arguments]
342+
-h, --help Print this usage information.
343+
-n, --scene-name=<string> (mandatory) Name of the scene to get the items of
344+
```
345+
346+
## scene-items get-scene-item-locked
347+
348+
```sh
349+
obs scene-items get-scene-item-locked --help
350+
```
351+
352+
```text
353+
Gets the lock state of a scene item.
354+
355+
Usage: obs scene-items get-scene-item-locked [arguments]
356+
-h, --help Print this usage information.
357+
-n, --scene-name=<string> (mandatory) Name of the scene the item is in
358+
-i, --scene-item-id=<int> (mandatory) Numeric ID of the scene item
359+
```
360+
361+
## scene-items set-scene-item-locked
362+
363+
```sh
364+
obs scene-items set-scene-item-locked --help
365+
```
366+
367+
```text
368+
Sets the lock state of a scene item.
369+
370+
Usage: obs scene-items set-scene-item-locked [arguments]
371+
-h, --help Print this usage information.
372+
-n, --scene-name=<string> (mandatory) Name of the scene the item is in
373+
-i, --scene-item-id=<int> (mandatory) Numeric ID of the scene item
374+
-l, --[no-]scene-item-locked New lock state of the scene item
375+
```
376+
312377
### send
313378

314379
```sh

bin/obs.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void main(List<String> arguments) async {
3131
..addCommand(ObsSourcesCommand())
3232
// ..addCommand(ObsProfilesCommand())
3333
// ..addCommand(ObsRecordingCommand())
34-
// ..addCommand(ObsSceneItemsCommand())
34+
..addCommand(ObsSceneItemsCommand())
3535
// ..addCommand(ObsScenesCommand())
3636
..addCommand(ObsStreamCommand())
3737
..addCommand(ObsUiCommand())

lib/command.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export 'src/cmd/obs_config_command.dart';
88
export 'src/cmd/obs_general_command.dart';
99
export 'src/cmd/obs_helper_command.dart';
1010
export 'src/cmd/obs_listen_command.dart';
11+
export 'src/cmd/obs_scene_items_command.dart';
1112
export 'src/cmd/obs_send_command.dart';
1213
export 'src/cmd/obs_sources_command.dart';
1314
export 'src/cmd/obs_stream_command.dart';
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import 'package:args/command_runner.dart';
2+
import 'package:obs_websocket/command.dart';
3+
4+
/// Config Requests
5+
class ObsSceneItemsCommand extends Command {
6+
@override
7+
String get description => 'Scene Items Requests';
8+
9+
@override
10+
String get name => 'scene-items';
11+
12+
ObsSceneItemsCommand() {
13+
addSubcommand(ObsGetSceneItemListCommand());
14+
addSubcommand(ObsGetSceneItemLockedCommand());
15+
addSubcommand(ObsSetSceneItemLockedCommand());
16+
}
17+
}
18+
19+
/// Gets a list of all scene items in a scene.
20+
class ObsGetSceneItemListCommand extends ObsHelperCommand {
21+
@override
22+
String get description => 'Gets the lock state of a scene item.';
23+
24+
@override
25+
String get name => 'get-scene-item-list';
26+
27+
ObsGetSceneItemListCommand() {
28+
argParser.addOption('scene-name',
29+
abbr: 'n',
30+
mandatory: true,
31+
valueHelp: 'string',
32+
help: 'Name of the scene to get the items of');
33+
}
34+
35+
@override
36+
void run() async {
37+
await initializeObs();
38+
39+
final sceneItemDetailList =
40+
await obs.sceneItems.getSceneItemList(argResults!['scene-name']);
41+
42+
print(sceneItemDetailList);
43+
44+
obs.close();
45+
}
46+
}
47+
48+
/// Gets the lock state of a scene item.
49+
class ObsGetSceneItemLockedCommand extends ObsHelperCommand {
50+
@override
51+
String get description => 'Gets the lock state of a scene item.';
52+
53+
@override
54+
String get name => 'get-scene-item-locked';
55+
56+
ObsGetSceneItemLockedCommand() {
57+
argParser
58+
..addOption('scene-name',
59+
abbr: 'n',
60+
mandatory: true,
61+
valueHelp: 'string',
62+
help: 'Name of the scene the item is in')
63+
..addOption(
64+
'scene-item-id',
65+
abbr: 'i',
66+
mandatory: true,
67+
valueHelp: 'int',
68+
help: 'Numeric ID of the scene item',
69+
);
70+
}
71+
72+
@override
73+
void run() async {
74+
await initializeObs();
75+
76+
final isLocked = await obs.sceneItems.getLocked(
77+
sceneName: argResults!['scene-name'],
78+
sceneItemId: int.parse(argResults!['scene-item-id']));
79+
80+
print(isLocked);
81+
82+
obs.close();
83+
}
84+
}
85+
86+
/// Sets the lock state of a scene item.
87+
class ObsSetSceneItemLockedCommand extends ObsHelperCommand {
88+
@override
89+
String get description => 'Sets the lock state of a scene item.';
90+
91+
@override
92+
String get name => 'set-scene-item-locked';
93+
94+
ObsSetSceneItemLockedCommand() {
95+
argParser
96+
..addOption('scene-name',
97+
abbr: 'n',
98+
mandatory: true,
99+
valueHelp: 'string',
100+
help: 'Name of the scene the item is in')
101+
..addOption(
102+
'scene-item-id',
103+
abbr: 'i',
104+
mandatory: true,
105+
valueHelp: 'int',
106+
help: 'Numeric ID of the scene item',
107+
)
108+
..addFlag(
109+
'scene-item-locked',
110+
abbr: 'l',
111+
help: 'New lock state of the scene item',
112+
);
113+
}
114+
115+
@override
116+
void run() async {
117+
await initializeObs();
118+
119+
await obs.sceneItems.setLocked(
120+
sceneName: argResults!['scene-name'],
121+
sceneItemId: int.parse(argResults!['scene-item-id']),
122+
sceneItemLocked: argResults!['scene-item-locked']);
123+
124+
obs.close();
125+
}
126+
}

lib/src/model/response/boolean_response.dart

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,26 @@ class BooleanResponse {
1111
final bool? sceneItemEnabled;
1212
final bool? studioModeEnabled;
1313
final bool? inputMuted;
14+
final bool? sceneItemLocked;
1415

1516
bool get enabled {
16-
final bool? check =
17-
outputActive ?? sceneItemEnabled ?? studioModeEnabled ?? inputMuted;
17+
final bool? check = outputActive ??
18+
sceneItemEnabled ??
19+
studioModeEnabled ??
20+
inputMuted ??
21+
sceneItemLocked;
1822

1923
if (check == null) throw Exception();
2024

2125
return check;
2226
}
2327

24-
BooleanResponse({
25-
this.outputActive,
26-
this.sceneItemEnabled,
27-
this.studioModeEnabled,
28-
this.inputMuted,
29-
});
28+
BooleanResponse(
29+
{this.outputActive,
30+
this.sceneItemEnabled,
31+
this.studioModeEnabled,
32+
this.inputMuted,
33+
this.sceneItemLocked});
3034

3135
factory BooleanResponse.fromJson(Map<String, dynamic> json) =>
3236
_$BooleanResponseFromJson(json);

lib/src/model/response/boolean_response.g.dart

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)