Пример #1
0
        private MediaContent CreateMediaContent(string serverAddress, Content file)
        {
            MediaContent mediaContent = new MediaContent()
            {
                Source = new Uri(serverAddress + "/ms/file/" + file.ID.ToString() + Path.GetExtension(file.Path)),
                Type   = this.ConvertContentTypeToString(file.ContentType),
                Name   = file.Name
            };

            if (file.ContentType == ContentType.Track)
            {
                Track track = file as Track;
                if (track != null && track.Artist != null && track.Album != null)
                {
                    mediaContent.AlbumName  = track.Album.Name;
                    mediaContent.ArtistName = track.Artist.Name;
                }
            }
            if (file.Preview != (Uri)null)
            {
                mediaContent.Thumbnail = new Uri(serverAddress + "/ms/cover/" + file.ID.ToString());
            }
            return(mediaContent);
        }
Пример #2
0
        public void PushMediaToTvQueue(IEnumerable <Content> files)
        {
            Logger.Instance.LogMessageFormat("[SmartView2][MultiScreenController]PushMediaToTv PushMediaToTvQueue...");
            this.TryStartMultiscreenApp();
            if (this.LoadState == LoadState.Loading)
            {
                if (files == null)
                {
                    return;
                }
                foreach (Content content in files)
                {
                    this.loadingQueue.Enqueue(new Tuple <Content, bool>(content, true));
                }
            }
            else
            {
                if (this.LoadState != LoadState.Loaded || files == null)
                {
                    return;
                }
                foreach (Content content in files)
                {
                    Content file = content;
                    if (Enumerable.FirstOrDefault <Content>((IEnumerable <Content>) this.shareFiles, (Func <Content, bool>)(f => f.ID == file.ID)) == null)
                    {
                        this.shareFiles.Add(file);
                    }
                }
                int           num  = 0;
                bool          flag = false;
                List <object> list = new List <object>();
                foreach (Content file in files)
                {
                    if (!File.Exists(file.Path))
                    {
                        flag = true;
                    }
                    else
                    {
                        MediaContent mediaContent    = this.CreateMediaContent(this.httpServer.ServerUrl, file);
                        var          fAnonymousType1 = new
                        {
                            index = num,
                            media = mediaContent
                        };
                        list.Add(fAnonymousType1);
                        ++num;
                    }
                }
                int addedFiles = this.mediaQueue == null?Enumerable.Count <Content>(files) : Enumerable.Count <Content>(Enumerable.Except <Content>(files, this.MediaQueue, (IEqualityComparer <Content>) new ContentCompare()));

                int repeatedFiles = Enumerable.Count <Content>(files) - addedFiles;
                this.OnPushToTvQueueEnded(addedFiles, repeatedFiles);
                this.appChannel.SendToHost(JsonConvert.SerializeObject(new
                {
                    type       = "mediaQueuePlayer.addItems",
                    queueItems = list
                }).ToString());
                if (!flag)
                {
                    return;
                }
                this.OnMultiScreenContentBroken();
            }
        }