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

(Hybrid Smart Client) RSS Media Player

, 9 Mar 2009
A WPF application for viewing RSS video feeds. Built using the MVVM pattern.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RSSVideoPlayer.Model;
using System.Collections.ObjectModel; 
using RSSVideoPlayer.Common;
using System.Windows.Input;
using System.IO;
using Microsoft.Win32;

namespace RSSVideoPlayer.ViewModel
    class LibraryViewModel : TabViewModel
        private MediaItem  _MediaItems;
        private Data.LibraryRepository repository;
        public LibraryViewModel()
            repository = new RSSVideoPlayer.Data.LibraryRepository();
            base.TabName = "Library";
        public LibraryViewModel(string StartingFolder)
            repository = new RSSVideoPlayer.Data.LibraryRepository(StartingFolder);
            base.TabName = "Library";

        public string FolderPath
            get { return repository.FilePath; }
                repository.FilePath = value; 
                repository = new RSSVideoPlayer.Data.LibraryRepository(FolderPath);

        public ObservableCollection<MediaItem> MediaItems
        { get { return repository.MediaItems; }}

        private MediaItem _selectedItem;
        public MediaItem SelectedItem
            get {return _selectedItem; }
            set { _selectedItem = value; OnMediaChanged(SelectedItem.file); }

        #region "Commands"
        private RelayCommand _cmdDirectory;

        public ICommand cmdDirectory
                if (_cmdDirectory == null)
                    _cmdDirectory = new RelayCommand(param => this.ShowDirectory());
                return _cmdDirectory;

        public void ShowDirectory()
            OpenFileDialog flDlg = new OpenFileDialog();
            flDlg.InitialDirectory = FolderPath;
            flDlg.Title = "Please choose a folder";
            flDlg.CheckFileExists = false;

            flDlg.FileName = "[Get Folder…]";
            flDlg.Filter = "Folders|no.files";

            if ((bool)flDlg.ShowDialog())
                string path = System.IO.Path.GetDirectoryName(flDlg.FileName);
                if (path != null && path.Length > 0)
                    FolderPath = path;


        #region "Media changing event"
        public void OnMediaChanged(string MediaSource)
            if (MediaChanged != null)
                MediaChanged(this, new Common.MediaChangedEventArgs(MediaSource));
        public event EventHandler<Common.MediaChangedEventArgs> MediaChanged;

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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Software Developer (Senior) Anytime Fitness
United States United States
No Biography provided
Follow on   Twitter

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 9 Mar 2009
Article Copyright 2009 by Paul_Wade
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid