コード例 #1
0
        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;
            }
        }
コード例 #2
0
 protected void CSSLoader()
 {
     customCSSLocation = "\"" + HelperClass.CustomCSSLoader() + "\"";
     W3CSSLocation     = "\"" + HelperClass.W3CSSLoader() + "\"";
 }
コード例 #3
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");
        }
コード例 #4
0
ファイル: Player.aspx.cs プロジェクト: Frengkys55/MediaPlayer
        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";
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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");
            }
        }
コード例 #7
0
ファイル: Error.aspx.cs プロジェクト: Frengkys55/MediaPlayer
        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";
            }
        }