Ejemplo n.º 1
0
 public override void BrowseWebMetadata(XmlWriter xmlWriter, MediaSettings settings, string idParams)
 {
     if (this.Audio)
     {
         ItemAudio.WriteHTML(xmlWriter, this.Id.ToString(), this.Title, "0:00:00", string.Empty, string.Empty, string.Empty, false, null);
     }
     else
     {
         ItemVideo.WriteHTML(xmlWriter, this.Id.ToString(), this.Title, "0:00:00", this.Resolution, false, null);
     }
 }
Ejemplo n.º 2
0
 public override void GetWebPlayer(XmlWriter xmlWriter, ItemManager manager, Dictionary <string, string> urlParams)
 {
     if (this.Audio)
     {
         ItemAudio.WriteHTMLPlayer(xmlWriter, this.Id.ToString(), GetDuration(), urlParams);
     }
     else
     {
         ItemVideo.WriteHTMLPlayer(xmlWriter, manager, this.Id.ToString(), GetDuration(), urlParams, null);
     }
 }
Ejemplo n.º 3
0
        public override void BrowseMetadata(XmlWriter writer, MediaSettings settings, string host, string idParams, HashSet <string> filterSet, int parentId, TimeSpan?startTime)
        {
            writer.WriteStartElement("item");

            writer.WriteAttributeString("id", this.Id.ToString());
            writer.WriteAttributeString("restricted", "true");
            writer.WriteAttributeString("parentID", parentId + "_" + VideoIndex);

            //Povinne hodnoty
            writer.WriteElementString("dc", "title", null, this.Title);
            writer.WriteElementString("upnp", "class", null, "object.item.videoItem");

            //Volitelne hodnoty
            if (filterSet == null || filterSet.Contains("dc:date"))
            {
                writer.WriteElementString("dc", "date", null, this.Date.ToString("yyyy-MM-dd"));
            }

            if ((filterSet == null || filterSet.Contains("upnp:icon")) && (this.Parent.HasThumbnail.HasValue && this.Parent.HasThumbnail.Value))
            {
                writer.WriteElementString("upnp", "icon", null, host + "/thumbnail/image.jpg?id=" + this.Id + "&codec=jpeg&width=160&height=160&keepaspect");
            }

            if ((filterSet == null || filterSet.Contains("upnp:albumArtURI")) && (this.Parent.HasThumbnail.HasValue && this.Parent.HasThumbnail.Value))
            {
                writer.WriteStartElement("upnp", "albumArtURI", null);
                writer.WriteAttributeString("dlna", "profileID", "urn:schemas-dlna-org:metadata-1-0/", "JPEG_TN");
                writer.WriteValue(host + "/thumbnail/image.jpg?id=" + this.Id + "&codec=jpeg&width=160&height=160&keepaspect");
                writer.WriteEndElement();
            }

            //Vlozi titulkovy subor, vynecha sa item s titulkami vo videu
            if ((filterSet == null || filterSet.Contains("sec:CaptionInfoEx")) && (this.SubtitlesPath == null))
            {
                ItemVideo subItem = this.Parent.Children.OfType <ItemVideo>().Where(a => a.SubtitlesPath != null).FirstOrDefault();
                if (subItem != null)
                {
                    string type = System.IO.Path.GetExtension(subItem.SubtitlesPath).TrimStart('.');

                    writer.WriteStartElement("sec", "CaptionInfoEx", null);
                    writer.WriteAttributeString("sec", "type", null, type);
                    writer.WriteValue(host + "/subtitle/subtitle." + type + "?id=" + subItem.Id);
                    writer.WriteEndElement();
                }
            }

            if (filterSet == null || filterSet.Any(a => a.StartsWith("res")))
            {
                TimeSpan?duration = this.GetDuration();
                if (duration.HasValue && startTime.HasValue)
                {
                    duration -= startTime;
                }

                if (settings.Video.NativeFile && this.SubtitlesPath == null && this.Path == null && !startTime.HasValue)
                {
                    //Povoli sa povodne video ak sa nevkladaju titulky, nemeni sa zvukova stopa alebo zaciatok videa
                    writer.WriteStartElement("res");

                    if (filterSet == null || filterSet.Contains("res@size"))
                    {
                        writer.WriteAttributeString("size", ((ItemContainerVideo)this.Parent).Length.ToString());
                    }

                    if (duration.HasValue && (filterSet == null || filterSet.Contains("res@duration")))
                    {
                        writer.WriteAttributeString("duration", duration.Value.ToString("h':'mm':'ss'.'fff"));
                    }

                    int?bitrate = ((ItemContainerVideo)this.Parent).Bitrate;
                    if (bitrate.HasValue && (filterSet == null || filterSet.Contains("res@bitrate")))
                    {
                        writer.WriteAttributeString("bitrate", bitrate.Value.ToString());
                    }

                    string resolution = ((ItemContainerVideo)this.Parent).Resolution;
                    if (resolution != null && (filterSet == null || filterSet.Contains("res@resolution")))
                    {
                        writer.WriteAttributeString("resolution", resolution);
                    }

                    writer.WriteAttributeString("protocolInfo", string.Format("http-get:*:{0}:{1}", GetMime(), GetFileFeature(settings)));
                    writer.WriteValue(string.Format("{0}/files/video{1}?id={2}", host, System.IO.Path.GetExtension(this.Parent.Path), this.Id));
                    writer.WriteEndElement();
                }

                foreach (EncoderBuilder sett in settings.Video.Encode)
                {
                    writer.WriteStartElement("res");

                    if (duration.HasValue && (filterSet == null || filterSet.Contains("res@duration")))
                    {
                        writer.WriteAttributeString("duration", duration.Value.ToString("h':'mm':'ss'.'fff"));
                    }

                    if (sett.VidBitrate != null && (filterSet == null || filterSet.Contains("res@bitrate")))
                    {
                        writer.WriteAttributeString("bitrate", sett.VidBitrate);
                    }

                    if (sett.Resolution != null && (filterSet == null || filterSet.Contains("res@resolution")))
                    {
                        writer.WriteAttributeString("resolution", sett.Resolution);
                    }

                    writer.WriteAttributeString("protocolInfo", string.Format("http-get:*:{0}:{1}{2}", sett.GetMime(), sett.GetDlnaType(), settings.Video.EncodeFeature));
                    writer.WriteValue(string.Format("{0}/encode/video?id={1}{2}{3}{4}", host, this.Id, sett.GetParamString(), this.Path,
                                                    startTime.HasValue ? "&starttime=" + startTime.Value.TotalSeconds : string.Empty));
                    writer.WriteEndElement();
                }
            }

            writer.WriteEndElement();
        }