Example #1
0
        //Method to convert a YouTube video to an mp4 video for web playback
        public ActionResult webPlayer(video x)
        {
            //Ensure URL is valid
            x.fileType = "mp4";
            if (x.validate() == false)
            {
                return(View("player", x));
            }

            else
            {
                //Convert video to mp4 format for watching in HTML5 video tag
                x.clear("~/App_Data/");
                x.trimRequest = false;
                x.toMp4(x.url, true);
                return(View("player", x));
            }
        }
Example #2
0
        //METHODS//

        //Method to collect a URL from a form submission
        public ActionResult collectURL(video x)
        {
            //Ensure URL is valid
            if (x.validate() == false)
            {
                return(View("soundify", x));
            }

            //Check if the user wants their video trimed, and validate their input
            if (x.startTime != null || x.endTime != null)
            {
                //Set interval time based off start and end, if the user did not provide a response
                string tempStart = "0", tempEnd = "0";

                if (x.startTime != null || x.startTime != "")
                {
                    if (x.endTime == null || x.endTime == "")
                    {
                        x.endTime = "0";
                    }
                    tempStart = x.startTime;
                }

                if (x.endTime != null || x.endTime != "")
                {
                    if (x.startTime == null || x.startTime == "")
                    {
                        x.startTime = "0";
                    }
                    tempEnd = x.endTime;
                }

                TimeSpan s, e;
                s          = x.textToTimeSpan(tempStart);
                e          = x.textToTimeSpan(tempEnd);
                x.interval = e - s;

                //x.interval = TimeSpan.FromMinutes(tempEnd - tempStart).Duration();
                if (x.interval.Equals(0))
                {
                    x.trimRequest = false;
                }
                else
                {
                    x.trimRequest = true;
                }
            }

            x.clear("~/App_Data/");

            //Otherwise, begin file conversion process
            switch (x.fileType)
            {
            //Convert to mp3 format
            case ("mp3"): x.toMp3(x.url); return(View("soundify", x));

            //Convert to mp4 format
            case ("mp4"): x.toMp4(x.url, false); return(View("soundify", x));

            //Convert to wav format
            case ("wav"): x.toWav(x.url); return(View("soundify", x));

            //Convert to flv format
            case ("flv"): x.toFlv(x.url); return(View("soundify", x));

            //Convert to mov format
            case ("mov"): x.toMov(x.url); return(View("converter", x));

            //Convert to wmv format
            case ("wmv"): x.toWmv(x.url); return(View("soundify", x));

            default: x.message = "An error has occurred, please try again"; return(View("soundify", x));
            }
        }