Skip to content

Commit

Permalink
Merge pull request #620 from tarasfrompir/patch-4
Browse files Browse the repository at this point in the history
Patch 4
  • Loading branch information
sergejey committed Sep 9, 2019
2 parents 385dc31 + cb99228 commit ab883ed
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions modules/app_player/addons/majordroid.addon.php
Expand Up @@ -47,6 +47,36 @@ function play($input) {
} }
return $this->success; return $this->success;
} }

// Volume
function set_volume($volume) {
$this->reset_properties();
if(strlen($volume)) {
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if($socket === false) {
$this->success = FALSE;
$this->message = socket_strerror(socket_last_error());
$this->message = iconv('CP1251', 'UTF-8', $this->message);
} else {
$result = @socket_connect($socket, $this->terminal['HOST'], $this->terminal['PLAYER_PORT']);
if($result === false) {
$this->success = FALSE;
$this->message = socket_strerror(socket_last_error($socket));
$this->message = iconv('CP1251', 'UTF-8', $this->message);
} else {
$packet = 'volume:'.$volume;
socket_write($socket, $packet, strlen($packet));
$this->success = TRUE;
$this->message = 'OK';
}
socket_close($socket);
}
} else {
$this->success = FALSE;
$this->message = 'Input is missing!';
}
return $this->success;
}


// Pause // Pause
function pause() { function pause() {
Expand Down

0 comments on commit ab883ed

Please sign in to comment.