Files
plexphp/docs/sdks/media/README.md

7.0 KiB

Media

Overview

API Calls interacting with Plex Media Server Media

Available Operations

markPlayed

This will mark the provided media key as Played.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Components;

$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';

$sdk = Plex_API\PlexAPI::builder()
    ->setXPlexClientIdentifier('Postman')
    ->setSecurity($security)->build();

try {

    $response = $sdk->media->markPlayed(59398);

    if ($response->statusCode === 200) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Parameters

Parameter Type Required Description Example
key float ✔️ The media key to mark as played 59398

Response

?Operations\MarkPlayedResponse

Errors

Error Object Status Code Content Type
Errors\MarkPlayedResponseBody 401 application/json
LukeHagar\Plex_API\Models\Errors.SDKException 4xx-5xx /

markUnplayed

This will mark the provided media key as Unplayed.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Components;

$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';

$sdk = Plex_API\PlexAPI::builder()
    ->setXPlexClientIdentifier('Postman')
    ->setSecurity($security)->build();

try {

    $response = $sdk->media->markUnplayed(59398);

    if ($response->statusCode === 200) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Parameters

Parameter Type Required Description Example
key float ✔️ The media key to mark as Unplayed 59398

Response

?Operations\MarkUnplayedResponse

Errors

Error Object Status Code Content Type
Errors\MarkUnplayedResponseBody 401 application/json
LukeHagar\Plex_API\Models\Errors.SDKException 4xx-5xx /

updatePlayProgress

This API command can be used to update the play progress of a media item.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Components;

$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';

$sdk = Plex_API\PlexAPI::builder()
    ->setXPlexClientIdentifier('Postman')
    ->setSecurity($security)->build();

try {

    $response = $sdk->media->updatePlayProgress('<value>', 90000, 'played');

    if ($response->statusCode === 200) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Parameters

Parameter Type Required Description Example
key string ✔️ the media key
time float ✔️ The time, in milliseconds, used to set the media playback progress. 90000
state string ✔️ The playback state of the media item. played

Response

?Operations\UpdatePlayProgressResponse

Errors

Error Object Status Code Content Type
Errors\UpdatePlayProgressResponseBody 401 application/json
LukeHagar\Plex_API\Models\Errors.SDKException 4xx-5xx /