Пример #1
0
        private void btnMP3_Click(object sender, EventArgs e)
        {
            //string strFilePath = string.Empty;

            //OFDialog.InitialDirectory = Application.StartupPath;
            //OFDialog.FileName = "*.mp3";
            //OFDialog.Filter = "mp3 files(*.mp3)|*.mp3|All files(*.*)|*.*";
            //if (OFDialog.ShowDialog() == DialogResult.OK)
            //{
            //    if (_mediaPlayer == null)
            //    {
            //        _mediaPlayer = new MediaPlayer.MediaPlayerClass();
            //    }

            //    _mediaPlayer.FileName = OFDialog.FileName;
            //    _mediaPlayer.Stop();
            //    changeStaus(EnumStatus.stop);
            //    lblFileName.Text = OFDialog.FileName;

            //    //처음
            //    tbarVolume.Value = TrackbarToVolumn(-1200, 0 , _mediaPlayer.Volume);
            //    lblVolume.Text = tbarVolume.Value.ToString();

            //    //Timer
            //    _tm.Interval = 500;
            //    _tm.Tick += _tm_Tick;
            //}

            string strFilePath = string.Empty;

            OFDialog.InitialDirectory = Application.StartupPath;
            OFDialog.FileName         = "*.mp3";
            OFDialog.Filter           = "mp3 files(*.mp3)|*.mp3|All files(*.*)|*.*";
            if (OFDialog.ShowDialog() == DialogResult.OK)
            {
                if (_mediaPlayer == null)
                {
                    _mediaPlayer = new MediaPlayer.MediaPlayerClass();
                }

                _mediaPlayer.FileName = OFDialog.FileName;
                _mediaPlayer.Stop();
                changeStaus(EnumStatus.stop);
                lblFileName.Text = OFDialog.FileName;

                //처음
                tbarVolume.Value = TrackbarToVolumn(-1200, 0, _mediaPlayer.Volume);
                lblVolume.Text   = tbarVolume.Value.ToString();

                //Timer
                _tm.Interval = 500;
                _tm.Tick    += _tm_Tick;
            }
        }
Пример #2
0
        public Form1()
        {
            InitializeComponent();
            #region AssignOFD
            _ofd_music = new OpenFileDialog();
            _ofd_music.InitialDirectory = Application.StartupPath;
            _ofd_music.Title            = "악곡 가져오기";
            _ofd_music.FileName         = "*.mp3";
            _ofd_music.Filter           = "음악 파일 (*.mp3) | *.mp3";

            _ofd_Getnote = new OpenFileDialog();
            _ofd_Getnote.InitialDirectory = Application.StartupPath;
            _ofd_Getnote.Title            = "채보 불러오기";
            _ofd_Getnote.FileName         = "*.txt";
            _ofd_Getnote.Filter           = "메모장 파일 (*.txt) | *.txt";

            _ofd_Savenote = new SaveFileDialog();
            _ofd_Savenote.InitialDirectory = Application.StartupPath;
            _ofd_Savenote.Title            = "채보 저장하기";
            _ofd_Savenote.FileName         = "*.txt";
            _ofd_Savenote.Filter           = "메모장 파일 (*.txt) | *.txt";
            #endregion
            #region AssignMP3Player
            _mp3player      = new MediaPlayer.MediaPlayerClass();
            _timer          = new Timer();
            _timer.Interval = 10;
            _timer.Tick    += _timer_tick;

            _sfxPlayers = new MediaPlayer.MediaPlayerClass[4];

            for (int i = 0; i < _sfxPlayers.Length; i++)
            {
                _sfxPlayers[i]        = new MediaPlayer.MediaPlayerClass();
                _sfxPlayers[i].Volume = 0;
            }
            _sfxTimer          = new Timer();
            _sfxTimer.Interval = 10;
            _sfxTimer.Tick    += _sfxTimer_tick;
            #endregion
            _noteinfoEditor = new NoteInfoEditor(this);
        }
