Syncing YouTube Videos to iTunes and Zune
iTunes and Zune provide different mechanisms for syncing videos, but we will build one interface that we can use for both videos, to keep a standard mechanism for syncing files (see Example 4-35 and Example 4-36). This interface will sync files for a given device based on the file path.
Example 4-35.
C# interface for syncing to iTunes and Zune
interface IVideoService
{
void Sync(string filePath);
}Example 4-36.
Visual Basic interface for syncing with iTunes and Zune
Friend Interface IVideoService Sub Sync(ByVal filePath As String) End Interface
Syncing Videos to iTunes
To sync YouTube videos to iTunes, we'll use the iTunes COM interop library. This library is automatically included when you install iTunes, and you can add it to your Visual Studio project by clicking in the Solution Explorer and selecting Add Reference.... Then, click the COM tab and select the iTunes 1.11 Type Library, which is a COM wrapper class that simplifies automating iTunes with .NET code.
As you can see in Example 4-37 and Example 4-38, we import the iTunesLib namespace and create a private member named iTunes.
Example 4-37.
C# class declaration for iTunes class
using iTunesLib; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access