Perl extension for upnp.
use Net::UPnP::ControlPoint; use Net::UPnP::AV::MediaRenderer; my $obj = Net::UPnP::ControlPoint->new(); @dev_list = (); while (@dev_list <= 0 || $retry_cnt > 5) { @dev_list = $obj->search(st =>'upnp:rootdevice', mx => 3); $retry_cnt++; } $devNum= 0; foreach $dev (@dev_list) { my $device_type = $dev->getdevicetype(); if ($device_type ne 'urn:schemas-upnp-org:device:MediaRenderer:1') { next; } my $friendlyname = $dev->getfriendlyname(); print "[$devNum] : " . $friendlyname . "\n"; my $renderer = Net::UPnP::AV::MediaRenderer->new(); $renderer->setdevice($dev); $renderer->stop(); $renderer->setAVTransportURI(CurrentURI => 'http://xxx.xxx.xxx.xxx/xxxx.mpg'); $renderer->play(); $devNum++; }
The package is a extention UPnP/AV media server.
$renderer = Net::UPnP::AV::MediaRenderer(); Creates a new object. Read `perldoc perlboot` if you don't understand that. The new object is not associated with any UPnP devices. Please use setdevice() to set the device.
$renderer->setdevice($dev); Set a device to the object.
@action_response = $renderer->setAVTransportURI( InstanceID => $instanceID, # 0 CurrentURI => $url, # '' CurrentURIMetaData => $metaData, # "' ); Set a current content to play, Net::UPnP::ActionResponse.
@action_response = $renderer->setNextAVTransportURI( InstanceID => $instanceID, # 0 NextURI => $url, # '' NextURIMetaData => $metaData, # "' ); Set a next content to play, Net::UPnP::ActionResponse.
@action_response = $renderer->play( InstanceID => $instanceID, # 0 Speed => $url, # 1 ); Play the specified content.
@action_response = $renderer->stop( InstanceID => $instanceID, # 0 ); Stop the playing content.
Net::UPnP::AV::Content
Net::UPnP::AV::Item
Net::UPnP::AV::Container
Satoshi Konno [email protected]
CyberGarage http://www.cybergarage.org
Copyright (C) 2005 by Satoshi Konno
It may be used, redistributed, and/or modified under the terms of \s-1BSD\s0 License.