|
|
Article
|
| The Beyond TV SDK - Tutorial 2: Reading and writing
media properties |
Posted:
June 9, 2004
|
By: Richard Kuo |
|
Intro
OK folks! This is our second look at how you can leverage the power
of Beyond TV in your own code using the methods provided by the
Beyond TV SDK. If you are just getting started, please take
a look at the first tutorial to
get a blow by blow walkthrough of how to set up a fully working
Beyond TV sample project. This tutorial assumes you understand
all of the setup and license management that we walked you through
in the first Beyond TV SDK tutorial.
Today we'll cover one of the most frequently asked questions
by developers...how do I read out all the media properties in a
recording and how do I add my own? This particular question gets
asked a lot by Beyond TV users for several reasons.
Some users want to catalog the data when they store their recordings
in their own personal spreadsheets or databases. Other users like
to edit or manipulate their recordings with third party programs
that unfortunately don't know how to keep that metadata around
in the file after editing it. And still other users want to be
able to use that data to display in their own specially crafted
applications or frontends.
Point is, there are plenty of good reasons to read and write the data.
It's my distinct pleasure to show you today how to do this with
the SDK. in fact, it's so easy that some of you might just
be kicking yourself when I'm done walking you guys through it!
Just like the first tutorial, with a couple of small differences
If you went through the first tutorial, you already created a solution
and a project named BTVSDKSample1. Using your existing solution,
go ahead and create another
project exactly like the BTVSDKSample1 project
you created, except this time named BTVSDKSample2.
Next, follow the same procedure you did with BTVSDKSample1
to add references to the Beyond TV SDK web services, except
this time, you'll be referencing BTVLicenseManager.asmx, BTVDispatcher.asmx,
and BTVLibrary.asmx. Don't forget the steps detailed in the first
tutorial, especially the namespace changes!
As a side note, we don't actually use BTVDispatcher.asmx in this
tutorial, but for the sake of consistency, we reference this class
and keep the data type definitions here like we did in the first
tutorial for the sake of consistency. It's not good to create multiple
projects and have to wonder where you decided to define the PropertyBag
types in each project.
New code
OK, for this new walkthrough, you're going to need to pick a recording
that you would like to edit. Many of the methods
in BTVLibrary take the fully qualified path to a recording as a
unique identifier for a recording. The property is called "FullName"
in Beyond TV.
For security reasons, Beyond TV will not allow you to reference files
that aren't in a directory that Beyond TV is aware of. So make
sure your file or recording can already be seen by Beyond TV in
one of its video folders.
Let's take a look at our new source example.
 As in the first tutorial, edit the networkLicense variable so that
it represents your license. Next, edit the fullName variable so
that it points to the recording you want to edit.
In this example, we first call the GetMediaByFullName method of BTVLibrary.
This retrieves all properties of the recording. We then dump them
to the console, as shown below.

OK. That was just a little too easy, wasn't it? If all you want to
do is look at the metadata for each recording, you can easily dump
or translate this data into any format you wish. I'd recommend
using the XML classes in .NET to dump the data if that's where
you are heading with your development. By the way, in case you're
curious what all of these properties mean and what they do, a thoroughly
documented explanation of each property is available in the Beyond
TV SDK documentation.
The next task is to actually edit one of these properties. As it
turns out, this really isn't much harder. The PVSPropertyBag base type that is used all over the place in the
Beyond TV SDK isn't very friendly for actually manipulating
properties. We probably should change this at some point, but for
the moment, the best thing for you to do is take the properties
and copy them into a friendlier collection or wrapper class that
you write yourself. In the source code example, we just dump our
PVSPropertyBag into the native ArrayList class in .NET. We then
set the "EpisodeDescription" property and create a new PVSPropertyBag.
We then pass this PVSPropertyBag into the EditMedia method call.
And voila, we are done!
It's probably worth mentioning that some of the media properties
are read-only. For example, duration is an inherent
property of a media file and you won't be able to set a property
to change that. It
doesn't hurt to set these types of properties through the SDK,
but it doesn't actually do anything.
At any rate, let's take a look at the final result.

As you can see, the description has been successfully edited.
OK, wow. Wasn't that easy? If you hadn't realized by now how simple
Beyond TV makes things at every level, you're probably starting
to appreciate it now. Editing recording metadata is a cinch using
the Beyond TV SDK.
That's all for now, folks. Keep those questions coming in our forums
and get your ideas rolling with the power of the Beyond TV SDK!
Discuss it in our forums.
|