|
// Written by Shai Raiten: http://blogs.microsoft.co.il/blogs/shair/
using System;
using System.Collections;
using System.IO;
using KinectReception.Enums;
namespace KinectReception.Managers
{
public static class VideoManager
{
/// <summary>
/// Define the type of video you want to play
/// If you ask for out video and there isn't one return null - Stop Video and
/// start showing Kinect Image
/// If you ask for in video and there isn't one then return random video.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static Uri GetVideo(VideoType type)
{
if (string.IsNullOrEmpty(Properties.Settings.Default.VideosLibraryFolder) ||
!Directory.Exists(Properties.Settings.Default.VideosLibraryFolder))
return null;
else
{
string value = null;
switch (type)
{
case VideoType.In:
value = Properties.Settings.Default.VideosLibraryInFile;
return string.IsNullOrEmpty(value) || !File.Exists(value) ?
CollectRandomMovie() : new Uri(value);
case VideoType.Out:
value = Properties.Settings.Default.VideosLibraryOutFile;
return string.IsNullOrEmpty(value) || !File.Exists(value) ?
null : new Uri(value);
default:
return CollectRandomMovie();
}
}
}
private static Uri CollectRandomMovie()
{
var movies = new ArrayList();
foreach (var filter in Properties.Settings.Default.VideoFilter)
movies.AddRange(Directory.GetFiles(Properties.Settings.Default.VideosLibraryFolder,
filter));
if (movies.Count == 0) return null;
var rnd = new Random();
return new Uri(movies[rnd.Next(movies.Count)].ToString());
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Shai Raiten is VS ALM MVP, currently working for Sela Group as a ALM senior consultant and trainer specializes in Microsoft technologies especially Team System and .NET technology. He is currently consulting in various enterprises in Israel, planning and analysis Load and performance problems using Team System, building Team System customizations and adjusts ALM processes for enterprises. Shai is known as one of the top Team System experts in Israel. He conducts lectures and workshops for developers\QA and enterprises who want to specialize in Team System.
My Blog: http://blogs.microsoft.co.il/blogs/shair/