Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Kinect Reception

, 12 Jan 2012 Ms-PL
TV Screen in the Reception, When nothing happens (no one is in the reception) we can display videos on the screen but when someone enters the frame show him the Kinect Image, and if the user is doing something funny, capture his image and save it.
// 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.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Shai Raiten
Architect Sela
Israel Israel
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/
Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141216.1 | Last Updated 12 Jan 2012
Article Copyright 2011 by Shai Raiten
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid