protected string LoadSample(string information) { int sampleNumber = 0; if (Int32.TryParse(information.ToLower().Replace("sample", ""), out sampleNumber)) { return(HelperClass.HostChanger(HelperClass.StringEncoderDecoder(ConfigurationManager.AppSettings["SampleVideo" + sampleNumber], StringConversionMode.Decode))); } else { return(HelperClass.HostChanger(HelperClass.StringEncoderDecoder(ConfigurationManager.AppSettings["SampleVideo1"], StringConversionMode.Decode))); } }
private int GetTotalProcessedFile(string PID) { int processedFiles = 0; string processingLocation = string.Empty; SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader(); SQLClassPeralatan.MintaDataDatabase mintaDataDatabase = new SQLClassPeralatan.MintaDataDatabase("LocalProcessedVideoFolder", "ProcessedVideoInfo", "ProcessID", PID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString); if (!mintaDataDatabase.TerdapatKesalahan) { processingLocation = HelperClass.StringEncoderDecoder(mintaDataDatabase.DataDiterima, StringConversionMode.Decode); processedFiles = Directory.GetFiles(processingLocation, "*.jpg").Length; } else { processedFiles = 0; } return(processedFiles); }
protected void Page_Load(object sender, EventArgs e) { CSSLoader(); if (Request.QueryString["displaypreload"] == "true") { PreloadBufferGenerator(true); } else { PreloadBufferGenerator(); } if (!IsPostBack) { PageImageLoader(); PageThemeLoader(); } if (Request.QueryString.Count != 0) { if (Request.QueryString["new"] == "true") { if (ConfigurationManager.AppSettings["overridehost"] == "true") { VideoURL = HelperClass.HostChanger(Request.QueryString["path"]); } else { VideoURL = Request.QueryString["path"]; } if (Request.QueryString["mode"] != null) { if (Request.QueryString["mode"] == "upload") { try { videoFileName = HelperClass.StringEncoderDecoder(HttpUtility.UrlDecode(Request.QueryString["name"]), StringConversionMode.Decode); } catch (Exception err) { //Response.Redirect("Error.aspx?id=31"); videoFileName = "(Name conversion fail) " + HttpUtility.UrlDecode(Request.QueryString["name"]); } } else { videoFileName = Request.QueryString["name"]; } } else { videoFileName = Request.QueryString["name"]; } videoDuration = TimeSecondToTimeStringConverter(Convert.ToDouble(Request.QueryString["duration"])); videoFrameRate = Convert.ToDouble(Request.QueryString["framerate"]); startFrame = Request.QueryString["startframe"]; videoTotalFrame = Request.QueryString["endframe"]; videoHeight = Convert.ToInt32(Request.QueryString["videoresolution"]); videoPlaySpeed = playSpeedIncrement = Request.QueryString["playspeed"]; middleFrame = videoTotalFrame; CheckerAddress = ConfigurationManager.AppSettings["hostAddress"] + "Checker.aspx?id=" + Request.QueryString["pid"]; if (Request.QueryString["timeposition"] != null) { audioStartDuration = TimeStringToSecondConverter(Request.QueryString["timeposition"]); if (audioStartDuration >= Convert.ToDouble(Request.QueryString["duration"])) { audioStartDuration = 0; } startFrame = TimeToFrameConverter(audioStartDuration, videoFrameRate).ToString(); } else { audioStartDuration = 0; } if (Request.QueryString["playspeed"] != null) { playSpeedIncrement = Request.QueryString["playspeed"]; } else { playSpeedIncrement = "0"; } #region Video player settings #region Progress bar settings if (Request.QueryString["progressbar"] != null) { if (Request.QueryString["progressbar"] == "true") { processProgressBar = "true"; } else { processProgressBar = "false"; } } else { // Default processProgressBar = "true"; } #endregion Progress bar settings #region Time settings if (Request.QueryString["time"] != null) { if (Request.QueryString["time"] == "true") { processTime = "true"; } else { processTime = "false"; } } else { // Default processTime = "true"; } #endregion Time settings #endregion Video player settings } else { videoFileName = Request.QueryString["n"]; videoTotalFrame = Request.QueryString["tf"]; middleFrame = Convert.ToInt32((Convert.ToDouble(videoTotalFrame) / 2)).ToString(); videoFrameRate = Convert.ToDouble(Request.QueryString["fr"]); if (Request.QueryString["sid"] != null) { sessionID = Request.QueryString["sid"]; testMode = true; } if (testMode) { if (VideoSequenceLocation.EndsWith("/")) { VideoURL = VideoSequenceLocation + sessionID + "/" + videoFileName; } else { VideoURL = VideoSequenceLocation + "/" + sessionID + "/" + videoFileName; } } else { if (VideoSequenceLocation.EndsWith("/")) { VideoURL = VideoSequenceLocation + Session.SessionID + "/" + videoFileName; } else { VideoURL = VideoSequenceLocation + "/" + Session.SessionID + "/" + videoFileName; } } } } else { displayPreloadImage = "false"; VideoURL = string.Empty; videoFileName = string.Empty; videoDuration = "0"; videoFrameRate = 0; startFrame = string.Empty; videoTotalFrame = string.Empty; videoHeight = 0; videoPlaySpeed = string.Empty; middleFrame = string.Empty; CheckerAddress = string.Empty; audioStartDuration = 0; startFrame = string.Empty; playSpeedIncrement = string.Empty; } userRequestedURL = HelperClass.StringEncoderDecoder(Request.Url.AbsoluteUri, StringConversionMode.Encode) + "&encoded=true"; }
protected void btnUploadVideo_Click(object sender, EventArgs e) { #region Preparation #region Initialization #region Database configuration string databaseName = "MediaPlayerDatabase"; string userTableName = "SessionInfo"; string settingsTable = "UserSettings"; #endregion Database configuration #region Processor initialization Processor mainProcessor = new Processor(); #endregion Processor initialization #region User information UserInfo userInfo = new UserInfo(); #endregion User information #region Video processing information string videoName = string.Empty; string videoNameWithoutExtension = string.Empty; ProcessedVideo processedVideo = new ProcessedVideo(); VideoProcessingInformation videoProcessingInformation = new VideoProcessingInformation(); #endregion Video processing information #endregion Initialization #region System configuration loader SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader(); #endregion System configuration loader #region User information loader // Check for user information in database if (HelperClass.CheckUser(databaseName, userTableName, Session.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString)) { userInfo.SessionID = Session.SessionID; try { userInfo.UserID = HelperClass.ReadUserInfo(Session.SessionID).UserID; } catch (Exception err) { Response.Redirect("Error.aspx?id=22&message=" + err.Message); } } else { userInfo.SessionID = Session.SessionID; if (!HelperClass.AddUser(databaseName, userTableName, userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString)) { Response.Redirect("Error.aspx?id=23"); } try { userInfo.UserID = HelperClass.ReadUserInfo(Session.SessionID).UserID; } catch (Exception err) { Response.Redirect("Error.aspx?id=22&message=" + err.Message); } } #endregion User information loader #region Player settings loader VideoPlayerSettings settings = new VideoPlayerSettings(); if (HelperClass.CheckSettings(databaseName, userInfo, settingsTable, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString)) { settings = HelperClass.ReadPlayerSettings(Session.SessionID, database, settingsTable, connectionString); } else { if (HelperClass.CreateNewSettings(databaseName, settingsTable, userInfo, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString)) { settings = HelperClass.ReadPlayerSettings(Session.SessionID, database, settingsTable, connectionString); } } #endregion Player settings loader #region Video information preparation //processedVideo.videoName = HttpUtility.UrlEncode(HelperClass.StringEncoderDecoder(Path.GetFileNameWithoutExtension(uplVideo.FileName), StringConversionMode.Encode)); processedVideo.videoName = HttpUtility.UrlEncode(HelperClass.StringEncoderDecoder(Path.GetFileName(uplVideo.FileName), StringConversionMode.Encode)); //processedVideo.processedVideoName = Convert.ToBase64String(Encoding.UTF8.GetBytes(processedVideo.videoName)); #endregion Video information preparation #endregion Preparation #region File saving configuration //string saveLocation = string.Empty; bool requestDeleteFileAfterComplete = false; #region Temporary download location if (videoSaveLocation.EndsWith("\\")) { processedVideo.localAccessLocation = videoSaveLocation + Session.SessionID; } else { processedVideo.localAccessLocation = videoSaveLocation + "\\" + Session.SessionID; } // Path checking if (!Directory.Exists(processedVideo.localAccessLocation)) { Directory.CreateDirectory(processedVideo.localAccessLocation); } if (processedVideo.localAccessLocation.EndsWith("\\")) { //processedVideo.localAccessLocation += processedVideo.processedVideoName + Path.GetExtension(uplVideo.FileName); processedVideo.localAccessLocation += Convert.ToBase64String(Encoding.UTF8.GetBytes(processedVideo.videoName)) + Path.GetExtension(uplVideo.FileName); } else { processedVideo.localAccessLocation += "\\" + Convert.ToBase64String(Encoding.UTF8.GetBytes(processedVideo.videoName)) + Path.GetExtension(uplVideo.FileName);; } #endregion Temporary download location #endregion File saving configuration #region Received info configuration string networkAccessLocation = string.Empty; //string videoName = string.Empty; string videoDuration = string.Empty; string frameRate = string.Empty; string startFrame = string.Empty; string endFrame = string.Empty; string videoWidth = string.Empty; string videoHeight = string.Empty; #endregion Received info configuration #region Video saving uplVideo.SaveAs(processedVideo.localAccessLocation); //try //{ //} //catch (Exception err) //{ // Response.Redirect("Error.aspx?id=202&message=" + err.Message); // return; //} #endregion Video saving #region Information generation videoProcessingInformation.VideoLocations.VideoLocation = processedVideo.localAccessLocation; videoProcessingInformation.VideoLocations.videoSaveLocation = systemConfiguration.ProcessedVideoSaveLocation; videoProcessingInformation.VideoLocations.videoNetworkSaveLocation = systemConfiguration.NetworkProcessedVideoSaveLocation; videoProcessingInformation.VideoSetting.processedVideoResolution = settings.resolution; videoProcessingInformation.VideoSetting.frameRate = settings.frameRate; videoProcessingInformation.VideoSetting.audioProcessing = AudioProcessing.ProcessAudio; #endregion Information generation #region Video processing ProcessedVideo processedVideo2 = mainProcessor.ProcessVideo(videoProcessingInformation, systemConfiguration, userInfo, true); //VideoProcessingService.Service1Client client = new VideoProcessingService.Service1Client(); //string[] receivedInfo = client.ProcessVideo2(saveLocation, true, Session.SessionID, true, 854, 480, 30); #endregion Video processing #region Result combination string temporaryData = processedVideo.videoName; processedVideo = processedVideo2; processedVideo.videoName = temporaryData; #endregion Result combination #region Query string preparation string queryString = string.Empty; if (processedVideo.result == Result.Success) { queryString += "?new=true&"; queryString += "mode=upload&"; queryString += "path=" + processedVideo.networkAccessLocation + "&"; queryString += "name=" + processedVideo.videoName + "&"; queryString += "duration=" + processedVideo.videoDuration + "&"; queryString += "framerate=" + processedVideo.frameRate + "&"; queryString += "startframe=" + processedVideo.startFrame + "&"; queryString += "endframe=" + processedVideo.endFrame + "&"; queryString += "videoresolution=" + processedVideo.videoHeight + "&"; queryString += "pid=" + processedVideo.processID; if (Convert.ToInt32(lstPlayingSpeed.SelectedValue) > 0) { queryString += "&playspeed=" + lstPlayingSpeed.SelectedValue; } if (txtCustomPlayTime.Text != string.Empty) { queryString += "&timeposition=" + txtCustomPlayTime.Text; } Response.Redirect("Player.aspx" + queryString); } else { Response.Redirect("Error.aspx?id=301"); } #endregion Query string preparation // Transfer page Response.Redirect("Player.aspx" + queryString); }
protected void Page_Load(object sender, EventArgs e) { CSSLoader(); PageImageLoader(); if (Request.QueryString.Count != 0) { bool urlHasBeenSet = false; if (Request.QueryString["id"] == "1") { lbError.Text = "Couldn't play. The browser doesn't support this kind of things (for now)..."; backgroundPosition = "left"; } else if (Request.QueryString["id"] == "2") { lbError.Text = "Can't play sample video...tehepero..."; errorImgURL = TeheperoImage; backgroundPosition = "right"; urlHasBeenSet = true; } else if (Request.QueryString["id"] == "3") { lbError.Text = "Sorry, i can't use that right now..."; errorImgURL = SadImage; backgroundPosition = "right"; urlHasBeenSet = true; } else if (Request.QueryString["id"] == "10") { lbError.Text = "There's an error that happening on the service (WCFAIOProcessor)"; errorImgURL = pokerFaceImage; backgroundPosition = "left"; urlHasBeenSet = true; } else if (Request.QueryString["id"] == "20") { lbError.Text = "There's an error that happening on the service (MediaPlayer)"; errorImgURL = pokerFaceImage; backgroundPosition = "left"; urlHasBeenSet = true; } else if (Request.QueryString["id"] == "21") { lbError.Text = "Can't load your info. Something is wrong..."; if (Request.QueryString["message"] != null) { lbError.Text += "<br />" + Request.QueryString["message"]; } errorImgURL = pokerFaceImage; backgroundPosition = "left"; urlHasBeenSet = true; } else if (Request.QueryString["id"] == "22") { lbError.Text = "Can't load your settings. Something is wrong..."; if (Request.QueryString["message"] != null) { lbError.Text += "<br />" + Request.QueryString["message"]; } errorImgURL = pokerFaceImage; backgroundPosition = "left"; urlHasBeenSet = true; } else if (Request.QueryString["id"] == "23") { lbError.Text = "Can't create your info. Something is wrong..."; if (Request.QueryString["message"] != null) { lbError.Text += "<br />" + Request.QueryString["message"]; } errorImgURL = pokerFaceImage; backgroundPosition = "left"; urlHasBeenSet = true; } else if (Request.QueryString["id"] == "24") { lbError.Text = "Can't create your settings. Something is wrong..."; if (Request.QueryString["message"] != null) { lbError.Text += "<br />" + Request.QueryString["message"]; } errorImgURL = pokerFaceImage; backgroundPosition = "left"; urlHasBeenSet = true; } else if (Request.QueryString["id"] == "25") { lbError.Text = "Can't load your settings. Something is wrong..."; if (Request.QueryString["message"] != null) { lbError.Text += "<br />" + Request.QueryString["message"]; } errorImgURL = TeheperoImage; backgroundPosition = "left"; urlHasBeenSet = true; } // Player error else if (Request.QueryString["id"] == "31") { lbError.Text = "Can't process this video name...<br />tehepero..."; errorImgURL = TeheperoImage; urlHasBeenSet = true; backgroundPosition = "right"; } else if (Request.QueryString["id"] == "50") { lbError.Text = "sumanai... test mode..."; backgroundPosition = "left"; } else if (Request.QueryString["id"] == "96") { lbError.Text = "well.... you just found a not yet implemented function..."; errorImgURL = notInterestedImage; backgroundPosition = "left"; urlHasBeenSet = true; } else if (Request.QueryString["id"] == "97") { lbError.Text = "hmmm.... where did the ID go?"; errorImgURL = ConfuseImage; backgroundPosition = "left"; urlHasBeenSet = true; } else if (Request.QueryString["id"] == "98") { lbError.Text = "hmmm.... where did the PID go?"; errorImgURL = ConfuseImage; backgroundPosition = "left"; urlHasBeenSet = true; } else if (Request.QueryString["id"] == "99") { lbError.Text = "hmmm.... what did you do?"; backgroundPosition = "left"; } else if (Request.QueryString["id"] == "100") { lbError.Text = "This is an error page...."; backgroundPosition = "left"; } #region File error handling (Error code 2xx) else if (Request.QueryString["id"] == "201") { lbError.Text = "Either file name or directory or both is too long...."; errorImgURL = TeheperoImage; urlHasBeenSet = true; backgroundPosition = "right"; } else if (Request.QueryString["id"] == "202") { lbError.Text = "Can't save the video..."; if (Request.QueryString["message"] != null) { if (Request.QueryString["encoded"] == "true") { lbError.Text += "<br />" + HelperClass.StringEncoderDecoder(Request.QueryString["message"], StringConversionMode.Decode); } else { lbError.Text += "<br />" + Request.QueryString["message"]; } } errorImgURL = TeheperoImage; urlHasBeenSet = true; backgroundPosition = "right"; } #endregion File error handling (Error code 2xx) #region Processing error handling (Error code 3xx) else if (Request.QueryString["id"] == "301") { lbError.Text = "Processing video failed..."; if (Request.QueryString["message"] != null) { lbError.Text += "<br />" + Request.QueryString["message"]; } errorImgURL = TeheperoImage; urlHasBeenSet = true; backgroundPosition = "right"; } #endregion Processing error handling (Error code 3xx) #region User related problems else if (Request.QueryString["id"] == "901") { lbError.Text = "It seems like the JavaScript was disabled.<br \\>This player uses javascript for playing video so please enable it and then click "; if (Request.QueryString["message"] != null) { if (Request.QueryString["encoded"] == "true") { lbError.Text += "<a href=\"" + HelperClass.StringEncoderDecoder(Request.QueryString["message"], StringConversionMode.Decode) + "\">here</a>."; } else { lbError.Text += "<a href=\"" + Request.QueryString["message"] + "\">here</a>."; } } else { lbError.Text += "<a href=\"Index.aspx\">here</a>."; } errorImgURL = SadImage; urlHasBeenSet = true; backgroundPosition = "left"; } else if (Request.QueryString["id"] == "902") { lbError.Text = "You aren't alowed to download from that site..."; if (Request.QueryString["message"] != null) { lbError.Text += "<br >" + Request.QueryString["message"]; } errorImgURL = SmirkImage; urlHasBeenSet = true; backgroundPosition = "right"; } else if (Request.QueryString["id"] == "903") { lbError.Text = "What i need is video and not page, so..."; if (Request.QueryString["message"] != null) { lbError.Text += "<br >" + Request.QueryString["message"]; } errorImgURL = SmirkImage; urlHasBeenSet = true; backgroundPosition = "right"; } #endregion User related problems else { lbError.Text = "hmmmmmmmm...."; errorImgURL = notInterestedImage; backgroundPosition = "left"; urlHasBeenSet = true; } if (!urlHasBeenSet) { errorImgURL = pokerFaceImage; backgroundPosition = "left"; } } else { lbError.Text = "hmm? are you lost?<br />let me take you <a href=\"Index.aspx\">home</a>"; errorImgURL = ConfuseImage; backgroundPosition = "left"; } }