示例#1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (FileName.Length != 0)
            {
                hash ^= FileName.GetHashCode();
            }
            if (MediaName.Length != 0)
            {
                hash ^= MediaName.GetHashCode();
            }
            if (DownloadedUTC.Length != 0)
            {
                hash ^= DownloadedUTC.GetHashCode();
            }
            if (LastWatchedUTC.Length != 0)
            {
                hash ^= LastWatchedUTC.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#2
0
        public ActionResult Playlist(WebMediaType type, string itemId, string transcoder = null)
        {
            // save stream request
            if (!PlayerOpenedBy.Contains(Request.UserHostAddress))
            {
                PlayerOpenedBy.Add(Request.UserHostAddress);
            }

            // get profile
            var defaultProfile = type == WebMediaType.TV || type == WebMediaType.Recording ?
                                 Settings.ActiveSettings.DefaultTVProfile :
                                 Settings.ActiveSettings.DefaultMediaProfile;
            var profile = GetProfile(GetStreamControl(type), transcoder ?? defaultProfile);

            // generate url
            RouteValueDictionary parameters = new RouteValueDictionary();

            parameters["item"]           = itemId;
            parameters["transcoder"]     = profile.Name;
            parameters["continuationId"] = "playlist-" + randomGenerator.Next(10000, 99999);
            string url = Url.Action(Enum.GetName(typeof(WebMediaType), type), "Stream", parameters, Request.Url.Scheme, Request.Url.Host);

            // create playlist
            StringBuilder m3u = new StringBuilder();

            m3u.AppendLine("#EXTM3U");
            m3u.AppendLine("#EXTINF:-1, " + MediaName.GetMediaName(type, itemId));
            m3u.AppendLine(url);

            // return it
            byte[] data = Encoding.UTF8.GetBytes(m3u.ToString());
            return(File(data, "audio/x-mpegurl", "stream.m3u"));
        }
示例#3
0
 public Release ToRelease()
 {
     return(new Release(
                MediaName.ToLower(),
                ReleaseNumber,
                SubReleaseNumber ?? 0,
                Url
                ));
 }
示例#4
0
        public ActionResult Playlist(WebMediaType type, string itemId, string transcoder = null)
        {
            if (!PlayerOpenedBy.Contains(Request.UserHostAddress))
            {
                PlayerOpenedBy.Add(Request.UserHostAddress);
            }

            var           profile = GetProfile(GetStreamControl(type), transcoder ?? GetDefaultProfile(type));
            StringBuilder m3u     = new StringBuilder();

            m3u.AppendLine("#EXTM3U");

            RouteValueDictionary parameters;
            string continuationId = "playlist-" + randomGenerator.Next(10000, 99999);
            string url;
            int    filecount = 1;

            switch (type)
            {
            case WebMediaType.MusicAlbum:
                // add all album tracks
                foreach (WebMusicTrackBasic track in Connections.Current.MAS.GetMusicTracksBasicForAlbum(Settings.ActiveSettings.MusicProvider, itemId, sort: WebSortField.MusicTrackNumber))
                {
                    parameters                   = new RouteValueDictionary();
                    parameters["item"]           = track.Id;
                    parameters["transcoder"]     = profile.Name;
                    parameters["continuationId"] = continuationId;
                    m3u.AppendLine(String.Format("#EXTINF:{0},{1}", track.Duration, track.Title));
                    url = Url.AbsoluteAction(Enum.GetName(typeof(WebMediaType), WebMediaType.MusicTrack), "Stream", parameters);
                    m3u.AppendLine(url);
                }
                break;

            case WebMediaType.MusicTrack:
            case WebMediaType.TVEpisode:
            case WebMediaType.Movie:
                var mediaItem = Connections.Current.MAS.GetMediaItem(GetProvider(type), type, itemId);
                filecount = mediaItem.Path.Count;
                goto case WebMediaType.Recording;     // really, Microsoft? Fall-through cases are useful.

            case WebMediaType.TV:
            case WebMediaType.Recording:
                for (int i = 0; i < filecount; i++)
                {
                    parameters                   = new RouteValueDictionary();
                    parameters["item"]           = itemId;
                    parameters["transcoder"]     = profile.Name;
                    parameters["continuationId"] = continuationId;
                    parameters["fileindex"]      = i;
                    url = Url.AbsoluteAction(Enum.GetName(typeof(WebMediaType), type), "Stream", parameters);
                    m3u.AppendLine("#EXTINF:-1, " + MediaName.GetMediaName(type, itemId));
                    m3u.AppendLine(url);
                }
                break;

            default:
                Log.Error("Requested playlist for non-supported media type {0} with id {1}", type, itemId);
                break;
            }

            // return it
            byte[] data = Encoding.UTF8.GetBytes(m3u.ToString());
            return(File(data, "audio/x-mpegurl", "stream.m3u"));
        }