Пример #1
0
        //
        // Player
        protected ActionResult CreatePlayer(IWebStreamingService streamControl, PlayerViewModel model, List<StreamTarget> targets, WebTranscoderProfile profile, bool album)
        {
            // save stream request
            if (!PlayerOpenedBy.Contains(Request.UserHostAddress))
            {
                PlayerOpenedBy.Add(Request.UserHostAddress);
            }

            // get view properties
            VideoPlayer player = targets.First(x => profile.Targets.Contains(x.Name)).Player;
            string viewName = Enum.GetName(typeof(VideoPlayer), player) + (album ? "Album" : "") + "Player";

            // generate view
            var supportedTargets = Configuration.StreamingPlatforms.GetValidTargetsForUserAgent(Request.UserAgent).Intersect(targets.Select(x => x.Name));
            model.Transcoders = ProfileModel.GetProfilesForTargets(streamControl, supportedTargets).Select(x => x.Name);
            model.Transcoder = profile.Name;
            model.TranscoderProfile = profile;
            model.Player = player;
            model.PlayerViewName = viewName;
            Log.Debug("Created player with size={0} view={1} transcoder={2} url={3}", model.Size, viewName, profile.Name, model.URL);
            return PartialView("Player", model);
        }
Пример #2
0
        //
        // Player
        protected ActionResult CreatePlayer(IWebStreamingService streamControl, PlayerViewModel model, List<StreamTarget> targets, WebTranscoderProfile profile, bool album)
        {
            // save stream request
            if (!PlayerOpenedBy.Contains(Request.UserHostAddress))
            {
                PlayerOpenedBy.Add(Request.UserHostAddress);
            }

            // get all transcoder profiles
            List<string> profiles = new List<string>();
            foreach (StreamTarget target in targets)
            {
                if (target.ValidForRequest(Request))
                    profiles = profiles.Concat(streamControl.GetTranscoderProfilesForTarget(target.Name).Select(x => x.Name)).Distinct().ToList();
            }

            // get view properties
            VideoPlayer player = targets.First(x => profile.Targets.Contains(x.Name)).Player;
            string viewName = Enum.GetName(typeof(VideoPlayer), player) + (album ? "Album" : "") + "Player";

            // generate view
            model.Transcoders = profiles;
            model.Transcoder = profile.Name;
            model.TranscoderProfile = profile;
            model.Player = player;
            model.PlayerViewName = viewName;
            Log.Debug("Created player with size={0} view={1} transcoder={2} url={3}", model.Size, viewName, profile.Name, model.URL);
            return PartialView("Player", model);
        }
Пример #3
0
        public ActionResult Player(WebMediaType type, string itemId, int fileindex = 0)
        {
            PlayerViewModel model = new PlayerViewModel();
            model.MediaType = type;
            model.MediaId = itemId;
            model.ContinuationId = randomGenerator.Next(100000, 999999).ToString();

            // get profile
            var profile = GetProfile(GetStreamControl(type), GetDefaultProfile(type));

            // get size
            if (type == WebMediaType.TV)
            {
                // TODO: we should start the timeshifting through an AJAX call, and then load the player based upon the results
                // from that call. Also avoids timeouts of the player when initiating the timeshifting takes a long time.
                // HACK: currently there is no method in WSS to get the aspect ratio for streams with a fixed aspect ratio.
                model.Size = GetStreamControl(type).GetStreamSize(type, null, "", 0, profile.Name);
            }
            else if (!StreamTarget.GetAllTargets().First(t => profile.Targets.Contains(t.Name)).HasVideo)
            {
                model.Size = new WebResolution() { Width = 600, Height = 100 };
            }
            else
            {
                model.Size = GetStreamControl(type).GetStreamSize(type, GetProvider(type), itemId, 0, profile.Name);
            }

            // generate url
            RouteValueDictionary parameters = new RouteValueDictionary();
            parameters["item"] = itemId;
            parameters["fileindex"] = fileindex;
            parameters["transcoder"] = profile.Name;
            parameters["continuationId"] = model.ContinuationId;
            model.URL = Url.Action(Enum.GetName(typeof(WebMediaType), type), parameters);

            // generic part
            var targets = type == WebMediaType.MusicTrack ? StreamTarget.GetAllTargets() : StreamTarget.GetVideoTargets();
            return CreatePlayer(GetStreamControl(type), model, targets, profile, false);
        }
Пример #4
0
        public ActionResult Player(WebStreamMediaType type, string itemId)
        {
            PlayerViewModel model = new PlayerViewModel();
            model.MediaType = type;
            model.MediaId = itemId;

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

            // get size
            if(type == WebStreamMediaType.TV)
            {
                // TODO: we should start the timeshifting through an AJAX call, and then load the player based upon the results
                // from that call. Also avoids timeouts of the player when initiating the timeshifting takes a long time.
                // HACK: currently there is no method in WSS to get the aspect ratio for streams with a fixed aspect ratio.
                model.Size = GetStreamControl(type).GetStreamSize(type, null, "", profile.Name);
            }
            else
            {
                model.Size = GetStreamControl(type).GetStreamSize(type, GetProvider(type), itemId, profile.Name);
            }

            // generate url
            RouteValueDictionary parameters = new RouteValueDictionary();
            parameters["item"] = itemId;
            parameters["transcoder"] = profile.Name;
            parameters["continuationId"] = randomGenerator.Next(10000, 99999);
            model.URL = Url.Action(Enum.GetName(typeof(WebStreamMediaType), type), parameters);

            // generic part
            return CreatePlayer(GetStreamControl(type), model, StreamTarget.GetVideoTargets(), profile);
        }