* Authenticate to the tv
     * @except Login fails (wrong pairing key?)
     **/
    try {
        $_SESSION['SESSION_ID'] = $tv->authenticate();
    } catch (Exception $e) {
        die('Authentication failed, I am sorry.');
    }
} else {
    $tv->setSession($_SESSION['SESSION_ID']);
}
if (isset($_GET['cmd'])) {
    switch ($_GET['cmd']) {
        case 'screen':
            header('Content-Type: image/jpeg');
            exit($tv->queryData(TV_INFO_SCREEN));
            break;
        case 'changeChannel':
            if (!isset($_GET['value'])) {
                exit;
            }
            $channelName = strtolower($_GET['value']);
            foreach ($_SESSION['CHANNEL_LIST'] as $channel) {
                if (strtolower($channel['chname']) == $channelName) {
                    $tv->processCommand(TV_CMD_CHANGE_CHANNEL, $channel);
                    break;
                }
            }
            break;
        case 'info':
            $currentChannel = $tv->queryData(TV_INFO_CURRENT_CHANNEL);
Exemple #2
0
/**
 * Set your volume down
**/
$tv->processCommand(TV_CMD_VOLUME_DOWN);
/**
 * Move your mouse
**/
$tv->processCommand(TV_CMD_MOUSE_MOVE, ['x' => 20, 'y' => 20]);
/**
 * Trigger a mouse click
**/
$tv->processCommand(TV_CMD_MOUSE_CLICK);
/**
 * Get current volume
**/
echo $tv->queryData(TV_INFO_VOLUME)->level;
/**
 * Get current channel name
**/
echo $tv->queryData(TV_INFO_CURRENT_CHANNEL)->chname;
/**
 * Save a screenshot
**/
file_put_contents('screen.jpeg', $tv->queryData(TV_INFO_SCREEN));
/**
 * Change channel (Channel VIVA)
**/
// Get channel list
$channels = $tv->queryData(TV_INFO_CHANNEL_LIST);
// Channel name
$channelName = 'VIVA';
Exemple #3
0
<?php

include 'PHP-LG-SmartTV/smartTV.php';
$tv = new SmartTV('192.168.0.11', 8080);
$tv->setPairingKey(647492);
try {
    $tv->authenticate();
} catch (Exception $e) {
    die('Authentication failed, I am sorry.');
}
file_put_contents('screen.jpeg', $tv->queryData(TV_INFO_SCREEN));