Exemplo n.º 1
0
        public static string Description(upnpObject aObject)
        {
            string result = string.Empty;

            if (aObject is audioItem)
            {
                audioItem item = aObject as audioItem;
                result = item.Description;
            }
            else if (aObject is videoItem)
            {
                videoItem item = aObject as videoItem;
                result = item.Description;
            }
            else if (aObject is album)
            {
                album item = aObject as album;
                result = item.Description;
            }
            else if (aObject is playlistContainer)
            {
                playlistContainer item = aObject as playlistContainer;
                result = item.Description;
            }

            // always return a non-null string
            return(NonNullString(result));
        }
Exemplo n.º 2
0
        private string renderClip(videoItem clip, bool kf)
        {
            string html = string.Empty;

            html += "<li class=\"item-" + itemNumber.ToString() + "\">\n";
            html += "\t<a href=\"http://video.malmo.se/?bctid=" + clip.id + "\" alt=\"" + clip.shortDescription + "\">\n";
            html += "\t\t<img src=\"" + clip.thumbnailURL + "\"/>\n";
            if (Convert.ToInt32(clip.length) >= 0)
            {
                if (!kf)
                {
                    html += "\t\t<div class=\"video-time\">" + new TimeSpan(0, 0, 0, 0, Convert.ToInt32(clip.length)).ToString(@"mm\:ss", System.Globalization.CultureInfo.InvariantCulture) + "</div>\n";
                }
                if (kf)
                {
                    html += "\t\t<div class=\"video-time\">" + new TimeSpan(0, 0, 0, 0, Convert.ToInt32(clip.length)).ToString(@"hh\:mm\:ss", System.Globalization.CultureInfo.InvariantCulture) + "</div>\n";
                }
            }
            html += "\t\t<h3>" + clip.name + "</h3>\n";
            html += "\t</a>\n";
            html += "</li>\n";

            itemNumber++;
            //html += "\t\t<img class=\"overlay\" src=\"" + Request.Url.GetLeftPart(UriPartial.Authority) + "/Images/video_play_overlay.png\"/>\n";
            return(html);
        }
Exemplo n.º 3
0
        public static string Director(upnpObject aObject)
        {
            string result = string.Empty;

            if (aObject is videoItem)
            {
                videoItem item = aObject as videoItem;
                for (int i = 0; i < item.Director.Count; ++i)
                {
                    if (i > 0 && i < item.Director.Count - 1)
                    {
                        result += ", ";
                    }
                    result += item.Director[i];
                }
            }
            else if (aObject is videoBroadcast)
            {
                videoBroadcast item = aObject as videoBroadcast;
                for (int i = 0; i < item.Director.Count; ++i)
                {
                    if (i > 0 && i < item.Director.Count - 1)
                    {
                        result += ", ";
                    }
                    result += item.Director[i];
                }
            }
            else if (aObject is movie)
            {
                movie item = aObject as movie;
                for (int i = 0; i < item.Director.Count; ++i)
                {
                    if (i > 0 && i < item.Director.Count - 1)
                    {
                        result += ", ";
                    }
                    result += item.Director[i];
                }
            }
            else if (aObject is musicVideoClip)
            {
                musicVideoClip item = aObject as musicVideoClip;
                for (int i = 0; i < item.Director.Count; ++i)
                {
                    if (i > 0 && i < item.Director.Count - 1)
                    {
                        result += ", ";
                    }
                    result += item.Director[i];
                }
            }

            // always return a non-null string
            return(NonNullString(result));
        }
