public ProductAllPhotoMessage BuildMessage()
        {
            db = new MarketBotDbContext();

            PhotoListMedia = new List <InputMediaBase>(10);

            MediaGroupPhoto = new MediaGroup();

            MediaGroupPhoto.FsIdTelegramFileId = new Dictionary <int, string>(10);

            GetPhotoList();


            MediaGroupPhoto.ListMedia = PhotoListMedia;

            BackBtn = new Telegram.Bot.Types.InlineKeyboardButtons.InlineKeyboardCallbackButton("Назад", BuildCallData(Bot.ProductBot.GetProductCmd, ProductBot.ModuleName, ProductId));

            base.TextMessage = "Вернуться назад";

            base.MessageReplyMarkup = new InlineKeyboardMarkup(
                new[] {
                new[]
                {
                    BackBtn
                },
            });

            return(this);
        }
Exemplo n.º 2
0
        public void CanAddFileContentToExternalDb()
        {
            using (var db = CreateDbContext <SpikesExternalDbContext>())
            {
                var mediaGroup = new MediaGroup();
                db.FileContents.AddRange(new[]
                {
                    new FileContent
                    {
                        FileOwnerType = "Customer",
                        ContentType   = "application/image",
                        ImageSize     = ImageSize.Thumbnail,
                        MediaGroup    = mediaGroup
                    },
                    new FileContent
                    {
                        FileOwnerType = "Customer",
                        ContentType   = "application/image",
                        ImageSize     = ImageSize.Full,
                        MediaGroup    = mediaGroup
                    }
                });
                db.SaveChanges();
            }

            using (var db = CreateDbContext <SpikesExternalDbContext>())
            {
                Assert.That(db.FileContents.Count(), Is.EqualTo(2));
                Assert.That(db.FileContents.Select(fc => fc.MediaGroupId).Distinct().Count(), Is.EqualTo(1));
            }
        }
        /// <summary>
        /// creates media, if the first media, creates also media group
        /// </summary>
        /// <param name="createDto"></param>
        /// <returns>media id</returns>
        public async Task <int> CreateAsync(MediaCreateDto createDto)
        {
            // TODO Armin -> maybe we should seperate create and add method ?
            if (createDto.GroupId == 0)
            {
                MediaGroup mediaGroup = new MediaGroup {
                    Type = createDto.GroupType
                };
                await _context.MediaGroups.AddAsync(mediaGroup);

                await _context.SaveChangesAsync();

                createDto.GroupId = mediaGroup.Id;
            }

            Media media = new Media
            {
                Source   = createDto.Source,
                Url      = createDto.Url,
                Type     = createDto.Type,
                GroupId  = createDto.GroupId,
                PublicId = createDto.PublicId
            };

            await _context.Medias.AddAsync(media);

            await _context.SaveChangesAsync();

            return(media.Id);
        }
 public bool Edit(MediaGroup obj)
 {
     if (_mediaGroupService.UpdateEntity(obj))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 5
0
 public Media()
 {
     Tags       = new List <string>();
     Enabled    = true;
     MediaType  = MediaType.LiveTv;
     Lang       = "fr";
     IsValid    = true;
     MediaGroup = new MediaGroup();
 }
Exemplo n.º 6
0
        public void MediaTest()
        {
            PicasaEntry target   = new PicasaEntry(); // TODO: Initialize to an appropriate value
            MediaGroup  expected = new MediaGroup();
            MediaGroup  actual;

            target.Media = expected;
            actual       = target.Media;
            Assert.AreEqual(expected, actual);
        }
        /// <summary>
        /// mocks deleting media group
        /// </summary>
        /// <param name="id">mock group id</param>
        public async Task DeleteGroupByIdAsync(int id)
        {
            MediaGroup group = await Task.Run(() => { return(_groups.Where(g => g.Id == id).First()); });

            if (group == null)
            {
                throw new KeyNotFoundException($"MediaGroup with: {id} could not be found!");
            }

            _groups.Remove(group);
        }
        /// <summary>
        /// deletes group by id
        /// </summary>
        /// <param name="id">media group id</param>
        public async Task DeleteGroupByIdAsync(int id)
        {
            MediaGroup mediaGroup = await _context.MediaGroups.FindAsync(id);

            if (mediaGroup == null)
            {
                throw new KeyNotFoundException($"Media group with id: {id} could not be found!");
            }

            _context.MediaGroups.Remove(mediaGroup);
            await _context.SaveChangesAsync();
        }
Exemplo n.º 9
0
        public PicasaWebPhoto(PicasaEntry photo, string albumName)
        {
            PhotoAccessor pa = new PhotoAccessor(photo);

            this.m_accessId  = pa.Id;
            this.m_media     = photo.Media;
            this.m_id        = photo.Id.Uri.ToString();
            this.m_title     = photo.Title.Text;
            this.m_albumName = albumName;
            this.m_height    = pa.Height;
            this.m_width     = pa.Width;
            this.m_uploaded  = photo.Updated.ToShortDateString() + " " + photo.Updated.ToShortTimeString();
            this.m_location  = (string)photo.Media.Content.Attributes["url"];
            pa = null;
        }
Exemplo n.º 10
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                base.OnNavigatedTo(e);
                var currentView = SystemNavigationManager.GetForCurrentView();

                currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
                currentView.BackRequested += backButton_Tapped;
                mediaGroup = e.Parameter as MediaGroup;
                await UpdateMediaElementSource();
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 11
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     int MediaID = 0;
     if (ViewState["MediaID"] != null)
     {
         MediaID = Int32.Parse(ViewState["MediaID"].ToString());
     }
         MediaGroup mediagroup = new MediaGroup
         {
             MediaID = MediaID,
             MediaTitle = txtMediaTitle.Text,
             MediaType = lstMediaType.SelectedValue,
             ProductID = Int32.Parse(txtProductID.Text),
             Active = chkActive.Checked
         };
         mediagroup.Save();
         //BindData();
         Response.Redirect("/editvideomain.aspx");
 }
