1Net::UPnP::AV::Item(3)User Contributed Perl DocumentationNet::UPnP::AV::Item(3)
2
3
4
6 Net::UPnP::AV::Item - Perl extension for UPnP.
7
9 use Net::UPnP::ControlPoint;
10 use Net::UPnP::AV::MediaServer;
11
12 my $obj = Net::UPnP::ControlPoint->new();
13
14 @dev_list = $obj->search(st =>'upnp:rootdevice', mx => 3);
15
16 $devNum= 0;
17 foreach $dev (@dev_list) {
18 $device_type = $dev->getdevicetype();
19 if ($device_type ne 'urn:schemas-upnp-org:device:MediaServer:1') {
20 next;
21 }
22 print "[$devNum] : " . $dev->getfriendlyname() . "\n";
23 unless ($dev->getservicebyname('urn:schemas-upnp-org:service:ContentDirectory:1')) {
24 next;
25 }
26 $mediaServer = Net::UPnP::AV::MediaServer->new();
27 $mediaServer->setdevice($dev);
28 @content_list = $mediaServer->getcontentlist(ObjectID => 0);
29 foreach $content (@content_list) {
30 print_content($mediaServer, $content, 1);
31 }
32 $devNum++;
33 }
34
35 sub print_content {
36 my ($mediaServer, $content, $indent) = @_;
37 my $id = $content->getid();
38 my $title = $content->gettitle();
39 for ($n=0; $n<$indent; $n++) {
40 print "\t";
41 }
42 print "$id = $title";
43 if ($content->isitem()) {
44 print " (" . $content->geturl();
45 if (length($content->getdate())) {
46 print " - " . $content->getdate();
47 }
48 print " - " . $content->getcontenttype() . ")";
49 }
50 print "\n";
51 unless ($content->iscontainer()) {
52 return;
53 }
54 @child_content_list = $mediaServer->getcontentlist(ObjectID => $id );
55 if (@child_content_list <= 0) {
56 return;
57 }
58 $indent++;
59 foreach my $child_content (@child_content_list) {
60 print_content($mediaServer, $child_content, $indent);
61 }
62 }
63
65 The package is a extention UPnP/AV media server, and a sub class of
66 Net::UPnP::AV::Content.
67
69 isitem - Check if the content is a item.
70 $isItem = $item->isisitem();
71
72 Check if the content is a item.
73
74 getid - Get the content ID.
75 $id = $item->getid();
76
77 Get the content ID.
78
79 gettitle - Get the content title.
80 $title = $item->gettitle();
81
82 Get the content title.
83
84 getdate - Get the content date.
85 $date = $item->getdate();
86
87 Get the content date.
88
89 geturl - get the content URL
90 $url = $item->getcontenttype();
91
92 Get the content URL.
93
94 getcontenttype - get the content type
95 $content_type = $item->getcontenttype();
96
97 Get the content type.
98
100 Net::UPnP::AV::Content
101
102 Net::UPnP::AV::Container
103
105 Satoshi Konno skonno@cybergarage.org
106
107 CyberGarage http://www.cybergarage.org
108
110 Copyright (C) 2005 by Satoshi Konno
111
112 It may be used, redistributed, and/or modified under the terms of BSD
113 License.
114
115
116
117perl v5.12.0 2009-07-27 Net::UPnP::AV::Item(3)