public static FunctionResult UpdateSettings(VideoPlayerSettings settings, UserInfo userInfo, string database, string table, string connectionString) { #region Preparation SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader(); FunctionResult result = new FunctionResult(); #endregion Preparation #region SQL statement string SQLCommand = string.Empty; SQLCommand = "USE " + database + ";"; SQLCommand += "UPDATE " + table + " SET "; SQLCommand += "VideoHeight=" + (int)settings.resolution + ", "; SQLCommand += "FrameRate=" + (int)settings.frameRate + ", "; SQLCommand += "BufferMode=" + (int)settings.bufferMode + ", "; SQLCommand += "PreloadFrames=" + (int)settings.preloadFrames + " WHERE "; SQLCommand += "UserID=" + userInfo.UserID + ";"; #endregion SQL statement if (!Peralatan.UbahDataDatabase(SQLCommand, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString)) { result.functionResult = Result.Fail; result.functionErrroInformation.errorMessage = Peralatan.PesanKesalahan; } else { result.functionResult = Result.Success; } return(result); }
protected void PreloadBufferGenerator(bool displayImage = false) { SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader(); frameBufferNumber = systemConfiguration.NumberOfImageContainer.ToString(); frameBufferCode = string.Empty; string imageDisplayStyle = "none"; if (displayImage) { imageDisplayStyle = "visible"; } for (int i = 0; i < systemConfiguration.NumberOfImageContainer; i++) { frameBufferCode += "<img id=\"preloadFrame" + (i + 1) + "\" alt=\"preloadFrame" + (i + 1) + "\" src=\"#\" style=\"width:100px;display:" + imageDisplayStyle + "\" />\n"; } }
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); }
private string CheckProcessStatus(string PID) { #region Preparation SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader(); string database = "MediaPlayerDatabase"; string table = "ProcessedVideoInfo"; string receivedStatus = string.Empty; #endregion Preparation try { receivedStatus = SQLClassPeralatan.Peralatan.MintaDataDatabase(database, "VideoStatus", table, "ProcessID", PID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString); if (receivedStatus == "1") { return("processing|" + GetTotalProcessedFile(PID)); } else if (receivedStatus == "2") { //Read the actual end frame return("success|" + SQLClassPeralatan.Peralatan.MintaDataDatabase(database, "VideoActualEndFrame", table, "ProcessID", PID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString)); } else if (receivedStatus == "3") { return("failed"); } else if (receivedStatus == "4") { return("canceled"); } } catch (Exception err) { return("error" + err.Message); } return(receivedStatus); }
protected void Page_Load(object sender, EventArgs e) { CSSLoader(); //savedSettings = HelperClass.ReadPlayerSettings(Session.SessionID, settingsDatabase, settingsTable, connectionString); #region Preparation #region System setting loading SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader(); #endregion System setting loading #region User info loading UserInfo userInfo = new UserInfo { SessionID = Session.SessionID }; // Try reading user information try { if (HelperClass.CheckUser("MediaPlayerDatabase", "SessionInfo", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString)) { // Load user info SQLClassPeralatan.MintaDataDatabase mintaDataDatabase = new SQLClassPeralatan.MintaDataDatabase("UserID", "SessionInfo", "SessionID", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString); userInfo.UserID = Convert.ToInt32(mintaDataDatabase.DataDiterima); } else { // Add user info if (HelperClass.AddUser("MediaPlayerDatabase", "SessionInfo", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString)) { // Read user id SQLClassPeralatan.MintaDataDatabase mintaDataDatabase = new SQLClassPeralatan.MintaDataDatabase("UserID", "SessionInfo", "SessionID", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString); if (!mintaDataDatabase.TerdapatKesalahan) { userInfo.UserID = Convert.ToInt32(mintaDataDatabase.DataDiterima); } else { Response.Redirect("Error.aspx?id=21"); } } else { Response.Redirect("Error.aspx?id=23"); } } } catch (Exception err) { Response.Redirect("Error.aspx?id=21&message=" + err.Message); } #endregion User info loading #region User player configuration loading VideoPlayerSettings userPlayerSetting = new VideoPlayerSettings(); try { if (!IsPostBack) { // Check user player configuration if (HelperClass.CheckSettings("MediaPlayerDatabase", userInfo, "UserSettings", systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString)) { userPlayerSetting = HelperClass.ReadPlayerSettings(userInfo.SessionID, "MediaPlayerDatabase", "UserSettings", systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString); } else { if (HelperClass.CreateNewSettings("MediaPlayerDatabase", "UserSettings", userInfo, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString)) { userPlayerSetting = HelperClass.ReadPlayerSettings(userInfo.SessionID, "MediaPlayerDatabase", "UserSettings", systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString); } else { Response.Redirect("Error.aspx?id=24&message=Maybe a server problem"); } } } } catch (Exception err) { Response.Redirect("Error.aspx?id=24&message=" + err.Message); } #endregion User player configuration loading #endregion Preparation if (!IsPostBack) { lstVideoResolution.SelectedValue = ((int)userPlayerSetting.resolution).ToString(); lstFrameRate.SelectedValue = ((int)userPlayerSetting.frameRate).ToString(); lstFrameBufferMode.SelectedValue = ((int)userPlayerSetting.bufferMode).ToString(); lstFramePreload.SelectedValue = ((int)userPlayerSetting.preloadFrames).ToString(); lstPlayMode.SelectedIndex = 0; } }
protected void btnSaveSettings_Click(object sender, EventArgs e) { #region Preparation VideoPlayerSettings settings = new VideoPlayerSettings(); SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader(); UserInfo userInfo = new UserInfo(); #endregion Preparation #region User info loading userInfo.SessionID = Session.SessionID; // Try reading user information if (HelperClass.CheckUser("MediaPlayerDatabase", "SessionInfo", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString)) { // Load user info SQLClassPeralatan.MintaDataDatabase mintaDataDatabase = new SQLClassPeralatan.MintaDataDatabase("UserID", "SessionInfo", "SessionID", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString); userInfo.UserID = Convert.ToInt32(mintaDataDatabase.DataDiterima); } else { Response.Redirect("Error.aspx?id=21"); } #endregion User info loading #region Resolution int selectedResolution = Convert.ToInt32(lstVideoResolution.SelectedValue); if (selectedResolution == (int)Resolution.Original) { settings.resolution = Resolution.Original; } else if (selectedResolution == (int)Resolution.SD_360p) { settings.resolution = Resolution.SD_360p; } else if (selectedResolution == (int)Resolution.SD_480p) { settings.resolution = Resolution.SD_480p; } else if (selectedResolution == (int)Resolution.HD_720p) { settings.resolution = Resolution.HD_720p; } else if (selectedResolution == (int)Resolution.HD_1080p) { settings.resolution = Resolution.HD_1080p; } else if (selectedResolution == (int)Resolution.SUHD_1440p) { settings.resolution = Resolution.SUHD_1440p; } else { settings.resolution = Resolution.Other; } #endregion Resolution #region Framerate int selectedFramerate = Convert.ToInt32(lstFrameRate.SelectedValue); if (selectedFramerate == (int)FrameRate.Default) { settings.frameRate = FrameRate.Default; } else if (selectedFramerate == (int)FrameRate._24fps) { settings.frameRate = FrameRate._24fps; } else if (selectedFramerate == (int)FrameRate._30fps) { settings.frameRate = FrameRate._30fps; } else if (selectedFramerate == (int)FrameRate._60fps) { settings.frameRate = FrameRate._60fps; } else if (selectedFramerate == (int)FrameRate._120fps) { settings.frameRate = FrameRate._120fps; } else { settings.frameRate = FrameRate.Other; } #endregion Framerate #region Buffer mode int selectedBufferMode = Convert.ToInt32(lstFrameBufferMode.SelectedValue); if (selectedBufferMode == (int)BufferMode.SingleBuffer) { settings.bufferMode = BufferMode.SingleBuffer; } else if (selectedBufferMode == (int)BufferMode.DoubleBuffer) { settings.bufferMode = BufferMode.DoubleBuffer; } else { settings.bufferMode = BufferMode.TripleBuffer; } #endregion Buffer mode #region Frame preload int selectedFramePreload = Convert.ToInt32(lstFramePreload.SelectedValue); if (selectedFramePreload == (int)PreloadFrames.EnablePreload) { settings.preloadFrames = PreloadFrames.EnablePreload; } else { settings.preloadFrames = PreloadFrames.DisablePreload; } #endregion Frame preload FunctionResult result = HelperClass.UpdateSettings(settings, userInfo, "MediaPlayerDatabase", "UserSettings", connectionString); if (result.functionResult == Result.Fail) { Response.Redirect("Error.aspx?id=25"); } Response.Redirect("Index.aspx"); }
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 btnLoadURLVideo_Click(object sender, EventArgs e) { if (mode == AccessMode.Web || mode == AccessMode.External) { #region In line commands // Used to check for commands (wihtout additional information) if (txtURLSource.Text.ToLower() == "help" || txtURLSource.Text.ToLower() == "bantuan") { Response.Redirect("Help.aspx"); } else if (txtURLSource.Text.ToLower() == "error") { Response.Redirect("Error.aspx?id=100"); } else if (txtURLSource.Text.ToLower() == "setting" || txtURLSource.Text.ToLower() == "settings") { Response.Redirect("Settings.aspx"); } else if (txtURLSource.Text.ToLower() == "player") { Response.Redirect("Player.aspx"); } else if (txtURLSource.Text.ToLower() == "sample1" || txtURLSource.Text.ToLower() == "sample2" || txtURLSource.Text.ToLower() == "sample3" || txtURLSource.Text.ToLower() == "sample4" || txtURLSource.Text.ToLower() == "sample5") { Response.Redirect("Error.aspx?id=2"); } else if (txtURLSource.Text.ToLower() == "checker") { Response.Redirect("Checker.aspx?mode=sample"); } #endregion In line commands #region Validation if (HelperClass.CheckWebsite(txtURLSource.Text)) { Uri uri = new Uri(txtURLSource.Text); Response.Redirect("Error.aspx?id=902&message=" + uri.Host); } #endregion Validation #region (Old) Main Processing //#region Old main processing //#region Service initialization //VideoProcessingService.Service1Client videoProcessor = new VideoProcessingService.Service1Client(); //#endregion Service initialization //#region Main process //string[] receivedVideoInfo = videoProcessor.ProcessVideo2(txtURLSource.Text, true, Session.SessionID, true, 0, (int)settings.resolution, (float)settings.frameRate); //#endregion Main process //#endregion Old main processing //#region Result processor //Stopwatch waitTime = new Stopwatch(); //waitTime.Start(); //if (receivedVideoInfo.Length == 0) //{ // System.Threading.Thread.Sleep(1000); // if (waitTime.ElapsedMilliseconds == 20000) // { // waitTime.Stop(); // Response.Redirect("Error.aspx"); // } //} //videoProcessor.Close(); //if (receivedVideoInfo[0].ToLower().Contains("error")) //{ // Response.Redirect("Error.aspx?id=10a"); //} //else //{ // string queryString = string.Empty; // queryString += "?new=true&"; // queryString += "path=" + receivedVideoInfo[1] + "&"; // queryString += "name=" + receivedVideoInfo[2] + "&"; // queryString += "duration=" + receivedVideoInfo[3] + "&"; // queryString += "framerate=" + receivedVideoInfo[4] + "&"; // queryString += "startframe=" + receivedVideoInfo[5] + "&"; // queryString += "endframe=" + receivedVideoInfo[6] + "&"; // queryString += "videowidth=" + receivedVideoInfo[7]; // Response.Redirect("Player.aspx" + queryString); //} //#endregion Result processor #endregion (Old) Main Processing #region New processing #region Preparation string databaseName = "MediaPlayerDatabase"; string userTableName = "SessionInfo"; string settingsTable = "UserSettings"; Processor mainProcessor = new Processor(); UserInfo userInfo = new UserInfo(); VideoProcessingInformation videoProcessingInformation = new VideoProcessingInformation(); #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(); // Check settings 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 #endregion Preparation; #region Information generation videoProcessingInformation.VideoLocations.VideoLocation = txtURLSource.Text; 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; userInfo.SessionID = Session.SessionID; #endregion Information generation #region Main process ProcessedVideo processedVideo = mainProcessor.ProcessVideo(videoProcessingInformation, systemConfiguration, userInfo); string queryString = string.Empty; if (processedVideo.result == Result.Success) { queryString += "?new=true&"; 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&message=" + processedVideo.message); } #endregion Main process #endregion New processing } else if (mode == AccessMode.Other) { Server.Transfer("Error.aspx?id=96"); } }