Пример #1
0
        private void getLatestVideo()
        {
            if (_archive != null)
            {
                long      published   = 0;
                videoItem latestVideo = new videoItem();

                foreach (videoCategory cat in _archive.categories)
                {
                    foreach (videoItem video in cat.videos)
                    {
                        long thisPublished = 0;
                        bool parse         = long.TryParse(video.startDate, out thisPublished);
                        if (parse)
                        {
                            if (thisPublished >= published)
                            {
                                latestVideo = video;
                                published   = thisPublished;
                            }
                        }
                    }
                }
                if (latestVideo != null)
                {
                    parseVideo(latestVideo);
                }
            }
        }
Пример #2
0
        private videoArchive build()
        {
            videoArchive archive = new videoArchive();

            archive.categories = new List <videoCategory>();

            string BRSArchivePlayerBcId = "3222810931001";

            string videoFields = "id,name,shortDescription,longDescription,videoStillURL,thumbnailURL,length,playsTotal,publishedDate,startDate";

            var BRSRequest = (HttpWebRequest)HttpWebRequest.Create(string.Format("http://api.brightcove.com/services/library?command=find_playlists_for_player_id&player_id={0}&video_fields={1}&token={2}", BRSArchivePlayerBcId, videoFields, RSReadToken));

            BRSRequest.Method = "POST";

            //Get BRS Account Items
            try
            {
                var    response         = BRSRequest.GetResponse();
                Stream dataStream       = response.GetResponseStream();
                string BCResponseString = string.Empty;
                using (StreamReader reader = new StreamReader(dataStream))
                {
                    BCResponseString = reader.ReadToEnd();

                    if (BCResponseString != null && BCResponseString != "null")
                    {
                        var results = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(BCResponseString);

                        foreach (dynamic category in results.items)
                        {
                            videoCategory cat = new videoCategory();
                            cat.name   = category.name;
                            cat.videos = new List <videoItem>();
                            foreach (dynamic video in category.videos)
                            {
                                videoItem item = new videoItem();
                                item.id               = video.id;
                                item.name             = video.name.ToString().Replace("\"", "&quot");
                                item.length           = video.length;
                                item.playsTotal       = video.playsTotal;
                                item.thumbnailURL     = video.thumbnailURL;
                                item.videoStillURL    = video.videoStillURL;
                                item.publishedDate    = video.publishedDate;
                                item.startDate        = video.startDate;
                                item.shortDescription = video.shortDescription.ToString().Replace("\"", "&quot");
                                item.longDescription  = video.longDescription.ToString().Replace("\"", "&quot");
                                cat.videos.Add(item);
                            }
                            archive.categories.Add(cat);
                        }
                    }
                }
            }
            catch { }
            return(archive);
        }
Пример #3
0
        private void getRealtedVideos(string bcid)
        {
            Dictionary <long, videoItem> relatedVideosDict = new Dictionary <long, videoItem>();

            if (_archive != null)
            {
                videoItem latestVideo = new videoItem();

                foreach (videoCategory cat in _archive.categories)
                {
                    foreach (videoItem video in cat.videos)
                    {
                        long thisPublished = 0;
                        bool parse         = long.TryParse(video.startDate, out thisPublished);
                        if (parse)
                        {
                            if (!relatedVideosDict.ContainsKey(thisPublished))
                            {
                                relatedVideosDict.Add(thisPublished, video);
                            }
                        }
                    }
                }
            }



            StringBuilder html = new StringBuilder();

            html.AppendLine("<div class=\"related-videos\">");
            html.AppendLine("<h2>Relaterade videor</h2>");
            if (relatedVideosDict.Count >= 1)
            {
                html.AppendLine("<div class=\"slider-videos\">");
                foreach (var item in relatedVideosDict.OrderByDescending(i => i.Key))
                {
                    html.AppendLine("<a class=\"relatedLink\" href=\"?bctid=" + item.Value.id + "\">");
                    //html.AppendLine("<div class=\"info-box\"><h2>" + item.Value.name + "</h2><img src=\"" + item.Value.videoStillURL + "\"/><p>" + item.Value.shortDescription + "</p></div>");
                    html.AppendLine("<div class=\"item-video\">");
                    html.AppendLine("<img src=\"" + item.Value.videoStillURL + "\" height=\"110px\" width=\"200px\" alt=\"" + item.Value.shortDescription + "\" />");
                    html.AppendLine("</div>");
                    html.AppendLine("</a>");
                }
                html.AppendLine("</div>");
            }
            html.AppendLine("</div>");

            relatedVideos.InnerHtml = html.ToString();
        }
