-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLMSDeviceModule.usp
More file actions
712 lines (633 loc) · 16.9 KB
/
LMSDeviceModule.usp
File metadata and controls
712 lines (633 loc) · 16.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
/*****************************************************************************
LMSDeviceModule.usp
Lyrion Music Server (LMS) - Crestron SIMPL+ Module for CP4N
Drop-in replacement for RoonDeviceModule v1.0 Build 10
Uses SIMPL Windows TCP/IP Client for transport (no SIMPL+ sockets)
*****************************************************************************/
#SYMBOL_NAME "LMSDeviceModule"
#DEFAULT_VOLATILE
#ENABLE_STACK_CHECKING
#ENABLE_TRACE
#PRINT_TO_TRACE
STRING_PARAMETER LMS_IP[64];
STRING_PARAMETER DefaultPlayer[64];
// === DIGITAL INPUTS (existing - do not reorder) ===
DIGITAL_INPUT SystemModuleReady;
DIGITAL_INPUT Standby;
DIGITAL_INPUT ConvenienceSwitch;
DIGITAL_INPUT Play;
DIGITAL_INPUT Pause;
DIGITAL_INPUT PlayPause;
DIGITAL_INPUT NextTrack;
DIGITAL_INPUT PreviousTrack;
DIGITAL_INPUT Stop;
DIGITAL_INPUT SetShuffleOn;
DIGITAL_INPUT SetShuffleOff;
DIGITAL_INPUT ToggleShuffle;
DIGITAL_INPUT SetLoop;
DIGITAL_INPUT SetLoopOne;
DIGITAL_INPUT SetLoopOff;
DIGITAL_INPUT ToggleLoop;
DIGITAL_INPUT SetAutoRadioOn;
DIGITAL_INPUT SetAutoRadioOff;
DIGITAL_INPUT ToggleAutoRadio;
DIGITAL_INPUT VolumeUp;
DIGITAL_INPUT VolumeDown;
DIGITAL_INPUT Mute;
DIGITAL_INPUT Unmute;
DIGITAL_INPUT MuteUnmute;
// TCP Client status
DIGITAL_INPUT TCP_Connected;
// === ANALOG INPUTS ===
ANALOG_INPUT Volume;
ANALOG_INPUT VolumeNormalized;
ANALOG_INPUT Seek;
ANALOG_INPUT SeekNormalized;
// === STRING INPUTS ===
STRING_INPUT CRPC[256];
STRING_INPUT From_Device[65534];
// === DIGITAL OUTPUTS (existing - do not reorder) ===
DIGITAL_OUTPUT IsAvailable_fb;
DIGITAL_OUTPUT SupportsStandby_fb;
DIGITAL_OUTPUT SupportsConvenienceSwitch_fb;
DIGITAL_OUTPUT IsPlayAllowed_fb;
DIGITAL_OUTPUT IsPauseAllowed_fb;
DIGITAL_OUTPUT IsNextAllowed_fb;
DIGITAL_OUTPUT IsPreviousAllowed_fb;
DIGITAL_OUTPUT Playing_fb;
DIGITAL_OUTPUT Paused_fb;
DIGITAL_OUTPUT Loading_fb;
DIGITAL_OUTPUT Stopped_fb;
DIGITAL_OUTPUT IsShuffle_fb;
DIGITAL_OUTPUT IsLoop_fb;
DIGITAL_OUTPUT IsLoopOne_fb;
DIGITAL_OUTPUT IsAutoRadio_fb;
DIGITAL_OUTPUT IsSeekAllowed_fb;
DIGITAL_OUTPUT IsVolumeFixed_fb;
DIGITAL_OUTPUT IsMuted_fb;
DIGITAL_OUTPUT ShowSeekPosition_fb;
DIGITAL_OUTPUT ShowLength_fb;
// TCP Client control
DIGITAL_OUTPUT TCP_Connect;
DIGITAL_OUTPUT TCP_Disconnect;
// === ANALOG OUTPUTS ===
ANALOG_OUTPUT VolumeMin_fb;
ANALOG_OUTPUT VolumeMax_fb;
ANALOG_OUTPUT Volume_fb;
ANALOG_OUTPUT VolumeNormalized_fb;
ANALOG_OUTPUT PositionSeconds_fb;
ANALOG_OUTPUT PositionNormalized_fb;
ANALOG_OUTPUT LengthSeconds_fb;
// === STRING OUTPUTS ===
STRING_OUTPUT Name_fb;
STRING_OUTPUT VolumeType_fb;
STRING_OUTPUT PositionSerial_fb;
STRING_OUTPUT LengthSerial_fb;
STRING_OUTPUT OneLine_fb;
STRING_OUTPUT TwoLine_Line1_fb;
STRING_OUTPUT TwoLine_Line2_fb;
STRING_OUTPUT ThreeLine_Line1_fb;
STRING_OUTPUT ThreeLine_Line2_fb;
STRING_OUTPUT ThreeLine_Line3_fb;
STRING_OUTPUT NowPlayingImageUrl_fb;
STRING_OUTPUT PlayBackError_fb;
STRING_OUTPUT CRPC_fb;
// TCP Client send
STRING_OUTPUT To_Device;
// === GLOBAL VARIABLES ===
STRING gPlayerID[64];
STRING gPlayerName[64];
STRING gRxBuffer[65534];
STRING gPendingRequest[2048];
STRING gResult[512];
STRING gCmd[512];
INTEGER gInitialized;
INTEGER gCurrentVol;
INTEGER gLengthSeconds;
INTEGER gRequestPending;
// === HELPER FUNCTIONS ===
FUNCTION Cmd1(STRING c)
{
gCmd = "[" + Chr(34) + c + Chr(34) + "]";
}
FUNCTION Cmd2(STRING c, STRING a)
{
gCmd = "[" + Chr(34) + c + Chr(34) + "," + Chr(34) + a + Chr(34) + "]";
}
FUNCTION Cmd3(STRING c, STRING sub, STRING a)
{
gCmd = "[" + Chr(34) + c + Chr(34) + "," + Chr(34) + sub + Chr(34) + "," + Chr(34) + a + Chr(34) + "]";
}
FUNCTION ExtractStr(STRING json, STRING key)
{
STRING search[128];
STRING segment[8192];
INTEGER pos;
INTEGER endPos;
INTEGER segLen;
gResult = "";
search = Chr(34) + key + Chr(34) + ":" + Chr(34);
pos = FIND(search, json);
if (pos = 0) return;
pos = pos + LEN(search);
segLen = LEN(json) - pos + 1;
if (segLen > 8192) segLen = 8192;
segment = MID(json, pos, segLen);
endPos = FIND(Chr(34), segment);
if (endPos = 0) return;
gResult = MID(segment, 1, endPos - 1);
}
FUNCTION ExtractNum(STRING json, STRING key)
{
STRING search[128];
STRING rest[64];
INTEGER pos;
INTEGER endPos;
INTEGER p;
gResult = "0";
search = Chr(34) + key + Chr(34) + ":";
pos = FIND(search, json);
if (pos = 0) return;
pos = pos + LEN(search);
rest = MID(json, pos, 32);
endPos = 33;
p = FIND(",", rest);
if (p > 0) { if (p < endPos) endPos = p; }
p = FIND(Chr(125), rest);
if (p > 0) { if (p < endPos) endPos = p; }
p = FIND("]", rest);
if (p > 0) { if (p < endPos) endPos = p; }
p = FIND(" ", rest);
if (p > 0) { if (p < endPos) endPos = p; }
p = FIND(Chr(10), rest);
if (p > 0) { if (p < endPos) endPos = p; }
p = FIND(Chr(13), rest);
if (p > 0) { if (p < endPos) endPos = p; }
if (endPos > 1)
gResult = MID(rest, 1, endPos - 1);
else
gResult = "0";
}
FUNCTION FormatTime(INTEGER secs)
{
INTEGER m;
INTEGER s;
if (secs < 0) secs = 0;
m = secs / 60;
s = secs - (m * 60);
if (s < 10)
gResult = ITOA(m) + ":0" + ITOA(s);
else
gResult = ITOA(m) + ":" + ITOA(s);
}
// BuildRPC: builds HTTP request into gPendingRequest
FUNCTION BuildRPC(STRING pid, STRING cmdArray)
{
STRING body[1024];
STRING lenStr[8];
INTEGER contentLen;
body = "{" + Chr(34) + "id" + Chr(34) + ":1," + Chr(34) + "method" + Chr(34) + ":" + Chr(34) + "slim.request" + Chr(34) + "," + Chr(34) + "params" + Chr(34) + ":[" + Chr(34) + pid + Chr(34) + "," + cmdArray + "]}";
contentLen = LEN(body);
lenStr = ITOA(contentLen);
gPendingRequest = "POST /jsonrpc.js HTTP/1.1\r\nHost: " + LMS_IP + "\r\nContent-Type: application/json\r\nContent-Length: " + lenStr + "\r\nConnection: close\r\n\r\n" + body;
}
FUNCTION BuildPlayerCmd(STRING cmdArray)
{
if (gPlayerID <> "") BuildRPC(gPlayerID, cmdArray);
}
FUNCTION PollPlayers()
{
STRING cmd[64];
cmd = "[" + Chr(34) + "players" + Chr(34) + ",0,10]";
BuildRPC("", cmd);
}
FUNCTION PollStatus()
{
STRING cmd[128];
if (gPlayerID = "")
{
PollPlayers();
return;
}
cmd = "[" + Chr(34) + "status" + Chr(34) + "," + Chr(34) + "-" + Chr(34) + ",1," + Chr(34) + "tags:cgaldK" + Chr(34) + "]";
BuildRPC(gPlayerID, cmd);
}
// SendRequest: send on existing connection or connect first
FUNCTION SendRequest()
{
gRxBuffer = "";
gRequestPending = 1;
if (TCP_Connected)
{
// Connection already open (keep-alive) - send directly
To_Device = gPendingRequest;
gRequestPending = 0;
}
else
{
// Need to connect first - PUSH handler will send
TCP_Connect = 1;
}
}
// === RESPONSE PARSING ===
FUNCTION ParsePlayers(STRING body)
{
STRING pid[64];
STRING fragment[512];
STRING nameSearch[256];
INTEGER pos;
INTEGER startPos;
if (DefaultPlayer <> "")
{
nameSearch = Chr(34) + "name" + Chr(34) + ":" + Chr(34) + DefaultPlayer + Chr(34);
pos = FIND(nameSearch, body);
if (pos > 0)
{
startPos = pos - 200;
if (startPos < 1) startPos = 1;
fragment = MID(body, startPos, pos - startPos + 200);
ExtractStr(fragment, "playerid");
pid = gResult;
if (pid <> "")
{
gPlayerID = pid;
gPlayerName = DefaultPlayer;
Name_fb = gPlayerName;
IsAvailable_fb = 1;
Trace("LMS: Found player %s = %s\n", gPlayerName, gPlayerID);
return;
}
}
}
ExtractStr(body, "playerid");
pid = gResult;
ExtractStr(body, "name");
if (pid <> "")
{
gPlayerID = pid;
gPlayerName = gResult;
Name_fb = gPlayerName;
IsAvailable_fb = 1;
Trace("LMS: Found player %s = %s\n", gPlayerName, gPlayerID);
}
}
FUNCTION ParseStatus(STRING body)
{
STRING mode[16];
STRING title[256];
STRING artist[256];
STRING album[256];
STRING artUrl[512];
STRING coverid[64];
INTEGER trackPos;
INTEGER trackLen;
INTEGER vol;
INTEGER mute;
INTEGER shuf;
INTEGER rep;
ExtractStr(body, "mode");
mode = gResult;
Playing_fb = 0;
Paused_fb = 0;
Stopped_fb = 0;
Loading_fb = 0;
if (mode = "play")
{
Playing_fb = 1;
IsPlayAllowed_fb = 0;
IsPauseAllowed_fb = 1;
}
else if (mode = "pause")
{
Paused_fb = 1;
IsPlayAllowed_fb = 1;
IsPauseAllowed_fb = 0;
}
else
{
Stopped_fb = 1;
IsPlayAllowed_fb = 1;
IsPauseAllowed_fb = 0;
}
IsNextAllowed_fb = 1;
IsPreviousAllowed_fb = 1;
IsSeekAllowed_fb = 1;
ShowSeekPosition_fb = 1;
ShowLength_fb = 1;
IsAutoRadio_fb = 0;
SupportsStandby_fb = 0;
SupportsConvenienceSwitch_fb = 0;
IsVolumeFixed_fb = 0;
VolumeMin_fb = 0;
VolumeMax_fb = 100;
VolumeType_fb = "number";
ExtractStr(body, "title");
title = gResult;
if (title = "")
{
ExtractStr(body, "current_title");
title = gResult;
}
ExtractStr(body, "artist");
artist = gResult;
ExtractStr(body, "album");
album = gResult;
ExtractStr(body, "artwork_url");
artUrl = gResult;
if (artUrl = "")
{
ExtractStr(body, "coverid");
coverid = gResult;
if (coverid <> "")
artUrl = "http://" + LMS_IP + ":9000/music/" + coverid + "/cover_500x500.jpg";
}
OneLine_fb = title;
TwoLine_Line1_fb = title;
TwoLine_Line2_fb = artist;
ThreeLine_Line1_fb = title;
ThreeLine_Line2_fb = artist;
ThreeLine_Line3_fb = album;
NowPlayingImageUrl_fb = artUrl;
ExtractNum(body, "time");
trackPos = ATOI(gResult);
ExtractNum(body, "duration");
trackLen = ATOI(gResult);
gLengthSeconds = trackLen;
PositionSeconds_fb = trackPos;
LengthSeconds_fb = trackLen;
FormatTime(trackPos);
PositionSerial_fb = gResult;
FormatTime(trackLen);
LengthSerial_fb = gResult;
if (trackLen > 0)
PositionNormalized_fb = (trackPos * 65535) / trackLen;
else
PositionNormalized_fb = 0;
ExtractNum(body, "mixer volume");
vol = ATOI(gResult);
if (vol < 0) vol = 0;
gCurrentVol = vol;
Volume_fb = vol;
VolumeNormalized_fb = (vol * 65535) / 100;
ExtractNum(body, "mixer muting");
mute = ATOI(gResult);
IsMuted_fb = mute;
ExtractNum(body, "playlist shuffle");
shuf = ATOI(gResult);
if (shuf <> 0) IsShuffle_fb = 1;
else IsShuffle_fb = 0;
ExtractNum(body, "playlist repeat");
rep = ATOI(gResult);
if (rep = 2) IsLoop_fb = 1;
else IsLoop_fb = 0;
if (rep = 1) IsLoopOne_fb = 1;
else IsLoopOne_fb = 0;
}
FUNCTION ParseResponse(STRING response)
{
STRING body[65534];
STRING modeKey[16];
INTEGER pos;
pos = FIND("\r\n\r\n", response);
if (pos > 0)
body = MID(response, pos + 4, LEN(response));
else
body = response;
modeKey = Chr(34) + "mode" + Chr(34);
if (FIND("players_loop", body) > 0)
ParsePlayers(body);
else if (FIND(modeKey, body) > 0)
ParseStatus(body);
}
// === TCP CLIENT EVENT HANDLERS ===
// Connected: send pending request (first connect only)
PUSH TCP_Connected
{
GENERATEUSERERROR("LMS: TCP CONNECTED");
if (gRequestPending)
{
To_Device = gPendingRequest;
gRequestPending = 0;
}
}
// Disconnected: unexpected drop - next poll will reconnect
RELEASE TCP_Connected
{
GENERATEUSERERROR("LMS: TCP DROPPED");
TCP_Connect = 0;
gRxBuffer = "";
}
// Data received: accumulate and parse when full HTTP response received
CHANGE From_Device
{
STRING clStr[16];
INTEGER hdrEnd;
INTEGER clPos;
INTEGER contentLen;
INTEGER bodyStart;
INTEGER bodyLen;
gRxBuffer = gRxBuffer + From_Device;
// Find end of HTTP headers
hdrEnd = FIND("\r\n\r\n", gRxBuffer);
if (hdrEnd = 0) return;
bodyStart = hdrEnd + 4;
// Extract Content-Length
clPos = FIND("Content-Length: ", gRxBuffer);
if (clPos = 0) return;
clStr = MID(gRxBuffer, clPos + 16, 10);
contentLen = ATOI(clStr);
if (contentLen = 0) return;
// Check if full body received
bodyLen = LEN(gRxBuffer) - bodyStart + 1;
if (bodyLen >= contentLen)
{
GENERATEUSERERROR("LMS: RESPONSE %d bytes", LEN(gRxBuffer));
ParseResponse(gRxBuffer);
gRxBuffer = "";
TCP_Connect = 0;
}
}
// === MAIN ===
Function Main()
{
WaitForInitializationComplete();
GENERATEUSERERROR("LMS: Main() started, IP=%s Player=%s", LMS_IP, DefaultPlayer);
gPlayerID = "";
gPlayerName = "";
gRxBuffer = "";
gPendingRequest = "";
gRequestPending = 0;
gInitialized = 0;
gCurrentVol = 0;
gLengthSeconds = 0;
gResult = "";
gCmd = "";
IsAvailable_fb = 0;
VolumeMin_fb = 0;
VolumeMax_fb = 100;
VolumeType_fb = "number";
ShowLength_fb = 1;
TCP_Connect = 0;
TCP_Disconnect = 0;
Trace("LMS: Module started, IP=%s Player=%s\n", LMS_IP, DefaultPlayer);
// Poll loop - runs forever on Main thread
WHILE(1)
{
DELAY(500);
if (!gRequestPending)
{
PollStatus();
SendRequest();
}
}
}
// === PUSH HANDLERS ===
PUSH SystemModuleReady
{
if (!gInitialized)
{
gInitialized = 1;
Trace("LMS: SystemModuleReady\n");
// Don't call SendRequest here - WHILE loop handles all polling
// This prevents collision with the WHILE loop's first poll
}
}
PUSH Play
{
Cmd1("play");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH Pause
{
Cmd2("pause", "1");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH PlayPause
{
Cmd1("pause");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH NextTrack
{
Cmd3("playlist", "index", "+1");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH PreviousTrack
{
Cmd3("playlist", "index", "-1");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH Stop
{
Cmd1("stop");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH SetShuffleOn
{
Cmd3("playlist", "shuffle", "1");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH SetShuffleOff
{
Cmd3("playlist", "shuffle", "0");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH ToggleShuffle
{
Cmd2("playlist", "shuffle");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH SetLoop
{
Cmd3("playlist", "repeat", "2");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH SetLoopOne
{
Cmd3("playlist", "repeat", "1");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH SetLoopOff
{
Cmd3("playlist", "repeat", "0");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH ToggleLoop
{
Cmd2("playlist", "repeat");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH VolumeUp
{
Cmd3("mixer", "volume", "+5");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH VolumeDown
{
Cmd3("mixer", "volume", "-5");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH Mute
{
Cmd3("mixer", "muting", "1");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH Unmute
{
Cmd3("mixer", "muting", "0");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
PUSH MuteUnmute
{
Cmd3("mixer", "muting", "toggle");
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
CHANGE Volume
{
Cmd3("mixer", "volume", ITOA(Volume));
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
CHANGE VolumeNormalized
{
INTEGER vol;
vol = (VolumeNormalized * 100) / 65535;
Cmd3("mixer", "volume", ITOA(vol));
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
CHANGE Seek
{
Cmd2("time", ITOA(Seek));
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
CHANGE SeekNormalized
{
INTEGER seekPos;
if (gLengthSeconds > 0)
{
seekPos = (SeekNormalized * gLengthSeconds) / 65535;
Cmd2("time", ITOA(seekPos));
BuildPlayerCmd(gCmd);
if (gPlayerID <> "") SendRequest();
}
}