Exemplo n.º 4
0
        public Trailer(string aId, string aTitle, string aRunTime, string aRating, string aStudio, string aDirector, string aDescription,
                       IList <string> aCast, IList <string> aGenre, IPoster aPoster, IVideo aVideo)
        {
            iId = aId;

            iMetadata       = new videoItem();
            iMetadata.Id    = aId;
            iMetadata.Title = aTitle;
            iMetadata.Genre.AddRange(aGenre);

            string[] directors = aDirector.Split(',');
            foreach (string s in directors)
            {
                iMetadata.Director.Add(s.Trim());
            }

            foreach (string s in aCast)
            {
                actor actor = new actor();
                actor.Actor = s;
                iMetadata.Actor.Add(actor);
            }

            iMetadata.LongDescription = aDescription;
            iMetadata.Publisher       = aStudio;
            iMetadata.Rating          = aRating;

            if (!string.IsNullOrEmpty(aPoster.UriSmall))
            {
                iMetadata.AlbumArtUri.Add(aPoster.UriSmall);
            }

            resource res = new resource();

            try
            {
                res.Duration = (new Time(string.Format("0:{0}", aRunTime))).ToString();
            }
            catch (Time.TimeInvalid)
            {
                res.Duration = (new Time(0)).ToString();
            }
            res.Size         = aVideo.Size;
            res.ProtocolInfo = "http-get:*:video/x-m4v:*";
            res.Uri          = aVideo.Uri;

            iMetadata.Res.Add(res);
        }
Exemplo n.º 5
0
        public static string Info(upnpObject aObject)
        {
            string result = string.Empty;

            if (aObject is audioItem)
            {
                audioItem item = aObject as audioItem;
                result = item.LongDescription;
            }
            else if (aObject is videoItem)
            {
                videoItem item = aObject as videoItem;
                result = item.LongDescription;
            }
            else if (aObject is album)
            {
                album item = aObject as album;
                result = item.LongDescription;
            }

            // always return a non-null string
            return(NonNullString(result));
        }
Exemplo n.º 6
0
        public static string Genre(upnpObject aObject)
        {
            string result = string.Empty;

            if (aObject is genre)
            {
                genre genre = aObject as genre;
                result = genre.Title;
            }
            else if (aObject is musicArtist)
            {
                musicArtist artist = aObject as musicArtist;
                for (int i = 0; i < artist.Genre.Count; ++i)
                {
                    if (i > 0 && i < artist.Genre.Count - 1)
                    {
                        result += ", ";
                    }
                    result += artist.Genre[i];
                }
            }
            else if (aObject is musicAlbum)
            {
                musicAlbum album = aObject as musicAlbum;
                for (int i = 0; i < album.Genre.Count; ++i)
                {
                    if (i > 0 && i < album.Genre.Count - 1)
                    {
                        result += ", ";
                    }
                    result += album.Genre[i];
                }
            }
            else if (aObject is audioItem)
            {
                audioItem item = aObject as audioItem;
                for (int i = 0; i < item.Genre.Count; ++i)
                {
                    if (i > 0 && i < item.Genre.Count - 1)
                    {
                        result += ", ";
                    }
                    result += item.Genre[i];
                }
            }
            else if (aObject is videoItem)
            {
                videoItem item = aObject as videoItem;
                for (int i = 0; i < item.Genre.Count; ++i)
                {
                    if (i > 0 && i < item.Genre.Count - 1)
                    {
                        result += ", ";
                    }
                    result += item.Genre[i];
                }
            }

            // always return a non-null string
            return(NonNullString(result));
        }
Exemplo n.º 7
0
        public static string Publisher(upnpObject aObject)
        {
            string result = string.Empty;

            if (aObject is album)
            {
                album item = aObject as album;
                for (int i = 0; i < item.Publisher.Count; ++i)
                {
                    if (i > 0 && i < item.Publisher.Count - 1)
                    {
                        result += ", ";
                    }
                    result += item.Publisher[i];
                }
            }
            else if (aObject is musicVideoClip)
            {
                musicVideoClip item = aObject as musicVideoClip;
                result = item.Publisher;
            }
            else if (aObject is musicTrack)
            {
                musicTrack item = aObject as musicTrack;
                for (int i = 0; i < item.Publisher.Count; ++i)
                {
                    if (i > 0 && i < item.Publisher.Count - 1)
                    {
                        result += ", ";
                    }
                    result += item.Publisher[i];
                }
            }
            else if (aObject is audioBook)
            {
                audioBook item = aObject as audioBook;
                for (int i = 0; i < item.Publisher.Count; ++i)
                {
                    if (i > 0 && i < item.Publisher.Count - 1)
                    {
                        result += ", ";
                    }
                    result += item.Publisher[i];
                }
            }
            else if (aObject is videoItem)
            {
                videoItem item = aObject as videoItem;
                result = item.Publisher;
            }
            else if (aObject is videoBroadcast)
            {
                videoBroadcast item = aObject as videoBroadcast;
                result = item.Publisher;
            }
            else if (aObject is movie)
            {
                movie item = aObject as movie;
                result = item.Publisher;
            }

            // always return a non-null string
            return(NonNullString(result));
        }
