4
4
import static org .junit .jupiter .api .Assertions .fail ;
5
5
6
6
import java .io .File ;
7
- import java .nio .file .Path ;
8
- import java .nio .file .Paths ;
9
7
import java .util .HashMap ;
10
- import java .util .List ;
11
8
import java .util .Map ;
12
9
import java .util .function .Consumer ;
13
10
import net .twasi .obsremotejava .OBSRemoteController ;
14
- import net .twasi .obsremotejava .objects .Scene ;
15
11
import org .junit .jupiter .api .AfterAll ;
16
12
import org .junit .jupiter .api .AfterEach ;
17
13
import org .junit .jupiter .api .BeforeAll ;
@@ -26,6 +22,16 @@ public class ObsRemoteE2eObservationIT {
26
22
27
23
static OBSRemoteController remote ;
28
24
25
+ private final String SOURCE_MEDIA = "media" ;
26
+ private final String SOURCE_VLC_MEDIA = "vlc-media" ;
27
+ private final String SOURCE_RED_SQUARE = "red_square" ;
28
+ private final String SOURCE_RED_SQUARE_FILTER = "Color Correction" ;
29
+ private final String SCENE1 = "scene1" ;
30
+ private final String SCENE2 = "scene2" ;
31
+ private final String TRANSITION_SLIDE = "Slide" ;
32
+ private final String TRANSITION_CUT = "Cut" ;
33
+ private final String TRANSITION_FADE = "Fade" ;
34
+
29
35
@ BeforeAll
30
36
static void beforeAll () {
31
37
@@ -73,55 +79,57 @@ public void afterEach() {
73
79
@ Test
74
80
void switchScene () {
75
81
obsShould ("Switch to scene2" );
76
- remote .changeSceneWithTransition ("scene2" , "Cut" , loggingConsumer );
82
+ remote .changeSceneWithTransition (SCENE2 , TRANSITION_CUT , loggingCallback );
77
83
}
78
84
79
85
@ Test
80
86
void showHideSceneItem () {
81
87
obsShould ("Show the red square" );
82
- remote .setSourceVisibility (null , "red_square" , true , loggingConsumer );
88
+ remote .setSourceVisibility (null , SOURCE_RED_SQUARE , true , loggingCallback );
83
89
obsShould ("Hide the red square" );
84
- remote .setSourceVisibility (null , "red_square" , false , loggingConsumer );
90
+ remote .setSourceVisibility (null , SOURCE_RED_SQUARE , false , loggingCallback );
85
91
}
86
92
87
93
@ Test
88
94
void setTransition () {
89
95
obsShould ("Set current transition to Slide, with transition 2000ms" );
90
- remote .setCurrentTransition ("Slide" , loggingConsumer );
91
- remote .setTransitionDuration (2000 , loggingConsumer );
96
+ remote .setCurrentTransition (TRANSITION_SLIDE , loggingCallback );
97
+ remote .setTransitionDuration (2000 , loggingCallback );
92
98
obsShould ("Set current transition back to 300ms" );
93
- remote .setTransitionDuration (300 , loggingConsumer );
99
+ remote .setTransitionDuration (300 , loggingCallback );
94
100
obsShould ("Set current transition back to Cut" );
95
- remote .setCurrentTransition ("Cut" , loggingConsumer );
101
+ remote .setCurrentTransition (TRANSITION_CUT , loggingCallback );
96
102
}
97
103
98
104
@ Test
99
105
void changeScenesWithTransition () {
100
106
obsShould ("Change to scene2, with the Slide transition" );
101
- remote .changeSceneWithTransition ("scene2" , "Slide" , loggingConsumer );
107
+ remote .changeSceneWithTransition (SCENE2 , TRANSITION_SLIDE , loggingCallback );
102
108
}
103
109
104
110
@ Test
105
111
void setSourceFilterVisibility () {
106
112
107
113
obsShould ("Show a blue square (red square colored blue by a filter)" );
108
- remote .setSourceVisibility (null , "red_square" , true , loggingConsumer );
109
- remote .setSourceFilterVisibility ("red_square" , "Color Correction" , true , loggingConsumer );
114
+ remote .setSourceVisibility (null , SOURCE_RED_SQUARE , true , loggingCallback );
115
+ remote .setSourceFilterVisibility (SOURCE_RED_SQUARE , SOURCE_RED_SQUARE_FILTER , true ,
116
+ loggingCallback );
110
117
obsShould ("Return the red square to normal" );
111
- remote .setSourceFilterVisibility ("red_square" , "Color Correction" , false , loggingConsumer );
118
+ remote .setSourceFilterVisibility (SOURCE_RED_SQUARE , SOURCE_RED_SQUARE_FILTER , false ,
119
+ loggingCallback );
112
120
113
121
}
114
122
115
123
@ Test
116
124
void exerciseStudioMode () {
117
125
obsShould ("Enable studio mode" );
118
- remote .setStudioModeEnabled (true , loggingConsumer );
126
+ remote .setStudioModeEnabled (true , loggingCallback );
119
127
obsShould ("Set preview scene to scene2" );
120
- remote .setPreviewScene ("scene2" , loggingConsumer );
128
+ remote .setPreviewScene (SCENE2 , loggingCallback );
121
129
obsShould ("Fade to scene2" );
122
- remote .transitionToProgram ("Fade" , 1500 , loggingConsumer );
130
+ remote .transitionToProgram (TRANSITION_FADE , 1500 , loggingCallback );
123
131
obsShould ("Disable studio mode" );
124
- remote .setStudioModeEnabled (false , loggingConsumer );
132
+ remote .setStudioModeEnabled (false , loggingCallback );
125
133
126
134
}
127
135
@@ -130,10 +138,10 @@ void setSourceSettings() {
130
138
obsShould ("Curse the 'scene1' text" );
131
139
Map <String , Object > settings = new HashMap <>();
132
140
settings .put ("text" , "S̼͚̞̼̩̱̽̓̍̽͊́ͨ̍̀ċͭ̚҉̪̖̤̥ͅȩ͉̣̜̖̖͙͇́̀̒ͥ̓̚͠͞n̦͍͆͑ͤ̕e̶̖̝̗̻͂̑̽̔ͩ̅́͜ͅ ̢͉̬͔͙̺̖͂͂ͣ͢1̮̥͇̏̇͋̈́ͨͥ͝ͅ" );
133
- remote .setSourceSettings ("scenename1" , settings , loggingConsumer );
141
+ remote .setSourceSettings (SCENE1 , settings , loggingCallback );
134
142
obsShould ("Change the 'scene1' text back to normal" );
135
143
settings .put ("text" , "Scene 1" );
136
- remote .setSourceSettings ("scenename1" , settings , loggingConsumer );
144
+ remote .setSourceSettings (SCENE1 , settings , loggingCallback );
137
145
}
138
146
139
147
@ Test
@@ -144,52 +152,79 @@ void takeSourceScreenshot() throws Exception {
144
152
String screenshotPath = file .getAbsolutePath ();
145
153
obsShould ("Take a screenshot of the current scene, and save it to " + screenshotPath , 1 );
146
154
remote .takeSourceScreenshot (
147
- "scene1" , "png" ,
155
+ SCENE1 , "png" ,
148
156
screenshotPath ,
149
157
null , 1 ,
150
158
1080 , 720 ,
151
- loggingConsumer
159
+ loggingCallback
152
160
);
153
161
}
154
162
155
163
@ Test
156
164
void startStopStreaming () {
157
165
obsShould ("Start Streaming" );
158
- remote .startStreaming (loggingConsumer );
166
+ remote .startStreaming (loggingCallback );
159
167
obsShould ("Stop Streaming" );
160
- remote .stopStreaming (loggingConsumer );
168
+ remote .stopStreaming (loggingCallback );
161
169
}
162
170
163
171
@ Test
164
172
void startStopRecordingAndReplayBuffer () {
165
173
obsShould ("Start Recording" );
166
- remote .startRecording (loggingConsumer );
174
+ remote .startRecording (loggingCallback );
167
175
168
176
obsShould ("Start the replay buffer" );
169
- remote .startReplayBuffer (loggingConsumer );
177
+ remote .startReplayBuffer (loggingCallback );
170
178
171
179
obsShould ("Save the replay buffer" );
172
- remote .saveReplayBuffer (loggingConsumer );
180
+ remote .saveReplayBuffer (loggingCallback );
173
181
174
182
obsShould ("Stop the replay buffer" );
175
- remote .stopReplayBuffer (loggingConsumer );
183
+ remote .stopReplayBuffer (loggingCallback );
176
184
177
185
obsShould ("Stop Recording" );
178
- remote .stopRecording (loggingConsumer );
186
+ remote .stopRecording (loggingCallback );
179
187
}
180
188
181
189
@ Test
182
190
void setVolumeAndMute () {
183
191
184
192
obsShould ("Set the volume to 50% (note, appears 67% due to log scaling; check % in advanced audio properties)" );
185
- remote .setSourceVisibility (null , "media" , true , loggingConsumer );
186
- remote .setVolume ("media" , 0.50 , loggingConsumer );
193
+ remote .setSourceVisibility (null , "media" , true , loggingCallback );
194
+ remote .setVolume (SOURCE_MEDIA , 0.50 , loggingCallback );
187
195
obsShould ("Mute the volume" );
188
- remote .setMute ("media" , true , loggingConsumer );
196
+ remote .setMute (SOURCE_MEDIA , true , loggingCallback );
189
197
obsShould ("Unmute the volume" );
190
- remote .setMute ("media" , false , loggingConsumer );
198
+ remote .setMute (SOURCE_MEDIA , false , loggingCallback );
191
199
obsShould ("Set the volume to 100%" );
192
- remote .setVolume ("media" , 1.00 , loggingConsumer );
200
+ remote .setVolume (SOURCE_MEDIA , 1.00 , loggingCallback );
201
+
202
+ }
203
+
204
+ @ Test
205
+ void playPauseVlcMedia () {
206
+ obsShould ("Play video 1, by showing it (Note, VLC must be installed!)" );
207
+ remote .setSourceVisibility (null , SOURCE_VLC_MEDIA , true , loggingCallback );
208
+
209
+ obsShould ("Pause video 1" );
210
+ remote .pauseMedia (SOURCE_VLC_MEDIA , loggingCallback );
211
+
212
+ // BUG: Toggle Play/Pause does not work in Palakis OBS plugin!
213
+ // see https://github.com/Palakis/obs-websocket/issues/725
214
+ // I've noted we can also replicate the problem
215
+ obsShould ("Toggle Play Video 1" );
216
+ remote .toggleMedia (SOURCE_VLC_MEDIA , loggingCallback );
217
+ obsShould ("Toggle Pause Video 1" );
218
+ remote .toggleMedia (SOURCE_VLC_MEDIA , loggingCallback );
219
+
220
+ obsShould ("Switch to video 2" );
221
+ remote .nextMedia (SOURCE_VLC_MEDIA , loggingCallback );
222
+
223
+ obsShould ("Restart, back at video 1 (should auto play)" );
224
+ remote .restartMedia (SOURCE_VLC_MEDIA , loggingCallback );
225
+
226
+ obsShould ("Stop video 1 (going back to beginning)" );
227
+ remote .stopMedia (SOURCE_VLC_MEDIA , loggingCallback );
193
228
194
229
}
195
230
@@ -244,7 +279,7 @@ private void cleanupScenes() {
244
279
});
245
280
}
246
281
247
- Consumer loggingConsumer = (obj ) -> {
282
+ Consumer loggingCallback = (obj ) -> {
248
283
System .out .println ("Received response: " + obj );
249
284
};
250
285
0 commit comments