PHP code example of jalder / upnp
1. Go to this page and download the library: Download jalder/upnp library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jalder / upnp example snippets
use jalder\Upnp\Chromecast;
$chromecast = new Chromecast();
print('searching...'.PHP_EOL);
$chromecasts = $chromecast->discover();
$movie = 'https://ia700408.us.archive.org/26/items/BigBuckBunny_328/BigBuckBunny_512kb.mp4';
if(!count($chromecasts)){
print_r('no chromecasts found via SSDP'.PHP_EOL);
}
foreach($chromecasts as $c){
print($c['description']['device']['friendlyName'].PHP_EOL);
$app = new Chromecast\Applications\DefaultMediaReceiver($c);
$remote = new Chromecast\Remote($c, $app);
$result = $remote->play($movie);
print_r($result);
}