Exemplo n.º 1
0
    public void OpenFileAndPlay(int num)
    {
        string filePath = OpenFile();

        if (filePath == "")
        {
            return;
        }

        bool   seekCheck = false;
        bool   dateCheck = true;
        string line;
        string filename           = System.IO.Path.GetFileName(filePath);
        string dirname            = System.IO.Path.GetDirectoryName(filePath);
        string filenamewithoutext = System.IO.Path.GetFileNameWithoutExtension(filePath);

        string movieInfoFile = dirname + "\\" + filenamewithoutext + ".txt";

        try
        {
            System.IO.StreamReader seekFile = new System.IO.StreamReader(movieInfoFile);
            Regex rgx = new Regex(@"creation_time", RegexOptions.IgnoreCase);

            while ((line = seekFile.ReadLine()) != null)
            {
                if (rgx.Match(line).Success)
                {
                    seekCheck = true;
                    Match matche = Regex.Match(line, @"20\d{2}(-|\/)((0[1-9])|(1[0-2]))(-|\/)((0[1-9])|([1-2][0-9])|(3[0-1]))(T|\s)(([0-1][0-9])|(2[0-3])):([0-5][0-9]):([0-5][0-9])\.([0-9][0-9][0-9])");

                    if (matche.Success)
                    {
                        string[] words = Regex.Split(matche.Value, @"T|\s");

                        for (int i = 0; i < ViewMax; i++)
                        {
                            if ((i != num) && isSet[i] && (vpManager.getMovieStartDate(i) != words[0]))
                            {
                                dateCheck = false;
                                break;
                            }
                        }

                        if (!dateCheck)
                        {
                            SetErrorDialog("ERROR:Invalid Creation Date", "The date is different from other selected files. [" + words[0] + "]");
                            break;
                        }
                        else
                        {
                            //マネージャーにセット
                            vpManager.setMovieUrl(num, "file://" + filePath);
                            vpManager.setMovieName(num, filename);
                            vpManager.setMovieStartDate(num, words[0]);
                            vpManager.setMovieStartTimes(num, words[1]);
                            vpManager.setAudioSupport(num, true);

                            MInfo[num].text = "動画" + (num + 1) + "ファイル名 : " + filename + " ( creation_time : " + vpManager.getMovieStartDate(num) + " " + vpManager.getMovieStartTimes(num) + ")";
                            isSet[num]      = true;

                            /*
                             * Debug.Log("動画" + num + ":" + vpManager.getMovieStartDate(num));
                             * Debug.Log("動画" + num + ":" + vpManager.getMovieStartTimes(num));
                             */
                            break;
                        }
                    }
                    else
                    {
                        SetErrorDialog("ERROR:Invalid Creation Date", "A date matching the format could not be found.");
                        break;
                    }
                }
            }
            seekFile.Close();

            if (!seekCheck)
            {
                SetErrorDialog("ERROR:Creation date Not Found", "Creation date line was not found.");
            }
        }
        catch (System.IO.IOException ex)
        {
            SetErrorDialog("ERROR:MovieInfo File Open Error", ex.Message);
        }

        // 音声コーデックがAC-3の場合、再生しない対応

        if (isSet[num])
        {
            CheckAudioSupport(num, movieInfoFile);
        }
    }