Пример #3
0
 public void Die_Music()
 {
     Die          = new MediaPlayer.MediaPlayerClass();
     Die.FileName = @"die.mp3";
     Die.Play();
 }
Пример #4
0
 public void Ending_Music()
 {
     Ending          = new MediaPlayer.MediaPlayerClass();
     Ending.FileName = @"end.mp3";
     Ending.Play();
 }
Пример #5
0
 public void Start_Music()
 {
     Start          = new MediaPlayer.MediaPlayerClass();
     Start.FileName = @"Undertale.mp3";
     Start.Play();
 }
Пример #6
0
        //음성합성 로직 처리
        //protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        protected override void Execute(CodeActivityContext context)
        {
            //입력 받은 매개변수 가져오기
            string text = context.GetValue(this.Text);

            if (string.IsNullOrEmpty(text))
            {
                throw new Exception("음성으로 만들어 낼  입력 텍스트가 없습니다.");
            }
            // 화자 - 언어 및 성별 구분
            string speaker  = speakers[(int)Lang, (int)Sex];
            string clientId = context.GetValue(this.ClientID);

            if (string.IsNullOrEmpty(clientId))
            {
                throw new Exception("Clova API를 호출하기 위한 Client ID 값이 없습니다.");
            }
            string clientSecret = context.GetValue(this.ClientSecret);

            if (string.IsNullOrEmpty(clientSecret))
            {
                throw new Exception("Clova API를 호출하기 위한 Client Secret 값이 없습니다.");
            }

            string         url     = "https://naveropenapi.apigw.ntruss.com/voice/v1/tts";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.Headers.Add("X-NCP-APIGW-API-KEY-ID", clientId);
            request.Headers.Add("X-NCP-APIGW-API-KEY", clientSecret);
            request.Method = "POST";
            var querystr = string.Format("speaker={0}&speed=0&text={1}", speaker, text);

            //System.Console.WriteLine("POST BODY : " + querystr);
            byte[] byteDataParams = Encoding.UTF8.GetBytes(querystr);
            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = byteDataParams.Length;
            Stream st = request.GetRequestStream();

            st.Write(byteDataParams, 0, byteDataParams.Length);
            st.Close();
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            //System.Console.WriteLine("Status : " + response.StatusCode.ToString());
            if (response.StatusCode == HttpStatusCode.OK)
            {
                var tempPath = Path.GetTempFileName();
                tempPath = tempPath.Replace(".tmp", ".mp3");
                using (Stream output = File.OpenWrite(tempPath))
                    using (Stream input = response.GetResponseStream())
                    {
                        input.CopyTo(output);
                    }
                FilePath.Set(context, tempPath);
                ErrorCode.Set(context, "OK");
                MediaPlayer.MediaPlayerClass _player;
                _player          = new MediaPlayer.MediaPlayerClass();
                _player.FileName = tempPath;
                _player.Play();

                /*
                 * Action< object > action = ( object obj) =>
                 * {
                 *  MediaPlayer.MediaPlayer player = (MediaPlayer.MediaPlayer)obj;
                 *
                 *  while( player.PlayState == MediaPlayer.MPPlayStateConstants.mpPlaying || player.PlayState == MediaPlayer.MPPlayStateConstants.mpWaiting)
                 *  {
                 *      System.Console.WriteLine(" 상태 : {0}", player.PlayState);
                 *      Thread.Sleep(1000);
                 *  }
                 * };
                 * Task t = new Task(action, mediaPlayer);
                 * t.Start();
                 * t.Wait();
                 */
            }
            else
            {
                FilePath.Set(context, "");
                ErrorCode.Set(context, "");
            }
        }
Пример #7
0
 public Player(string dir)
 {
     player          = new MediaPlayer.MediaPlayerClass();
     player.FileName = dir;
     player.Stop();
 }