Exemplo n.º 12
0
        //新增媒体群组
        public IActionResult ToAddGroup(string id, string pId)
        {
            MediaGroup obj = new MediaGroup();

            obj.mgroup_name = "new Group";
            if (!Shared.IsNum(id))
            {
                obj.parent_id = 0;
                obj.group_id  = Shared.ExtractNum(id);
            }
            else
            {
                obj.parent_id = Shared.ExtractNum(id);
                if (!Shared.IsNum(pId))
                {
                    obj.group_id = Shared.ExtractNum(pId);
                }
                else
                {
                    string            url         = string.Format("{0}?id={1}", group_url_get, Shared.ExtractNum(pId));
                    string            jsonStr     = HttpHelper.HttpGet(url);
                    List <MediaGroup> _mediaGroup = JsonConvert.DeserializeObject <List <MediaGroup> >(jsonStr);
                    if (_mediaGroup.Count > 0)
                    {
                        obj.group_id = _mediaGroup[0].group_id;
                    }
                }
            }

            string postData = JsonConvert.SerializeObject(obj);
            int    bigId    = Convert.ToInt32(HttpHelper.HttpPost(group_url_add, postData));

            if (bigId > 0)
            {
                obj.id = bigId;
                return(Json(obj));
            }
            else
            {
                return(Json(false));
            }
        }
