EF Media Player 3: The Code; The Idea

In EF Media Player 3, the implementation of videos viewing history recording and video bookmarking takes me about two days to figure out the way to do it.

Video Bookmarking in EF Media Player 3

Video Bookmarking

In order to have those features, storage is a important issue. The history and bookmark records need to be stored somewhere. There are a few approaches to this problem. One is of course the serialization. I can basically store the history and bookmark by doing serialization. This approach was tried and successfully implemented by our CS2103 team when we’re trying to store the data of our apps. In C#, thanks to the .NET library, I can actually store the data and records in settings as well. All these stored records will be persisted between application execution sessions.

Loading Values from Settings
System.Collections.Hashtable savedViewedVideos = new System.Collections.Hashtable();
// Try to load previously saved viewed videos (if any) to the list.
if (Properties.Settings.Default[“viewedVideosList”] != null){
foreach (String recordEntry in Properties.Settings.Default.viewedVideosList){
string[] entryBreakdown = recordEntry.Split(‘*’);
if (entryBreakdown[1].Equals(VideoRecordType.NEWLY_ADDED.ToString())) savedViewedVideos.Add(entryBreakdown[0], VideoRecordType.PREVIOUSLY_PLAYED.ToString());
savedViewedVideos.Add(entryBreakdown[0], entryBreakdown[1]);

I actually use a small trick here by using array list as a name-value collection. Every element in the array list is a string containing an asterisk symbol. Before the asterisk, it is the file path of the video and after it will be the video record type:

private enum VideoRecordType{

Storing Values to Settings
Why don’t I use the name-value collection which is also provided by .NET? The reason is simple. This is because the name-value collection doesn’t have a schema predefined. So, why do we need a schema here? This is because all the values stored in the settings are stored in XML format in the user.config file. Hence, without a schema defined, the values cannot be updated later using Properties.Settings.Default.Save();. Fortunately, the schema of the array list is provided. So, in order to avoid the troubles of defining schema for the name-value collection, I chose array list here.

Currently, there are still a lot of people discussing why they can’t update the values stored in the name-value collection and other similar data types. I am not sure about the causes of their problems but I think not having a schema for the data types they are using may be a reason for some of them.

More about settings: http://msdn.microsoft.com/en-us/library/aa730869(VS.80).aspx


One thought on “EF Media Player 3: The Code; The Idea

  1. Pingback: EF Media Player 3 « cuteprogramming

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s