/// <summary> /// Loads needed settings from their repository. /// </summary> private void LoadSettings() { //Load the player. thePlayer = MediaPlayer.GetForModule(ModuleId); if (thePlayer == null) { thePlayer = new MediaPlayer(); thePlayer.ModuleGuid = ModuleGuid; thePlayer.ModuleId = ModuleId; thePlayer.PlayerType = MediaType.Audio; if (IsEditable) { SiteUser currentUser = SiteUtils.GetCurrentSiteUser(); if (currentUser != null) { thePlayer.UserGuid = currentUser.UserGuid; MediaPlayer.Add(thePlayer); } } } config = new AudioPlayerConfiguration(Settings); if (config.DisableShuffle) { ShuffleControl.Visible = false; ShuffleOffControl.Visible = false; } if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } }
/// <summary> /// Loads needed settings from their repository. /// </summary> private void LoadSettings() { //siteRoot = WebUtils.GetSiteRoot(); //if (SiteUtils.IsSecureRequest()) //{ // siteRoot = siteRoot.Replace("http:", "https:"); //} //Load the player. thePlayer = MediaPlayer.GetForModule(ModuleId); if (thePlayer == null) { thePlayer = new MediaPlayer(); thePlayer.ModuleGuid = ModuleGuid; thePlayer.ModuleId = ModuleId; thePlayer.PlayerType = MediaType.Video; if (IsEditable) { SiteUser currentUser = SiteUtils.GetCurrentSiteUser(); if (currentUser != null) { thePlayer.UserGuid = currentUser.UserGuid; MediaPlayer.Add(thePlayer); } } } config = new VideoPlayerConfiguration(Settings); if (config.DisableShuffle) { ShuffleControl.Visible = false; ShuffleOffControl.Visible = false; } if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } }
public void InstallContent(Module module, string configInfo) { if (string.IsNullOrEmpty(configInfo)) { return; } SiteSettings siteSettings = new SiteSettings(module.SiteId); SiteUser admin = SiteUser.GetNewestUser(siteSettings); XmlDocument xml = new XmlDocument(); using (StreamReader stream = File.OpenText(HostingEnvironment.MapPath(configInfo))) { xml.LoadXml(stream.ReadToEnd()); } MediaPlayer player = new MediaPlayer(); player.ModuleGuid = module.ModuleGuid; player.ModuleId = module.ModuleId; player.PlayerType = MediaType.Audio; if ((xml.DocumentElement.Attributes["type"] != null) && (xml.DocumentElement.Attributes["type"].Value.Length > 0)) { player.PlayerType = (MediaType)Enum.Parse(typeof(MediaType), xml.DocumentElement.Attributes["type"].Value); } MediaPlayer.Add(player); XmlNode tracksNode = null; foreach (XmlNode n in xml.DocumentElement.ChildNodes) { if (n.Name == "tracks") { tracksNode = n; break; } } if (tracksNode == null) { return; } foreach (XmlNode node in xml.DocumentElement.ChildNodes) { if (node.Name == "moduleSetting") { XmlAttributeCollection settingAttributes = node.Attributes; if ((settingAttributes["settingKey"] != null) && (settingAttributes["settingKey"].Value.Length > 0)) { string key = settingAttributes["settingKey"].Value; string val = string.Empty; if (settingAttributes["settingValue"] != null) { val = settingAttributes["settingValue"].Value; if ((key == "HeaderContent") || (key == "FooterContent")) { val = System.Web.HttpUtility.HtmlDecode(val); } } ModuleSettings.UpdateModuleSetting(module.ModuleGuid, module.ModuleId, key, val); } } } foreach (XmlNode trackNode in tracksNode.ChildNodes) { if (trackNode.Name == "track") { XmlAttributeCollection trackAttrributes = trackNode.Attributes; MediaTrack track = new MediaTrack(); track.PlayerId = player.PlayerId; track.TrackType = player.PlayerType; if ((trackAttrributes["name"] != null) && (trackAttrributes["name"].Value.Length > 0)) { track.Name = trackAttrributes["name"].Value; } if ((trackAttrributes["artist"] != null) && (trackAttrributes["artist"].Value.Length > 0)) { track.Artist = trackAttrributes["artist"].Value; } MediaTrack.Add(track); XmlNode filesNode = null; foreach (XmlNode n in trackNode.ChildNodes) { if (n.Name == "files") { filesNode = n; break; } } if (filesNode == null) { return; } foreach (XmlNode fileNode in filesNode.ChildNodes) { if (fileNode.Name == "file") { MediaFile mediaFile = new MediaFile(); mediaFile.TrackId = track.TrackId; XmlAttributeCollection fileAttrributes = fileNode.Attributes; string targetFormat = string.Empty; string sourcePath = string.Empty; if ((fileAttrributes["targetPathFormat"] != null) && (fileAttrributes["targetPathFormat"].Value.Length > 0)) { targetFormat = fileAttrributes["targetPathFormat"].Value; } if ((fileAttrributes["sourcePath"] != null) && (fileAttrributes["sourcePath"].Value.Length > 0)) { sourcePath = HostingEnvironment.MapPath(fileAttrributes["sourcePath"].Value); } if (targetFormat != string.Empty) { mediaFile.FilePath = string.Format(CultureInfo.InvariantCulture, targetFormat, module.SiteId.ToInvariantString()); string directory = Path.GetDirectoryName(HostingEnvironment.MapPath(mediaFile.FilePath)); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } File.Copy(sourcePath, HostingEnvironment.MapPath(mediaFile.FilePath)); MediaFile.Add(mediaFile); } else //targetPathFormat is not defined so we don't need to move the file { mediaFile.FilePath = fileAttrributes["sourcePath"].Value; MediaFile.Add(mediaFile); } } } } } }