Exemplo n.º 13
0
        public async Task RemoveMedia(MediaGroup mediaG)
        {
            try
            {
                MediaGroup toDeleteMediaG = MediaGroupList.Where(x => x.CompostionFileName == mediaG.CompostionFileName).FirstOrDefault();
                using (var db = new MediaContext())
                {
                    db.MediaGroups.Remove(toDeleteMediaG);
                    db.SaveChanges();
                }
                MediaGroupList.Remove(toDeleteMediaG);
                StorageFile fileToDelete = await localFolder.GetFileAsync(mediaG.CompostionFileName + ".cmp");
                await fileToDelete.DeleteAsync();
            }
            catch (Exception ex)
            {


            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 修改媒体群组信息
        /// </summary>
        /// <param name="id">媒体群组的id</param>
        /// <param name="mgroup_name">媒体群组名称</param>
        /// <returns></returns>
        public IActionResult ToPutGroup(int id, string mgroup_name)
        {
            string            url         = string.Format("{0}?id={1}", group_url_get, id);
            string            jsonStr     = HttpHelper.HttpGet(url);
            List <MediaGroup> _mediaGroup = JsonConvert.DeserializeObject <List <MediaGroup> >(jsonStr);

            if (_mediaGroup.Count > 0)
            {
                MediaGroup obj = _mediaGroup[0];
                obj.mgroup_name = mgroup_name;
                obj.create_time = DateTime.Now;
                string postData = JsonConvert.SerializeObject(obj);
                bool   result   = Convert.ToBoolean(HttpHelper.HttpPut(group_url_edit, postData));
                return(Json(result));
            }
            else
            {
                return(Json(false));
            }
        }
Exemplo n.º 15
0
        private static void AddMedia(Uri playlist, M3U8TagInstance gt, IDictionary <string, MediaGroup> audioStreams)
        {
            var key       = gt.Attribute(ExtMediaSupport.AttrGroupId).Value;
            var uriString = gt.AttributeObject(ExtMediaSupport.AttrUri);
            Uri uri       = null;

            if (null != uriString)
            {
                uri = new Uri(playlist, new Uri(uriString, UriKind.RelativeOrAbsolute));
            }

            var str = gt.AttributeObject(ExtMediaSupport.AttrLanguage);
            var playlistSubStream1 = new PlaylistSubStream
            {
                Type         = gt.AttributeObject(ExtMediaSupport.AttrType),
                Name         = key,
                Playlist     = uri,
                IsAutoselect = IsYesNo(gt, ExtMediaSupport.AttrAutoselect),
                Language     = str?.Trim().ToLower()
            };

            var        playlistSubStream2 = playlistSubStream1;
            MediaGroup mediaGroup;

            if (!audioStreams.TryGetValue(key, out mediaGroup))
            {
                mediaGroup = new MediaGroup()
                {
                    Default = playlistSubStream2
                };
                audioStreams[key] = mediaGroup;
            }
            if (IsYesNo(gt, ExtMediaSupport.AttrDefault))
            {
                mediaGroup.Default = playlistSubStream2;
            }
            var index = gt.Attribute(ExtMediaSupport.AttrName).Value;

            mediaGroup.Streams[index] = playlistSubStream2;
        }
        public int Add(MediaGroup mediaGroup)
        {
            int bigId = (int)_mediaGroupService.InsertBigIdentity(mediaGroup);

            return(bigId);
        }
        /// <summary>
        /// Initialize In memory DB
        /// </summary>
        /// <param name="context">Medias Context</param>
        public static void Initialize(IMediasRepository repo)
        {
            var mediaGroups = new MediaGroup[]
            {
                new MediaGroup()
                {
                    Id   = Guid.Parse("d28888e9-2ba9-473a-a40f-e38cb54f9b35"),
                    Name = "Shield Hero",
                    Type = "Series"
                },
                new MediaGroup()
                {
                    Id   = Guid.Parse("da2fd609-d754-4feb-8acd-c4f9ff13ba96"),
                    Name = "Your Name",
                    Type = "Movie"
                },
                new MediaGroup()
                {
                    Id   = Guid.Parse("24810dfc-2d94-4cc7-aab5-cdf98b83f0c9"),
                    Name = "Goblin Slayer",
                    Type = "Series"
                },
                new MediaGroup()
                {
                    Id   = Guid.Parse("2902b665-1190-4c70-9915-b9c2d7680450"),
                    Name = "Fairy Tail",
                    Type = "Series"
                },
                new MediaGroup()
                {
                    Id   = Guid.Parse("d106b8e5-11e8-4f83-9b33-db7e2be73102"),
                    Name = "JoJo's Bizarre Adventure: Golden Wind",
                    Type = "Series"
                }
            };

            foreach (var mg in mediaGroups)
            {
                repo.AddMediaGroup(mg);
            }
            repo.SaveChanges();

            var medias = new Media[]
            {
                new Media()
                {
                    Id           = Guid.Parse("5b1c2b4d-48c7-402a-80c3-cc796ad49c6b"),
                    MediaGroupId = Guid.Parse("d28888e9-2ba9-473a-a40f-e38cb54f9b35"),
                    Title        = "EP 1 The Shield Hero",
                    Thumbnail    = "https://image.tmdb.org/t/p/w320_and_h180_bestv2/3UyyCIoFdWDoHpt4jk6wlWAKaex.jpg",
                    Description  = "While in the library, college student Naofumi Iwatani finds a fantasy book about \"Four Heroes\"; The Spear, Sword, Bow, and Shield."
                },
                new Media()
                {
                    Id           = Guid.Parse("8ae54711-7084-46ff-bf9e-9092d0ab37b8"),
                    MediaGroupId = Guid.Parse("d28888e9-2ba9-473a-a40f-e38cb54f9b35"),
                    Title        = "EP 2 The Slave Girl",
                    Thumbnail    = "https://images.attvideo.com/image/e_qKSpECrgM/raphtalia-kawaii-loli-tate-no-yuusha-no-nariagari-ep-2.jpg",
                    Description  = "Unable to use a sword, Naofumi searches for a partner, but he can only afford a sickly demi-human slave."
                },
                new Media()
                {
                    Id           = Guid.Parse("57970c37-a716-4668-ba9d-cabd79948e94"),
                    MediaGroupId = Guid.Parse("d28888e9-2ba9-473a-a40f-e38cb54f9b35"),
                    Thumbnail    = "https://dg31sz3gwrwan.cloudfront.net/screen/6983643/1_iphone.jpg",
                    Title        = "EP 3 Wave of Catastrophe",
                    Description  = "Naofumi and Raphtalia become good partners but must prepare themselves to fight an incoming wave."
                },
                new Media()
                {
                    Id           = Guid.Parse("d8663e5e-7494-4f81-8739-6e0de1bea7ee"),
                    MediaGroupId = Guid.Parse("da2fd609-d754-4feb-8acd-c4f9ff13ba96"),
                    Thumbnail    = "https://d2e111jq13me73.cloudfront.net/sites/default/files/styles/review_gallery_carousel_slide_thumbnail/public/screenshots/csm-movie/your-name-ss1.jpg?itok=2vfTpJIX",
                    Title        = "Your Name",
                    Description  = "A teenage boy and girl embark on a quest to meet each other for the first time after they magically swap bodies."
                },
                new Media()
                {
                    Id           = Guid.Parse("d173e20d-159e-4127-9ce9-b0ac2564ad97"),
                    MediaGroupId = Guid.Parse("24810dfc-2d94-4cc7-aab5-cdf98b83f0c9"),
                    Thumbnail    = "https://dg31sz3gwrwan.cloudfront.net/screen/6758282/1_iphone.jpg",
                    Title        = "EP 1 The Fate of Particular Adventurers",
                    Description  = "On Priestes first official adventure, she and her party of novices fall victim to murderous goblins."
                },
                new Media()
                {
                    Id           = Guid.Parse("B79A54F9-45A2-421B-735E-08D713CEC375"),
                    MediaGroupId = Guid.Parse("24810dfc-2d94-4cc7-aab5-cdf98b83f0c9"),
                    Thumbnail    = "https://image.tmdb.org/t/p/w320_and_h180_bestv2/e3BKChEdCLFmD1CcnkHWiUSuLTO.jpg",
                    Title        = "EP 2 Goblin Slayer",
                    Description  = "As Priestess accompanies Goblin Slayer on his intentionally specific quests."
                },
                new Media()
                {
                    Id           = Guid.Parse("30189F54-B7D8-4726-CD85-08D713DE3475"),
                    MediaGroupId = Guid.Parse("24810dfc-2d94-4cc7-aab5-cdf98b83f0c9"),
                    Thumbnail    = "https://image.tmdb.org/t/p/w320_and_h180_bestv2/xVfJgU9sAFyRPY2gKCkzLjDixsA.jpg",
                    Title        = "EP 3 Unexpected Visitors",
                    Description  = "Three adventurers, High Elf Archer, Dwarf Shaman, and Lizardman Priest, request Goblin Slayer's aid to stop a destructive demon lord."
                },
                new Media()
                {
                    Id           = Guid.Parse("493c3228-3444-4a49-9cc0-e8532edc59b2"),
                    MediaGroupId = Guid.Parse("2902b665-1190-4c70-9915-b9c2d7680450"),
                    Thumbnail    = "https://d2e111jq13me73.cloudfront.net/sites/default/files/styles/review_gallery_carousel_slide_thumbnail/public/screenshots/csm-tv/fairy-tail-ss5.jpg?itok=wy2HxSkX",
                    Title        = "EP 1 The Fairy Tail",
                    Description  = "When a phony wizard lures Lucy onto his ship with the promise of getting into the guild, her new friends must bail her out."
                },
                new Media()
                {
                    Id           = Guid.Parse("3706ded9-30ca-4b90-971c-924d330edb96"),
                    MediaGroupId = Guid.Parse("2902b665-1190-4c70-9915-b9c2d7680450"),
                    Thumbnail    = "https://images.attvideo.com/image/bVMH3H84shM/fairy-tail-episode-2-english-dubbed.jpg",
                    Title        = "EP 2 Fire Dragon, Monkey, and Bull",
                    Description  = "DescriptionNatsu and Happy take Lucy to their headquarters to meet the rowdy members of Fairy Tail."
                },
                new Media()
                {
                    Id           = Guid.Parse("f064bae0-483b-4db9-b06a-c85129803fdb"),
                    MediaGroupId = Guid.Parse("2902b665-1190-4c70-9915-b9c2d7680450"),
                    Thumbnail    = "https://www.myanime.co/file/cache/5jo46ejjxv0-320x180.jpg",
                    Title        = "EP 3 Infiltrate the Everlue Mansion",
                    Description  = "Natsu picks up a job that could pay big, but he needs Lucy to complete his plan."
                },
                new Media()
                {
                    Id           = Guid.Parse("8d81a6f1-f933-429a-91fb-7d38cd54b142"),
                    MediaGroupId = Guid.Parse("d106b8e5-11e8-4f83-9b33-db7e2be73102"),
                    Thumbnail    = "https://dw9to29mmj727.cloudfront.net/thumbnails/episodes/11029-jojos-bizarre-adventure-season-four-1-320x180.jpg?size=960x540",
                    Title        = "EP 1 Golden Wind",
                    Description  = "Koichi Hirose travels to Naples in order to find the possible son of DIO, Haruno Shiobana."
                },
                new Media()
                {
                    Id           = Guid.Parse("3d0c1d77-26e7-4972-9e8f-cf1055c996f7"),
                    MediaGroupId = Guid.Parse("d106b8e5-11e8-4f83-9b33-db7e2be73102"),
                    Thumbnail    = "https://dw9to29mmj727.cloudfront.net/thumbnails/episodes/11030-jojos-bizarre-adventure-season-four-2-320x180.jpg?size=960x540",
                    Title        = "EP 2 Bucciarati Is Coming",
                    Description  = "Bucciarati is looking for the person responsible for critically injuring Leaky Eye Luca."
                },
                new Media()
                {
                    Id           = Guid.Parse("4259cac2-fcf2-4ca2-b311-813bc291c2ce"),
                    MediaGroupId = Guid.Parse("d106b8e5-11e8-4f83-9b33-db7e2be73102"),
                    Thumbnail    = "https://i3.wp.com/ytimg.googleusercontent.com/vi/GxmiZ6Fn-dk/mqdefault.jpg",
                    Title        = "EP 27 King Crimson vs Metallica",
                    Description  = "Risotto figures out that Doppio must be a Stand user that the boss trusts in deeply because he’s able to hear the noise from a certain Stand."
                }
            };

            foreach (var m in medias)
            {
                repo.AddMedia(m);
            }
            repo.SaveChanges();
        }
Exemplo n.º 18
0
        public IDictionary<long, Program> Load(Uri playlist)
        {
            using (var f = new WebClient().OpenRead(playlist))
            {
                var parser = new M3U8Parser();

                parser.Parse(playlist, f);

                var audioStreams = new Dictionary<string, MediaGroup>();

                foreach (var gt in parser.GlobalTags)
                {
                    if (M3U8Tags.ExtXMedia == gt.Tag)
                    {
                        try
                        {
                            var audioAttribute = gt.Attribute(ExtMediaSupport.AttrType, "AUDIO");

                            if (null != audioAttribute)
                            {
                                var group = gt.Attribute(ExtMediaSupport.AttrGroupId).Value;

                                var urlAttribute = gt.AttributeObject(ExtMediaSupport.AttrUri);

                                Uri playlistUrl = null;

                                if (null != urlAttribute)
                                    playlistUrl = new Uri(playlist, new Uri(urlAttribute, UriKind.RelativeOrAbsolute));

                                var audioStream = new PlaylistSubStream
                                                  {
                                                      Name = group,
                                                      Playlist = playlistUrl
                                                  };

                                MediaGroup mediaGroup;
                                if (!audioStreams.TryGetValue(group, out mediaGroup))
                                {
                                    mediaGroup = new MediaGroup { Default = audioStream };

                                    audioStreams[group] = mediaGroup;
                                }

                                var isDefault = 0 == string.CompareOrdinal("YES", gt.Attribute(ExtMediaSupport.AttrDefault).Value);

                                if (isDefault)
                                    mediaGroup.Default = audioStream;

                                var name = gt.Attribute(ExtMediaSupport.AttrName).Value;

                                mediaGroup.Streams[name] = audioStream;
                            }
                        }
                        catch (NullReferenceException)
                        {
                            // DynamicObject isn't welcome on the phone or this would be a binding exception.
                        }
                    }
                }

                var programs = new Dictionary<long, Program>();
                SimpleSubProgram simpleSubProgram = null;

                foreach (var p in parser.Playlist)
                {
                    var streamInf = p.Tags.FirstOrDefault(t => M3U8Tags.ExtXStreamInf == t.Tag);

                    var programId = long.MinValue;
                    MediaGroup audioGroup = null;

                    if (null != streamInf)
                    {
                        var programIdAttribute = streamInf.Attribute(ExtStreamInfSupport.AttrProgramId);

                        if (null != programIdAttribute)
                            programId = programIdAttribute.Value;

                        var audioAttribute = streamInf.AttributeObject(ExtStreamInfSupport.AttrAudio);

                        if (null != audioAttribute)
                            audioStreams.TryGetValue(audioAttribute, out audioGroup);

                        var subProgram = new PlaylistSubProgram
                                         {
                                             Bandwidth = streamInf.Attribute(ExtStreamInfSupport.AttrBandwidth).Value,
                                             Playlist = new Uri(playlist, new Uri(p.Uri, UriKind.RelativeOrAbsolute)),
                                             Audio = audioGroup
                                         };

                        Program program;

                        if (!programs.TryGetValue(programId, out program))
                        {
                            program = new Program { ProgramId = programId };

                            programs[programId] = program;
                        }

                        program.SubPrograms.Add(subProgram);
                    }
                    else
                    {
                        var extInf = (ExtinfTagInstance)p.Tags.FirstOrDefault(t => M3U8Tags.ExtXInf == t.Tag);

                        if (null != extInf)
                        {
                            if (null == simpleSubProgram)
                            {
                                simpleSubProgram = new SimpleSubProgram();

                                var program = new Program { ProgramId = long.MinValue };

                                program.SubPrograms.Add(simpleSubProgram);

                                programs[program.ProgramId] = program;
                            }

                            simpleSubProgram.Segments.Add(new XSegment
                                                          {
                                                              Url = new Uri(playlist, new Uri(p.Uri, UriKind.RelativeOrAbsolute)),
                                                              Duration = TimeSpan.FromSeconds((double)extInf.Duration)
                                                          });
                        }
                    }
                }

                return programs;
            }
        }
Exemplo n.º 19
0
        private async Task <IDictionary <long, Program.Program> > LoadAsync(IWebReader webReader, M3U8Parser parser, CancellationToken cancellationToken)
        {
            var audioStreams = new Dictionary <string, MediaGroup>();

            foreach (var m3U8TagInstance in parser.GlobalTags)
            {
                if (M3U8Tags.ExtXMedia != m3U8TagInstance.Tag)
                {
                    continue;
                }

                try
                {
                    if (null != m3U8TagInstance.Attribute(ExtMediaSupport.AttrType, "AUDIO"))
                    {
                        AddMedia(parser.BaseUrl, m3U8TagInstance, audioStreams);
                    }
                }
                catch (NullReferenceException)
                {
                    ;
                }
            }

            var programs    = new Dictionary <long, Program.Program>();
            var hasSegments = false;

            foreach (var m3U8Uri in parser.Playlist)
            {
                if (m3U8Uri.Tags == null || m3U8Uri.Tags.Length < 1)
                {
                    hasSegments = true;
                }
                else
                {
                    var        streamInfTagInstance = M3U8Tags.ExtXStreamInf.Find(m3U8Uri.Tags);
                    var        programId            = long.MinValue;
                    MediaGroup mediaGroup           = null;
                    if (null != streamInfTagInstance)
                    {
                        var attributeValueInstance1 = streamInfTagInstance.Attribute(ExtStreamInfSupport.AttrProgramId);
                        if (null != attributeValueInstance1)
                        {
                            programId = attributeValueInstance1.Value;
                        }

                        var key = streamInfTagInstance.AttributeObject(ExtStreamInfSupport.AttrAudio);
                        if (null != key)
                        {
                            audioStreams.TryGetValue(key, out mediaGroup);
                        }

                        var uri = parser.ResolveUrl(m3U8Uri.Uri);
                        var attributeValueInstance2 = streamInfTagInstance.Attribute(ExtStreamInfSupport.AttrBandwidth);
                        var attributeInstance       = streamInfTagInstance.AttributeInstance <ResolutionAttributeInstance>(ExtStreamInfSupport.AttrResolution);
                        var baseUrl             = parser.BaseUrl;
                        var program             = GetProgram(programs, programId, baseUrl);
                        var hlsProgramStream    = _programStreamFactory.Create(new [] { uri }, webReader);
                        var playlistSubProgram1 = new PlaylistSubProgram(program, hlsProgramStream);
                        playlistSubProgram1.Bandwidth  = attributeValueInstance2?.Value ?? 0L;
                        playlistSubProgram1.Playlist   = uri;
                        playlistSubProgram1.AudioGroup = mediaGroup;
                        var playlistSubProgram2 = playlistSubProgram1;
                        if (null != attributeInstance)
                        {
                            playlistSubProgram2.Width  = attributeInstance.X;
                            playlistSubProgram2.Height = attributeInstance.Y;
                        }
                        program.SubPrograms.Add(playlistSubProgram2);
                    }
                    else
                    {
                        hasSegments = true;
                    }
                }
            }
            if (hasSegments)
            {
                var program          = GetProgram(programs, long.MinValue, parser.BaseUrl);
                var hlsProgramStream = _programStreamFactory.Create(new [] { webReader.RequestUri }, webReader);
                await hlsProgramStream.SetParserAsync(parser, cancellationToken).ConfigureAwait(false);

                var subProgram = new PlaylistSubProgram(program, hlsProgramStream);
                program.SubPrograms.Add(subProgram);
            }
            return(programs);
        }
Exemplo n.º 20
0
 public void when_lesson_is_null()
 {
     Assert.Throws <ArgumentNullException>(() => MediaGroup.Build(null));
 }
Exemplo n.º 21
0
        /// <summary>
        /// 返回Group群组
        /// </summary>
        /// <returns></returns>
        public IActionResult ToSelectGroup()
        {
            List <ZTree> objList = new List <ZTree>();
            //获取用户群组
            Expression <Func <UserGroup, bool> > _expressionUserGroup = _expressionUserGroup = f => 0 == 0;
            List <UserGroup> objUserGroupList = _userGroupService.QueryableToList(_expressionUserGroup);

            if (objUserGroupList.Count > 0)
            {
                //读取媒体群组
                string            url               = string.Format("{0}?id=-1", group_url_get);
                string            jsonStr           = HttpHelper.HttpGet(url);
                List <MediaGroup> objMediaGroupList = JsonConvert.DeserializeObject <List <MediaGroup> >(jsonStr);

                List <MediaGroup> mediaGroupList = new List <MediaGroup>();
                foreach (var itme in objUserGroupList)
                {
                    ZTree obj = new ZTree();
                    obj.id   = GlobalParameter._PREFIX + itme.id;
                    obj.name = itme.group_name;
                    obj.pId  = "0";
                    obj.open = true;
                    objList.Add(obj);
                    if (objMediaGroupList.Where(f => f.group_id == itme.id).ToList().Count <= 0)//判断媒体群组是否需要建立默认的
                    {
                        MediaGroup mediaGroup = new MediaGroup();
                        mediaGroup.parent_id   = 0;
                        mediaGroup.mgroup_name = "new group";
                        mediaGroup.group_id    = itme.id;
                        mediaGroupList.Add(mediaGroup);
                    }
                }
                //新增默认的媒体群组
                if (mediaGroupList.Count > 0)
                {
                    foreach (var items in mediaGroupList)
                    {
                        string data = JsonConvert.SerializeObject(items);
                        HttpHelper.HttpPost(group_url_add, data);
                    }
                }
                //重新获取媒体群组
                if (objMediaGroupList.Count <= 0)
                {
                    objMediaGroupList = JsonConvert.DeserializeObject <List <MediaGroup> >(HttpHelper.HttpGet(url));
                }
                foreach (var itme in objMediaGroupList)
                {
                    ZTree obj = new ZTree();

                    obj.id   = itme.id.ToString();
                    obj.name = itme.mgroup_name;
                    if (itme.parent_id == 0)
                    {
                        obj.pId = GlobalParameter._PREFIX + itme.group_id;
                    }
                    else
                    {
                        obj.pId = itme.parent_id.ToString();
                    }
                    objList.Add(obj);
                }
            }
            return(Json(objList));
        }
Exemplo n.º 22
0
        static void AddMedia(Uri playlist, M3U8TagInstance gt, Dictionary<string, MediaGroup> audioStreams)
        {
            var groupId = gt.Attribute(ExtMediaSupport.AttrGroupId).Value;

            var urlAttribute = gt.AttributeObject(ExtMediaSupport.AttrUri);

            Uri playlistUrl = null;

            if (null != urlAttribute)
                playlistUrl = new Uri(playlist, new Uri(urlAttribute, UriKind.RelativeOrAbsolute));

            var language = gt.AttributeObject(ExtMediaSupport.AttrLanguage);

            var audioStream = new PlaylistSubStream
            {
                Type = gt.AttributeObject(ExtMediaSupport.AttrType),
                Name = groupId,
                Playlist = playlistUrl,
                IsAutoselect = IsYesNo(gt, ExtMediaSupport.AttrAutoselect),
                Language = null == language ? null : language.Trim().ToLower()
            };

            MediaGroup mediaGroup;
            if (!audioStreams.TryGetValue(groupId, out mediaGroup))
            {
                mediaGroup = new MediaGroup
                {
                    Default = audioStream
                };

                audioStreams[groupId] = mediaGroup;
            }

            var isDefault = IsYesNo(gt, ExtMediaSupport.AttrDefault);

            if (isDefault)
                mediaGroup.Default = audioStream;

            var name = gt.Attribute(ExtMediaSupport.AttrName).Value;

            mediaGroup.Streams[name] = audioStream;
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>runs an authentication test, iterates all entries</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void QueryPhotosTest()
        {
            Tracing.TraceMsg("Entering PhotosQueryPhotosTest");

            PhotoQuery    query   = new PhotoQuery();
            PicasaService service = new PicasaService("unittests");

            if (this.defaultPhotosUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                GDataLoggingRequestFactory factory = (GDataLoggingRequestFactory)this.factory;
                factory.MethodOverride = true;
                service.RequestFactory = this.factory;

                query.Uri = new Uri(this.defaultPhotosUri);
                PicasaFeed feed = service.Query(query);

                ObjectModelHelper.DumpAtomObject(feed, CreateDumpFileName("PhotoAuthTest"));

                if (feed != null && feed.Entries.Count > 0)
                {
                    Tracing.TraceMsg("Found a Feed " + feed.ToString());
                    DisplayExtensions(feed);

                    foreach (PicasaEntry entry in feed.Entries)
                    {
                        Tracing.TraceMsg("Found an entry " + entry.ToString());
                        DisplayExtensions(entry);

                        GeoRssWhere w = entry.Location;
                        if (w != null)
                        {
                            Tracing.TraceMsg("Found an location " + w.Latitude + w.Longitude);
                        }

                        ExifTags tags = entry.Exif;
                        if (tags != null)
                        {
                            Tracing.TraceMsg("Found an exif block ");
                        }

                        MediaGroup group = entry.Media;
                        if (group != null)
                        {
                            Tracing.TraceMsg("Found a media Group");
                            if (group.Title != null)
                            {
                                Tracing.TraceMsg(group.Title.Value);
                            }
                            if (group.Keywords != null)
                            {
                                Tracing.TraceMsg(group.Keywords.Value);
                            }
                            if (group.Credit != null)
                            {
                                Tracing.TraceMsg(group.Credit.Value);
                            }
                            if (group.Description != null)
                            {
                                Tracing.TraceMsg(group.Description.Value);
                            }
                        }


                        PhotoAccessor photo = new PhotoAccessor(entry);

                        Assert.IsTrue(entry.IsPhoto, "this is a photo entry, it should have the kind set");
                        Assert.IsTrue(photo != null, "this is a photo entry, it should convert to PhotoEntry");

                        Assert.IsTrue(photo.AlbumId != null);
                        Assert.IsTrue(photo.Height > 0);
                        Assert.IsTrue(photo.Width > 0);
                    }
                }

                factory.MethodOverride = false;
            }
        }
Exemplo n.º 24
0
        public List <string> LoadFiles(List <FileUpload> list)
        {
            List <string> retContent = new List <string>();
            string        fullPath;//完整路径

            foreach (var item in list)
            {
                string feedbackInfo = string.Empty;
                if (string.IsNullOrEmpty(item.file_name) || string.IsNullOrEmpty(item.status) || string.IsNullOrEmpty(item.file_path) || item.media_group_id == 0)
                {
                    retContent.Add(item.file_name + ":参数不能为空");
                    continue;
                }


                Expression <Func <MediaGroup, bool> > _expression = _expression = f => f.id == item.media_group_id;
                MediaGroup mediaGroup = _mediaGroupService.QueryableToEntity(_expression);
                if (mediaGroup == null)
                {
                    retContent.Add(item.file_name + ":媒体群组Id错误");
                    continue;
                }
                FileType fileType = new FileType();
                if (item.status.ToLower().Trim() != "delete")
                {
                    fullPath = item.file_path + "\\" + item.file_name;//组合路径
                    if (!System.IO.File.Exists(fullPath))
                    {
                        retContent.Add(item.file_name + ":文件路径错误");
                        continue;
                    }
                    fileType = FileHelper.CheckFileType(fullPath);
                    if (fileType.ToString() == "nosupport")
                    {
                        retContent.Add(item.file_name + ":文件格式不支持");
                        continue;
                    }
                }

                switch (item.status.ToLower().Trim())
                {
                case "add":    //新增
                    if (!Add(item, fileType, ref feedbackInfo))
                    {
                        retContent.Add(feedbackInfo);
                    }
                    break;

                case "update":    //更新
                    if (!Update(item, fileType, ref feedbackInfo))
                    {
                        retContent.Add(feedbackInfo);
                    }
                    break;

                case "delete":    //删除
                    if (!Del(item, ref feedbackInfo))
                    {
                        retContent.Add(feedbackInfo);
                    }
                    break;

                default:
                    feedbackInfo = item.file_name + ":未识别的status";
                    retContent.Add(feedbackInfo);
                    break;
                }
            }
            return(retContent);
        }
Exemplo n.º 25
0
        public MediaGroup AddMediaGroup(MediaGroup mediaGroupEntityToAdd)
        {
            _context.MediaGroups.Add(mediaGroupEntityToAdd);

            return(mediaGroupEntityToAdd);
        }
Exemplo n.º 26
0
        public async Task MergeMedias(List<Media> medias, MediaGroup currentMediaGroup = null)
        {

            // Use Profile for output vid/cmp? file 


            try
            {
                List<StorageFile> mediaFiles = new List<StorageFile>();
                MediaGroup mediaGroup = new MediaGroup();
                StorageFolder localFolder = ApplicationData.Current.LocalFolder;
                MediaComposition composition = new MediaComposition();
                List<MediaClip> mediaClips = new List<MediaClip>();
                StorageFile timelineVidOutputFile;
                StorageFile timelineCMPOutputFile;
                bool deleteExistingFile = (currentMediaGroup != null) ? false : true;
                #region EmotionsMeanTemp

                double tmpAngerScoreMean = 0;
                double tmpContemptScoreMean = 0;
                double tmpDisgustScoreMean = 0;
                double tmpFearScoreMean = 0;
                double tmpHappinessScoreMean = 0;
                double tmpNeutralScoreMean = 0;
                double tmpSadnessScoreMean = 0;
                double tmpSurpriseScoreMean = 0;

                string tmpHighestEmotionMean = string.Empty;

                #endregion

                foreach (var media in medias)
                {

                    mediaFiles.Add(await StorageFile.GetFileFromApplicationUriAsync(new Uri(
                            string.Format("ms-appdata:///local/{0}", media.MediaName))));

                    tmpAngerScoreMean += media.AngerScore;
                    tmpContemptScoreMean += media.ContemptScore;
                    tmpDisgustScoreMean += media.DisgustScore;
                    tmpFearScoreMean += media.FearScore;
                    tmpHappinessScoreMean += media.HappinessScore;
                    tmpNeutralScoreMean += media.NeutralScore;
                    tmpSadnessScoreMean += media.SadnessScore;
                    tmpSurpriseScoreMean += media.SurpriseScore;
                }
                tmpAngerScoreMean = tmpAngerScoreMean / medias.Count;
                tmpContemptScoreMean = tmpContemptScoreMean / medias.Count;
                tmpDisgustScoreMean = tmpDisgustScoreMean / medias.Count;
                tmpFearScoreMean = tmpFearScoreMean / medias.Count;
                tmpHappinessScoreMean = tmpHappinessScoreMean / medias.Count;
                tmpNeutralScoreMean = tmpNeutralScoreMean / medias.Count;
                tmpSadnessScoreMean = tmpSadnessScoreMean / medias.Count;
                tmpSurpriseScoreMean = tmpSurpriseScoreMean / medias.Count;

                SortedList<string, double> tempForSortingScores = new SortedList<string, double>();
                tempForSortingScores.Add("AngerScoreMean", tmpAngerScoreMean);
                tempForSortingScores.Add("ContemptScoreMean", tmpContemptScoreMean);
                tempForSortingScores.Add("DisgustScoreMean", tmpDisgustScoreMean);
                tempForSortingScores.Add("FearScoreMean", tmpFearScoreMean);
                tempForSortingScores.Add("HappinessScoreMean", tmpHappinessScoreMean);
                tempForSortingScores.Add("NeutralScoreMean", tmpNeutralScoreMean);
                tempForSortingScores.Add("SadnessScoreMean", tmpSadnessScoreMean);
                tempForSortingScores.Add("SurpriseScoreMean", tmpSurpriseScoreMean);
                // TODO: check this.
                tmpHighestEmotionMean = tempForSortingScores.OrderByDescending(x => x.Value).FirstOrDefault().Key;

                if (currentMediaGroup == null)
                {
                    timelineVidOutputFile = await localFolder.CreateFileAsync(
                   "timelineMeOutput.mp4", CreationCollisionOption.GenerateUniqueName);

                    string CMPFileName = string.Format(timelineVidOutputFile.DisplayName + ".cmp");
                    timelineCMPOutputFile = await localFolder.CreateFileAsync(
                   CMPFileName, CreationCollisionOption.OpenIfExists);

                    for (int i = 0; i < mediaFiles.Count; i++)
                    {
                        mediaClips.Add(await MediaClip.CreateFromImageFileAsync(mediaFiles[i], TimeSpan.FromSeconds(int.Parse(localSettings.Values["DurationInSecForEachImage"].ToString()))));
                        composition.Clips.Add(mediaClips[i]);
                    }


                    using (var db = new MediaContext())
                    {
                        mediaGroup = new MediaGroup()
                        {
                            CompostionFileName = timelineVidOutputFile.DisplayName,
                            LastEditDate = DateTime.Now,
                            AngerScoreMean = tmpAngerScoreMean,
                            ContemptScoreMean = tmpContemptScoreMean,
                            DisgustScoreMean = tmpDisgustScoreMean,
                            FearScoreMean = tmpFearScoreMean,
                            HappinessScoreMean = tmpHappinessScoreMean,
                            NeutralScoreMean = tmpNeutralScoreMean,
                            SadnessScoreMean = tmpSadnessScoreMean,
                            SurpriseScoreMean = tmpSurpriseScoreMean,
                            HighestEmotionMean = tmpHighestEmotionMean

                        };

                        db.MediaGroups.Add(mediaGroup);
                        db.SaveChanges();

                    }

                    var action = composition.SaveAsync(timelineCMPOutputFile);
                    action.Completed = (info, status) =>
                    {
                        if (status != AsyncStatus.Completed)
                        {
                        //ShowErrorMessage("Error saving composition");
                    }

                    };



                }
                else
                {
                    using (var db = new MediaContext())
                    {
                        mediaGroup =
                            db.MediaGroups.Where(
                                x => x.CompostionFileName == currentMediaGroup.CompostionFileName).
                                FirstOrDefault();
                        // TODO Check this
                        mediaGroup.LastEditDate = DateTime.Now;
                        mediaGroup.AngerScoreMean = mediaGroup.AngerScoreMean + tmpAngerScoreMean / 2;
                        mediaGroup.ContemptScoreMean = mediaGroup.ContemptScoreMean + tmpContemptScoreMean / 2;
                        mediaGroup.DisgustScoreMean = mediaGroup.DisgustScoreMean + tmpDisgustScoreMean / 2;
                        mediaGroup.FearScoreMean = mediaGroup.FearScoreMean + tmpFearScoreMean / 2;
                        mediaGroup.HappinessScoreMean = mediaGroup.HappinessScoreMean + tmpHappinessScoreMean / 2;
                        mediaGroup.NeutralScoreMean = mediaGroup.NeutralScoreMean + tmpNeutralScoreMean / 2;
                        mediaGroup.SadnessScoreMean = mediaGroup.SadnessScoreMean + tmpSadnessScoreMean / 2;
                        mediaGroup.SurpriseScoreMean = mediaGroup.SurpriseScoreMean + tmpSurpriseScoreMean / 2;

                        SortedList<string, double> temptempForSortingScores = new SortedList<string, double>();
                        temptempForSortingScores.Add("AngerScoreMean", mediaGroup.AngerScoreMean);
                        temptempForSortingScores.Add("ContemptScoreMean", mediaGroup.ContemptScoreMean);
                        temptempForSortingScores.Add("DisgustScoreMean", mediaGroup.DisgustScoreMean);
                        temptempForSortingScores.Add("FearScoreMean", mediaGroup.FearScoreMean);
                        temptempForSortingScores.Add("HappinessScoreMean", mediaGroup.HappinessScoreMean);
                        temptempForSortingScores.Add("NeutralScoreMean", mediaGroup.NeutralScoreMean);
                        temptempForSortingScores.Add("SadnessScoreMean", mediaGroup.SadnessScoreMean);
                        temptempForSortingScores.Add("SurpriseScoreMean", mediaGroup.SurpriseScoreMean);
                        // TODO: check this.
                        mediaGroup.HighestEmotionMean = temptempForSortingScores.OrderByDescending(x => x.Value).FirstOrDefault().Key;

                        db.MediaGroups.Update(mediaGroup);
                        db.SaveChanges();
                    }

                    timelineVidOutputFile = await localFolder.GetFileAsync(currentMediaGroup.CompostionFileName + ".mp4");
                    timelineCMPOutputFile = await localFolder.GetFileAsync(currentMediaGroup.CompostionFileName + ".cmp");
                    composition = await MediaComposition.LoadAsync(timelineCMPOutputFile);
                    //TODO: make sure this works.
                    for (int i = 0; i < mediaFiles.Count; i++)
                    {
                        // TODO Fix this
                        mediaClips.Add(await MediaClip.CreateFromImageFileAsync(mediaFiles[i], TimeSpan.FromSeconds(int.Parse(localSettings.Values["DurationInSecForEachImage"].ToString()))));
                        composition.Clips.Add(mediaClips[i]);
                    }

                    var action = composition.SaveAsync(timelineCMPOutputFile);
                    action.Completed = (info, status) =>
                    {
                        if (status != AsyncStatus.Completed)
                        {
                        //ShowErrorMessage("Error saving composition");
                    }

                    };
                }
            }
            catch (Exception)
            {

                
            }

        }