Пример #4
0
        private void parseVideo(videoItem video)
        {
            string        playerKey = "AQ~~%2CAAAC55oP_QE~%2C9I10eiFWoUl-RRGxGS93LW88Oyy-tUat";
            string        playerId  = "3222810932001";
            StringBuilder html      = new StringBuilder();

            html.AppendLine("<div class=\"video\">\n");
            //VideoPlayer
            html.AppendLine("<div id=\"main-video\">\n");
            html.Append(@"
                <object id='myExperience" + video.id + @"' class='BrightcoveExperience'>
                <param name='bgcolor' value='#808080' />
                <param name='width' value='680' />
                <param name='height' value='380' />
                <param name='playerID' value='" + playerId + @"' />
                <param name='playerKey' value='" + playerKey + @"' />
                <param name='isVid' value='true' />
                <param name='isUI' value='true' />
                <param name='dynamicStreaming' value='true' />
                <param name='linkBaseURL' value='http://play.skane.com?bctid=" + video.id + @"' />
                <param name='wmode' value='opaque' />
                <param name='htmlFallback' value='true' />
                <param name='@videoPlayer' value='" + video.id + @"' />
                </object>
                <script type='text/javascript'>brightcove.createExperiences();</script>
            ");
            html.AppendLine("</div>");
            //VideoMeta
            html.AppendLine("<div class=\"information-video\">\n");

            html.AppendLine("<h2>" + video.name + "</h2>\n");
            html.AppendLine("<p>" + video.shortDescription + "</p>\n");

            //video information
            html.AppendLine("<div class=\"video-information\">");
            if (video.length != null)
            {
                html.AppendLine("\t<span class=\"label\">Längd:</span><p class=\"video-length\">" + new TimeSpan(0, 0, 0, 0, int.Parse(video.length)).ToString(@"hh\:mm\:ss", System.Globalization.CultureInfo.InvariantCulture) + "</p>");
            }
            if (video.publishedDate != null)
            {
                DateTime UNIXepoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                long     milli;
                bool     parse = long.TryParse(video.publishedDate, out milli);
                if (parse)
                {
                    UNIXepoch = UNIXepoch.AddMilliseconds(milli);
                    html.AppendLine("\t<span class=\"label\">Publicerad:</span><p class=\"date\">" + UNIXepoch.ToShortDateString() + "</p>");
                }
            }
            if (video.playsTotal != null)
            {
                html.AppendLine("\t<span class=\"label\">Visad:</span><p class=\"views\">" + video.playsTotal + "</p>");
            }
            html.AppendLine("</div>");

            //sharing
            html.AppendLine("<div class=\"share\">");
            html.Append(@"
              <div class='addthis_toolbox addthis_default_style '>
                <a class='addthis_button_facebook_like' fb:like:layout='button_count'></a>
                <a class='addthis_button_tweet'></a>
              </div>
              <script type='text/javascript' src='//s7.addthis.com/js/300/addthis_widget.js#pubid=xa-52e638551dd5b4d6'></script>

              <div class='addthis_toolbox addthis_16x16_style'>
                <a class='addthis_button_preferred_1'></a>
                <a class='addthis_button_preferred_3'></a>
              </div>
              <script type='text/javascript' src='//s7.addthis.com/js/300/addthis_widget.js#pubid=xa-52e63818548cf1ba'></script>
            ");
            html.AppendLine("</div>\n");

            html.AppendLine("</div>\n");

            html.AppendLine("</div>\n");

            videoContainer.InnerHtml = html.ToString();

            //Set social meta tags
            if (!frontpage)
            {
                StringBuilder faceBookMeta = new StringBuilder();
                StringBuilder twitterMeta  = new StringBuilder();

                if (video.name != null)
                {
                    metaPageTitel.Text = video.name;
                    twitterMeta.AppendLine("<meta name=\"twitter:title\" content=\"" + video.name + "\" />");
                    faceBookMeta.AppendLine("<meta property=\"og:title\" content=\"" + video.name + "\"/>");
                }
                if (video.shortDescription != null)
                {
                    twitterMeta.AppendLine("<meta name=\"twitter:description\" content=\"" + video.shortDescription + "\" />");
                    faceBookMeta.AppendLine("<meta property=\"og:description\" content=\"" + video.shortDescription + "\" />");
                }
                if (video.videoStillURL != null)
                {
                    twitterMeta.AppendLine("<meta name=\"twitter:image:src\" content=\"" + video.videoStillURL + "\" />");
                    faceBookMeta.AppendLine("<meta property=\"og:image\" content=\"" + video.videoStillURL + "\" />");
                }
                if (video.id != null)
                {
                    twitterMeta.AppendLine("<meta name=\"twitter:card\" content=\"player\" />");
                    twitterMeta.AppendLine("<meta name=\"twitter:url\" content=\"http://play.skane.com/?bctid=" + video.id + "\" />");

                    string twitterPlayerUrl = "https://link.brightcove.com/services/player/bcpid" + playerId + "?bckey=" + playerKey + "&bctid=" + video.id + "&secureConnections=true&autoStart=false&height=100%25&width=100%25";

                    twitterMeta.AppendLine("<meta name=\"twitter:player\" content=\"" + twitterPlayerUrl + "\" />");
                    twitterMeta.AppendLine("<meta name=\"twitter:player:width\" content=\"360\" />");
                    twitterMeta.AppendLine("<meta name=\"twitter:player:height\" content=\"200\" />");


                    string facebookPlayerId = playerId;
                    faceBookMeta.AppendLine("<meta property=\"og:url\"  content=\"http://play.skane.com/?bctid=" + video.id + "\"/>");
                    faceBookMeta.AppendLine("<meta property=\"og:type\" content=\"movie\"/>");
                    faceBookMeta.AppendLine("<meta property=\"og:video:height\" content=\"270\"/>");
                    faceBookMeta.AppendLine("<meta property=\"og:video:width\" content=\"480\"/>");
                    faceBookMeta.AppendLine("<meta property=\"og:video\" content=\"http://c.brightcove.com/services/viewer/federated_f9/?isVid=1&isUI=1&playerID=" + facebookPlayerId + "&autoStart=true&videoId=" + video.id + "\">");
                    faceBookMeta.AppendLine("<meta property=\"og:video:secure_url\" content=\"https://secure.brightcove.com/services/viewer/federated_f9/?isVid=1&isUI=1&playerID=" + facebookPlayerId + "&autoStart=true&videoId=" + video.id + "&secureConnections=true\">");
                    faceBookMeta.AppendLine("<meta property=\"og:video:type\" content=\"application/x-shockwave-flash\">");
                }

                fbMeta.Text = faceBookMeta.ToString();
                twMeta.Text = twitterMeta.ToString();
            }

            getRealtedVideos(video.id);
        }