Sunday 28 August 2011

How To: Create Themes for Smooth YouTube Downloader

Overview:
This post explains how to create Themes for Smooth YouTube Downloader.


How To:
A Theme in SYTD is basically an XML file "ThemeName_Theme.xml" that defines the colors for different screens.
All themes can be found in "\Program Files\SmoothYTDownloader\Themes\" for a normal default installation.
In the Theme folder you can find the set of images used by the theme, replace any image with another PNG image to use it instead of the default ones.

Note: names after the "_" character, cannot be changed.


You can start by copying one of the existing themes folders and change its name.
The name of the theme folder is what the user sees when he goes to the Theme Selection Screen.
Note: because of a limitation in the way installation CAB file is created, all files under the Theme directory must start with "ThemeName_"
You can see that naming convention in existing Themes.


The XML defines two types of Color Nodes (You can't change one of them to the other):

  1. A GlossyColor is like the color used for the Top Label, which is constructed from 4 colors blended from Top to Bottom, there are some bultin glossy colors that can be used easily, or you can define your own glossy color by defining the 4 colors (see example in the built in XML files)
  2. A Color is just a normal color, which is constructed from 3 Components, Red, Green, Blue each with a value from 0 to 255



The formatting of the XML is straight forward, it contains a Parent Node that defines an application Screen Name with child nodes that define names of elements on that page.


Child nodes of "SettingsPages" node will affect both, Themes and Download Service selection screens.


Note: You can't remove any element of the XML, if the XML wasn't loaded correctly, the Application will fallback to Default Theme


Make sure to read the comments in the existing XML files.


Finally:
If you'd like your design to be included in this post, please email it to me, wassim.khalil9@gmail.com

How To: Create Extensions for Smooth YouTube Downloader


Overview:
This page is for Developers who would like to create an Extension for Smooth YouTube Downloader, to support Searching and Downloading from Sites other than YouTube


Warning: Sites which contain adult content will not be supported nor included in the application !


How To:
The way extensions work is very straight forward, all you need to do is Create a class which Implements an Interface with few functions, then copy the resulting assembly to "Extensions" folder in "\Program Files\SmoothYTDownloader\Extensions" directory on device along (for a normal default installation) with the XML that defines the FileName of the assembly along with the Class FullName.


Stary by downloading this sample project, which contains The Source Code for "DailyMotion" Extension


Now I'll explain each method in the Interface and when it's called:


public interface IDownloadService
    {
        string DeveloperNotes { get; }
        string Name { get; }
        int SearchItemHeight { get; }
        int SearchItemSelectedHeight { get; }
        List<VideoFormat> GetAvailableFormats(VideoInfo videoInfo);
        string GetUniqueName(VideoInfo videoInfo);
        string GetVideoUrl(VideoInfo videoInfo);
        void OnFormatSelected(VideoInfo videoInfo, VideoFormat selectedFormat);
        List<VideoInfo> Search(string searchText, int currentPage, int maxResult);
    }


  • string DeveloperNotes { get; }

This will be displayed for users, when they click on "Show Developer Notes" in the "Download Service" selection screen, just in case there are some special cases in your Extension.





  • string Name { get; }
Name of Download Service, which will be Displayed in the "Download Service" selection screen
  • int SearchItemHeight { get; }
Normal item height in Search screen, this value usually depends on the height of thumbnails for the site.
  • int SearchItemSelectedHeight { get; }
Height of search item on selection, which will also Display the Duration of the video, so make sure to leave a space for that below the Thumbnail image.

  • List<VideoInfo> Search(string searchText, int currentPage, int maxResult);
This is the first main function, it's called when a user enters text in the search screen box, and hits Search.
It returns a list of VideoInfo objects, which will be passed later to other functions.
VideoInfo class can be found in the WassimK.Utils assembly, found in the sample project along with the Interface to implement.
For this function, you need to provide values for:
VideoInfo.Title // Title to be displayed in Search results
VideoInfo.Duration // Video Duration
videoInfo.ImageUrls // Urls for Thumbnails

And you can also save some values using:
VideoInfo["Key"] = "Value";
Usually you need to store video ID in this stage.

Parameters:
  1. currentPage: This value starts with 1 and is incremented every time the user hits, "Show More..." in search results, so the Search function should return the next set of Search Results depending on this value.
  2. maxResult: Maximum number of search results per search page.


  • List<VideoFormat> GetAvailableFormats(VideoInfo videoInfo);
This function is called when a user selects an item from Search Results.
videoInfo is the same object returned previously from the Search function above.
Depending on information stored in videoInfo object, you should be able to return a list of formats/qualities supported by selected video.
VideoFormat class has 3 properties that need to be set:
  1. ItemText: Text to Display in the list of Formats screen
  2. Value: Any hidden value developer decides to save and use later to help get the video URL.
  3. Url: This URL is only used to support "Copy Url" functionality, if left empty, the user will see a messagebox saying, "this video doesn't support copy url"
Bear in mind that this videoFormat object will be passed later to the OnFormatSelected function, to help get the correct video Url.


  • void OnFormatSelected(VideoInfo videoInfo, VideoFormat selectedFormat);
This function is called when the user select a format from the Formats Selection Screen.
selectedFormat object contains information saved previously in the GetAvailableFormats function.
Usually in this function, you need to store information in the videoInfo object, which will be passed later to GetVideoUrl function.
The information you need to save is the what will help you get the video url for the selected format.
  • string GetVideoUrl(VideoInfo videoInfo);
This function is called in two situations, when a user selects a format for the list of formats, or the application needs to continue a previously paused Download.
To resume downloads, VideoInfo object is serialized on application exit, and deserialized when the application is launched again, the object is then passed to this function to get the video url and continue downloading.
Important Note: Never store the URL in the videoInfo object, because most of sites copy the video to a cache server and sometimes this cache is cleaned up and the URL is not available anymore, always use the video ID along with other information, like Video format saved in the videoInfo object to get the video Url
  • string GetUniqueName(VideoInfo videoInfo);
This function is called whenever a user select a format from the format screen, it checks if a download of this particular video and format is in progress already. Usually, (videoInfo["ID"] + videoInfo["Format"]) is unique enough for each video.
XML file:
To be able to add your extension to the "Download Services" page you must include both the assembly and an XML file that defines the Download Service to the Root of Extensions folder

The format if the XML file is as follows:
<Service>
  <Assembly FileName="WassimK.DailyMotionService.dll" />
  <Class FullName="WassimK.SmoothYouTubeDownloader.Services.DailyMotionService" />
</Service>
It's straight forward, just one note Class FullName is the "NameSpace.ClassName"
Finally:
This was a very fast explanation and it's a bit ugly to be honest, but I hope it helps some of you, I believe the sample project code should cover most things in detail, if you have any questions or suggestions to improve the API, don't hesitate to write a comment here.

If you'd like your extension to be tested and included in next release, please email it to me, wassim.khalil9@gmail.com

TinyUrl for Windows Mobile

Overview:
This is a very simple application that uses TinyUrl services to shorten URLs on windows mobile.
Just unzip the file attached and copy it's contents to your device and run the application from there.



Download:
TinyUrl for Windows Mobile

Saturday 27 August 2011

[NEW VERSION 3.0] Smooth YouTube Downloader for Windows Mobile

Overview:
Smooth YouTube Downloader started as a personal project just for my personal use, then after a while I thought it might be useful to some people out there...
Basically, it allows you to download videos from YouTube (and potentially any other site) in different formats and qualities including MP3

The App was tested on Topaz (Touch Diamond 2) WVGA Windows Mobile 6.5



New V3.0 Features:

  • YouTube Feeds, for example (Most Popular, Music, This Week) etc...
  • History list of search.
  • Ability to set maximum number of simultaneous downloads, and queue the rest.
  • Ability to set the Application you want to open URLs with using an easy file dialog from the UI (Settings Page)
  • You can also set the "Default Format to download" from the UI (Settings Page)
  • Enhanced Performance

Requirements:
  • A working windows mobile 5, 6, 6.5
  • .NET Compact Framework 3.5


Features:
  • Shows thumbnails in the search results.
  • Ability to download multiple videos at the same time.
  • Ability to pause/resume downloads after you exit and run the application again.
  • A very nice UI and cool transitions between different screens of the app.
  • Ability to expand search results.
  • Ability to choose video format/quality including mp3.
  • Improved QVGA screens support.
  • Ability to switch between full screen and normal mode.
  • Ability to copy download URL.
  • Supports keeping the device awake while downloads are running, so the WiFi connection is not lost.
  • Supports installing extensions to support any other video site.
  • Supports Themes.
  • Supports Searching/Downloading from DailyMotion.com
  • Supports Searching/Downloading from Current.com
  • Open YouTube videos with CorePlayer, TCPMP or any other application you specify.
  • Ability to Shorten URLs on Copy/Open (for using with CorePlayer which doesn't support long URLs)
Screenshots:






























Advanced Hidden Settings:
Some settings cannot be set in the UI, so you can get to those settings by editing the XML file created in the Application directory, after saving settings of the application for the first time.
To understand the options available, read the file SYTDSettings_SAMPLE.xml which you can find in the application installation directory.


ONLY for CorePlayer Users: It doesn't support long youtube URLs so to Shorten URLs on Copy/Open use the settings below:


<ShortenAssemblyFileName>\Program Files\SmoothYTDownloader\WassimK.TinyUrl.dll</ShortenAssemblyFileName>
<ShortenClassFullName>WassimK.TinyUrlApi</ShortenClassFullName>
<ShortenMethodName>Shorten</ShortenMethodName>
<ShortenServices>YouTube</ShortenServices>

How can you contribute:
If you're a Developer and would like to learn how to create Extensions to support sites other than YouTube, Click Here
If you'd like to learn how to create new Themes, Click Here


Download:
SmoothYouTubeDownloader.V3.0.cab