示例#1
0
        public ActionResult MusicPlayer(string albumId)
        {
            AlbumPlayerViewModel model = new AlbumPlayerViewModel();

            model.MediaId = albumId;
            WebTranscoderProfile profile = GetProfile(Connections.Current.MASStreamControl, Settings.ActiveSettings.DefaultAudioProfile);

            model.Tracks = Connections.Current.MAS.GetMusicTracksDetailedForAlbum(Settings.ActiveSettings.MusicProvider, albumId);
            return(CreatePlayer(Connections.Current.MASStreamControl, model, StreamTarget.GetAudioTargets(), profile, true));
        }
示例#2
0
        public ActionResult MusicPlayer(string albumId)
        {
            AlbumPlayerViewModel model = new AlbumPlayerViewModel();

            model.MediaId        = albumId;
            model.ContinuationId = "playlist-" + randomGenerator.Next(100000, 999999).ToString();
            WebTranscoderProfile profile = GetProfile(Connections.Current.MASStreamControl,
                                                      Configuration.StreamingPlatforms.GetDefaultProfileForUserAgent(StreamingProfileType.Audio, Request.UserAgent));

            model.Tracks = Connections.Current.MAS.GetMusicTracksDetailedForAlbum(Settings.ActiveSettings.MusicProvider, albumId);
            return(CreatePlayer(Connections.Current.MASStreamControl, model, StreamTarget.GetAudioTargets(), profile, true));
        }
示例#3
0
        public ActionResult Player(WebStreamMediaType type, string itemId, bool video = true)
        {
            // get transcoding profile
            IWebStreamingService streamControl = GetStreamControl(type);
            WebTranscoderProfile profile       = null;

            if (Request.QueryString["transcoder"] != null)
            {
                profile = GetStreamControl(type).GetTranscoderProfileByName(Request.QueryString["transcoder"]);
            }
            if (Request.Form["transcoder"] != null)
            {
                profile = GetStreamControl(type).GetTranscoderProfileByName(Request.Form["transcoder"]);
            }
            if (profile == null)
            {
                string defaultName = "";
                if (type == WebStreamMediaType.TV || type == WebStreamMediaType.Recording)
                {
                    defaultName = Settings.ActiveSettings.DefaultTVProfile;
                }
                else if (video)
                {
                    defaultName = Settings.ActiveSettings.DefaultMediaProfile;
                }
                else
                {
                    defaultName = Settings.ActiveSettings.DefaultAudioProfile;
                }
                profile = GetStreamControl(type).GetTranscoderProfileByName(defaultName);
            }

            // get all transcoder profiles
            List <StreamTarget> targets  = video ? StreamTarget.GetVideoTargets() : StreamTarget.GetAudioTargets();
            List <string>       profiles = new List <string>();

            foreach (StreamTarget target in targets)
            {
                profiles = profiles.Concat(GetStreamControl(type).GetTranscoderProfilesForTarget(target.Name).Select(x => x.Name)).ToList();
            }

            // get view properties
            VideoPlayer player   = targets.First(x => x.Name == profile.Target).Player;
            string      viewName = Enum.GetName(typeof(VideoPlayer), player) + "Player";

            // player size
            WebResolution playerSize;

            if (!video)
            {
                playerSize = new WebResolution()
                {
                    Width = 300, Height = 150
                };
            }
            else
            {
                playerSize = GetStreamControl(type).GetStreamSize(type, GetProvider(type), itemId, profile.Name);
            }

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

            parameters["item"]       = itemId;
            parameters["transcoder"] = profile.Name;

            // generate view
            return(PartialView(new PlayerViewModel
            {
                Transcoders = profiles,
                Transcoder = profile.Name,
                Player = player,
                PlayerViewName = viewName,
                URL = Url.Action(Enum.GetName(typeof(WebStreamMediaType), type), parameters),
                Size = playerSize
            }));
        }