Esempio n. 1
0
        public PlayListItem Create(string filePath, PlayList playList)
        {
            var isStreamed = filePath.ToLower().Contains("http://") || 
                filePath.ToLower().Contains("https://") ||
                filePath.ToLower().Contains("ftp://");

            var plItem = new PlayListItem
            {
                Guid = Guid.NewGuid().ToString(),
                FileName = Path.GetFileName(filePath),
                FilePath = filePath,
                PlayListGuid = playList.Guid,
                Source = isStreamed ? PlayListItemSource.Streamed : PlayListItemSource.Disk,
            };

            plItem.ThumbnailPath = _thumbnailService.GenerateForFile(filePath, plItem.Source);
            if (PathHelper.FileIsLocked(filePath))
                return null;

            var tagFile = _fileTagService.GetTag(plItem.FilePath, plItem.Source);
            if (tagFile == null)
                return null;

            plItem.Type = tagFile.Type;
            plItem.TagName = tagFile.Tag.Title;
            plItem.FullScreen = plItem.Type != PlayListItemType.Audio;
            
            return plItem;
        }
Esempio n. 2
0
        public PlayListItem GetByFileName(string fileName, PlayList playList)
        {
            if (playList == null)
                return null;

            return Get(playList).FirstOrDefault(pi => pi.FileName.Equals(fileName, StringComparison.OrdinalIgnoreCase));
        }
Esempio n. 3
0
        public IEnumerable<PlayListItem> Get(PlayList playList)
        {
            if (playList == null)
                return null;

            return _playListService.GetByName(playList.Name).Items;
        }
        public async Task ImportFromDirectory(string path, PlayList playList)
        {
            if (!Directory.Exists(path))
                return;

            var allFiles = GetFiles(path, new[] {"*.mp3", "*.mp4", "*.wma"}, SearchOption.AllDirectories).ToList();
            if (allFiles.Any())
                await ImportFiles(allFiles, playList);
        }
Esempio n. 5
0
        public PlayList Insert(PlayList playList)
        {
            if (Get().FirstOrDefault(p => p.Name.Equals(playList.Name, StringComparison.OrdinalIgnoreCase)) == null)
            {
                PlayListCache.PlayLists.Add(playList);
            }

            return playList;
        }
        public async Task ImportFiles(IEnumerable<String> filePaths, PlayList playList)
        {
            var files = filePaths.ToArray();
            var max = files.Count();
            
            for (var i = 0; i < max; i++)
            {
                var filePath = files[i];
                var currentItem = i + 1;
                UpdateProgress(String.Format("Importing - {0} / {1}", currentItem, max), currentItem, max, 0);

                var fileName = Path.GetFileName(filePath);
                var newFilePath = Settings.Default.ImportLocation + "\\" + fileName;

                if (!File.Exists(newFilePath))
                    await
                        FileEx.CopyAsync(filePath, newFilePath,
                            new Progress<double>(
                                p => UpdateProgress(String.Format("Copying {0}", newFilePath), currentItem, max, p)));
                
                _playListItemService.AddToPlaylistUsingFilePath(newFilePath, playList);
            }
        }
 public async Task ImportFiles(string filePath, PlayList playList)
 {
     await ImportFiles(new[] { filePath }, playList);
 }
Esempio n. 8
0
 public void Delete(PlayList playList)
 {
     PlayListCache.PlayLists.Remove(playList);
 }
Esempio n. 9
0
 public void Update(PlayList playList)
 {
     Delete(playList);
     Insert(playList);
 }
Esempio n. 10
0
        public void AddToPlaylistUsingFilePath(string path, PlayList playList)
        {
            if (File.Exists(path))
            {
                var playListItem = GetByFileName(path, playList) ?? Create(path, playList);

                if (playListItem != null)
                    Insert(playListItem, playList);
            }
        }
Esempio n. 11
0
 public void Insert(PlayListItem playListItem, PlayList playList)
 {
     if (!playList.Items.Contains(playListItem))
         playList.Items.Add(playListItem);
 }
Esempio n. 12
0
        public void AddToPlaylistUsingUrl(string url, PlayList playList)
        {
            var playListItem = GetByFileName(url, playList) ?? Create(url, playList);

            if (playListItem != null)
                Insert(playListItem, playList);
        }
Esempio n. 13
0
 public void AddRangeToPlaylist(string[] filePaths, PlayList playList)
 {
     foreach (var filePath in filePaths)
         AddToPlaylistUsingFilePath(filePath, playList);
 }