Exemplo n.º 8
0
        public static upnpObject Create(FileInfo aInfo, string aArtworkUri, string aResourceUri)
        {
            // check for playlist file
            if (aInfo.Extension == Playlist.kPlaylistExtension)
            {
                playlistContainer playlist = new playlistContainer();
                resource          resource = new resource();
                playlist.Res.Add(resource);

                playlist.Id          = aInfo.FullName;
                playlist.Title       = aInfo.Name;
                playlist.WriteStatus = "PROTECTED";
                playlist.Restricted  = true;

                resource.Size = aInfo.Length;
                resource.Uri  = aResourceUri;

                return(playlist);
            }

            // check for audio/video file
            try
            {
                if (IsTagLibSupported(aInfo))
                {
                    TagLib.File f = TagLib.File.Create(aInfo.FullName);

                    if (f.Properties.MediaTypes == MediaTypes.Audio)
                    {
                        musicTrack track    = new musicTrack();
                        resource   resource = new resource();
                        track.Res.Add(resource);

                        track.Id          = aInfo.FullName;
                        track.WriteStatus = "PROTECTED";
                        track.Restricted  = true;

                        if (!f.Tag.IsEmpty)
                        {
                            if (f.Tag.Title != null)
                            {
                                track.Title = f.Tag.Title;
                            }
                            else
                            {
                                track.Title = aInfo.Name;
                            }
                            if (f.Tag.Album != null)
                            {
                                track.Album.Add(f.Tag.Album);
                            }
                            foreach (string g in f.Tag.Genres)
                            {
                                track.Genre.Add(g);
                            }
                            track.OriginalTrackNumber = (int)f.Tag.Track;
                            track.Date = f.Tag.Year.ToString();
                            foreach (string p in f.Tag.Performers)
                            {
                                artist performer = new artist();
                                performer.Artist = p;
                                performer.Role   = "Performer";
                                track.Artist.Add(performer);
                            }
                            foreach (string a in f.Tag.AlbumArtists)
                            {
                                artist artist = new artist();
                                artist.Artist = a;
                                artist.Role   = "AlbumArtist";
                                track.Artist.Add(artist);
                            }
                            foreach (string c in f.Tag.Composers)
                            {
                                artist composer = new artist();
                                composer.Artist = c;
                                composer.Role   = "Composer";
                                track.Artist.Add(composer);
                            }
                            if (f.Tag.Conductor != null)
                            {
                                artist conductor = new artist();
                                conductor.Artist = f.Tag.Conductor;
                                conductor.Role   = "Conductor";
                                track.Artist.Add(conductor);
                            }
                        }
                        else
                        {
                            track.Title = aInfo.Name;
                        }

                        resource.Bitrate         = (int)((f.Properties.AudioBitrate * 1000.0f) / 8.0f);
                        resource.Duration        = new Time((int)f.Properties.Duration.TotalSeconds).ToString();
                        resource.NrAudioChannels = f.Properties.AudioChannels;
                        resource.SampleFrequency = f.Properties.AudioSampleRate;
                        resource.Size            = aInfo.Length;
                        resource.Uri             = aResourceUri;

                        resource.ProtocolInfo = string.Format("http-get:*:{0}:*", f.MimeType.Replace("taglib", "audio"));
                        resource.ProtocolInfo = resource.ProtocolInfo.Replace("flac", "x-flac");
                        resource.ProtocolInfo = resource.ProtocolInfo.Replace("aif:", "aiff:");
                        resource.ProtocolInfo = resource.ProtocolInfo.Replace("wma", "x-ms-wma");
                        resource.ProtocolInfo = resource.ProtocolInfo.Replace("asf", "x-ms-asf");
                        resource.ProtocolInfo = resource.ProtocolInfo.Replace("mp3", "mpeg");
                        resource.ProtocolInfo = resource.ProtocolInfo.Replace("mpeg3", "mpeg");
                        resource.ProtocolInfo = resource.ProtocolInfo.Replace("m4a", "x-m4a");

                        if (!string.IsNullOrEmpty(aArtworkUri))
                        {
                            track.AlbumArtUri.Add(aArtworkUri);
                        }

                        return(track);
                    }
                    else if (f.Properties.MediaTypes == TagLib.MediaTypes.Video)
                    {
                        videoItem video    = new videoItem();
                        resource  resource = new resource();
                        video.Res.Add(resource);

                        video.Id          = aInfo.FullName;
                        video.WriteStatus = "PROTECTED";
                        video.Restricted  = true;

                        if (!f.Tag.IsEmpty)
                        {
                            if (f.Tag.Title != null)
                            {
                                video.Title = f.Tag.Title;
                            }
                            else
                            {
                                video.Title = aInfo.Name;
                            }
                            foreach (string g in f.Tag.Genres)
                            {
                                video.Genre.Add(g);
                            }
                            foreach (string p in f.Tag.Performers)
                            {
                                actor performer = new actor();
                                performer.Actor = p;
                                performer.Role  = "Actor";
                                video.Actor.Add(performer);
                            }
                        }
                        else
                        {
                            video.Title = aInfo.Name;
                        }

                        resource.Bitrate         = (int)((f.Properties.AudioBitrate * 1000.0f) / 8.0f);
                        resource.Duration        = new Time((int)f.Properties.Duration.TotalSeconds).ToString();
                        resource.NrAudioChannels = f.Properties.AudioChannels;
                        resource.SampleFrequency = f.Properties.AudioSampleRate;
                        resource.Size            = aInfo.Length;
                        resource.Uri             = aResourceUri;

                        resource.ProtocolInfo = string.Format("http-get:*:{0}:*", f.MimeType.Replace("taglib", "video"));

                        if (!string.IsNullOrEmpty(aArtworkUri))
                        {
                            video.AlbumArtUri.Add(aArtworkUri);
                        }

                        return(video);
                    }
                }
            }
            catch (TagLib.UnsupportedFormatException)
            {
            }
            catch (Exception e)
            {
                UserLog.WriteLine(aInfo.FullName + ": " + e.Message);
            }

            // check for image file
            string mimeType;

            if (IsImageFile(aInfo, out mimeType))
            {
                photo    photo    = new photo();
                resource resource = new resource();
                photo.Res.Add(resource);

                photo.Id          = aInfo.FullName;
                photo.Title       = aInfo.Name;
                photo.WriteStatus = "PROTECTED";
                photo.Restricted  = true;

                resource.Size         = aInfo.Length;
                resource.Uri          = aResourceUri;
                resource.ProtocolInfo = string.Format("http-get:*:{0}:*", mimeType);

                if (!string.IsNullOrEmpty(aArtworkUri))
                {
                    photo.AlbumArtUri.Add(aArtworkUri);
                }

                return(photo);
            }

            // all other types
            {
                item     item     = new item();
                resource resource = new resource();
                item.Res.Add(resource);

                item.Id          = aInfo.FullName;
                item.Title       = aInfo.Name;
                item.WriteStatus = "PROTECTED";
                item.Restricted  = true;

                resource.Size         = aInfo.Length;
                resource.Uri          = aResourceUri;
                resource.ProtocolInfo = string.Format("http-get:*:application/octet-stream:*");

                if (!string.IsNullOrEmpty(aArtworkUri))
                {
                    item.AlbumArtUri.Add(aArtworkUri);
                }

                return(item);
            }
        }