Esempio n. 1
0
        //void ChkWavestMouseWheel(object sender, MouseEventArgs e)
        //{
        //System.Diagnostics.Debug.WriteLine(chkWaves.TopIndex);
        //System.Diagnostics.Debug.WriteLine(chkWaves.);
        //	Text1MouseWheel(this.textBox1, e);
        //}

        //void Text1MouseWheel(object sender, MouseEventArgs e)
        //{
        //	int pos = textBox1.GetCharIndexFromPosition(e.Location);
        //	int line = textBox1.GetLineFromCharIndex(pos);
        //	System.Diagnostics.Debug.WriteLine(line);
        //}

        void ChkWavesSelectedIndexChanged(object sender, EventArgs e)
        {
            if (chkWaves.SelectedIndex == -1)
            {
                return;
            }
            gPlayer.StopPlayback();
            gPlayer.Close();

            String selFile = chkWaves.SelectedItem.ToString();

            String folder = cmbQisquchlar.SelectedItem.ToString();
            string yol    = Path.Combine(gAwazyol, folder, selFile);

            gInfo = new TStreamInfo();
            gPlayer.OpenFile(yol, TStreamFormat.sfAutodetect);
            gPlayer.GetStreamInfo(ref gInfo);
            label2.Text = string.Format("Uzunluqi : {0} millisecond", gInfo.Length.ms);

            int qur = chkWaves.SelectedIndex;

            textBox1.Focus();
            int qurUzun = 0;

            if (qur < textBox1.Lines.Length)
            {
                qurUzun = textBox1.GetFirstCharIndexFromLine(qur);
            }
            textBox1.SelectionLength = 0;
            textBox1.SelectionStart  = qurUzun;
            textBox1.ScrollToCaret();
        }
Esempio n. 2
0
        /// <summary>
        /// 循环播放当前配置文件中的音频文件,告警信息时候调用
        /// </summary>
        public void Play()
        {
            try
            {
                string source  = string.Empty;
                bool   enabled = false;
                VoiceXmlHelper.ReadFromXML(out source, out enabled);

                if (File.Exists(source) && enabled)
                {
                    m_currentPlayer.OpenFile(source, TStreamFormat.sfAutodetect);
                    // 循环播放
                    TStreamInfo info = new TStreamInfo();
                    m_currentPlayer.GetStreamInfo(ref info);

                    TStreamTime time = new TStreamTime();
                    time.sec = 0;
                    TStreamTime timeEnd = new TStreamTime();
                    timeEnd.sec = info.Length.sec;
                    m_currentPlayer.PlayLoop(TTimeFormat.tfSecond, ref time, TTimeFormat.tfSecond, ref timeEnd, Int32.MaxValue, true);
                    m_bIsCurrentFromWarningInfo = true;
                    //Play(source);
                }
            }
            catch (Exception exp)
            {
                System.Diagnostics.Debug.WriteLine(exp.Message);
            }
            finally
            {
            }
        }
Esempio n. 3
0
 public RadioDeskPlayer()
 {
     this.player        = new ZPlay();
     this.stream_status = new TStreamStatus();
     this.stream_info   = new TStreamInfo();
     this.player.GetPlayerVolume(ref this.volL, ref this.volR);
 }
Esempio n. 4
0
        private void Update(object sender, EventArgs e)
        {
            TimeSpan    ts, ts2;
            TStreamTime pos  = new TStreamTime();
            TStreamInfo info = new TStreamInfo();
            TStreamTime time = new TStreamTime();

            player2.GetPosition(ref pos);
            player2.GetStreamInfo(ref info);
            time = info.Length;
            ts   = TimeSpan.FromSeconds(Convert.ToDouble(pos.sec.ToString()));
            ts2  = TimeSpan.FromSeconds(Convert.ToDouble(time.sec.ToString()));

            if (Convert.ToInt32(time.sec) > 0)
            {
                if (Convert.ToInt32(time.sec) - Convert.ToInt32(pos.sec) <= 0)
                {
                    frm1.Invoke((MethodInvoker) delegate
                    {
                        frm1.Forward();
                    });
                }
                Form1.ChangeNameLabel(ts + "/" + ts2);
                Form1.ChangePositionBar(Convert.ToInt32(pos.sec) * 100 / Convert.ToInt32(time.sec));
            }
        }
Esempio n. 5
0
        private void SetupGraph(Control hWin)
        {
            //streamSource = new UdpSource("127.0.0.1", 2001);
            streamSource = new UdpSource("224.0.0.1", 2002);
            //streamSource = new Core.Sources.FileSource("test.ts");

            streamSource.PacketLength = Constants.TSPacketSize;
            streamSource.SearchMethod = TSUtils.TSPacketSearch;

            streamSource.Configure();

            if (!streamSource.Require(10))
            {
                throw new Exception("Source is not ready. No data is received.");
            }

            Log.Info("Identify the A/V streams");
            var streamInfo = new TStreamInfo(streamSource);

            streamInfo.Configure();

            streamSource.Reset();

            filterGraph = new FilterGraph() as IFilterGraph2;
            Ensure.IsNotNull(Log, filterGraph, "graph is null");
            if (filterGraph == null)
            {
                return;
            }

            var pVideoRender = (IBaseFilter) new VideoRendererDefault();
            var hr           = filterGraph.AddFilter(pVideoRender, "Video Renderer");

            DsError.ThrowExceptionForHR(hr);

            var pAudioRender = (IBaseFilter) new DSoundRender();

            hr = filterGraph.AddFilter(pAudioRender, "Audio Render");
            DsError.ThrowExceptionForHR(hr);

            Log.Info("Configure the directshow graph.");
            configurator = new GraphConfigurator
            {
                Source       = streamSource,
                StreamInfo   = streamInfo,
                Graph        = filterGraph,
                VideoRender  = pVideoRender,
                AudioRender  = pAudioRender,
                VideoGrabber = null,
                AudioGrabber = null
            };

            configurator.Configure();

            var videoWindow = pVideoRender as IVideoWindow;

            ConfigureVideoWindow(videoWindow, hWin);

            this.mediaControl = this.filterGraph as IMediaControl;
        }
Esempio n. 6
0
        private TStreamInfo GetStreamInfo(ref ZPlay player)
        {
            TStreamInfo streamInfo = new TStreamInfo();

            player?.GetStreamInfo(ref streamInfo);

            return(streamInfo);
        }
Esempio n. 7
0
        public void SetProgressBar(ref ZPlay player)
        {
            playbackProgressBarAdv.Minimum = 0;
            playbackProgressBarAdv.Value   = 0;

            TStreamInfo info = GetStreamInfo(ref player);

            playbackProgressBarAdv.Maximum = Convert.ToInt32(info.Length.ms);
        }
Esempio n. 8
0
        private void _loadImformation(string filename)
        {
            IsEmpty = true;
            if (filename == string.Empty)
            {
                return;
            }
            FilePath = filename;
            #region 获取文件信息
            #region 设置文件时间
            ZPlay tempPlay = new ZPlay();
            //如果文件不存在,则退出构造..
            bool bret = tempPlay.OpenFile(filename, TStreamFormat.sfAutodetect);
            if (!bret)
            {
                return;
            }
            TStreamInfo streamInfo = new TStreamInfo();
            tempPlay.GetStreamInfo(ref streamInfo);
            Length  = streamInfo.Length;
            Minutes = streamInfo.Length.sec / 60;
            Seconds = streamInfo.Length.sec % 60;

            tempPlay.Close();
            #endregion
            #region 获取歌曲名
            string musicName = filename.Substring(filename.LastIndexOf('\\') + 1);
            MusicName = musicName.Substring(0, musicName.LastIndexOf('.'));
            #endregion
            #region 设置文件格式
            string format = filename.Substring(filename.LastIndexOf('.'));
            switch (format.ToLower())
            {
            case ".wav":
                Format = TStreamFormat.sfWav;
                break;

            case ".mp3":
                Format = TStreamFormat.sfMp3;
                break;

            case ".flac":
                Format = TStreamFormat.sfFLAC;
                break;

            default:
                Format = TStreamFormat.sfAutodetect;
                break;
            }
            #endregion
            IsEmpty = false;

            #endregion
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Playing test.mp3. Press Q to quit.\n");
            // create ZPlay class
            ZPlay player = new ZPlay();

            // open file
            if (player.AddFile("1.mp3", TStreamFormat.sfAutodetect) == false)
            {
                Console.WriteLine(player.GetError());
                return;
            }


            // get song length
            TStreamInfo info = new TStreamInfo();

            player.GetStreamInfo(ref info);
            Console.WriteLine("Length: {0:G}:{1:G}:{2:G}:{3:G}",
                              info.Length.hms.hour,
                              info.Length.hms.minute,
                              info.Length.hms.second,
                              info.Length.hms.millisecond);

            // start playing
            player.StartPlayback();

            TStreamStatus status = new TStreamStatus();
            TStreamTime   time   = new TStreamTime();

            status.fPlay = true;

            while (status.fPlay)
            {
                player.GetPosition(ref time);
                Console.Write("Pos: {0:G}:{1:G}:{2:G}:{3:G}\r",
                              time.hms.hour,
                              time.hms.minute,
                              time.hms.second,
                              time.hms.millisecond);
                player.GetStatus(ref status);
                System.Threading.Thread.Sleep(50);
                if (Console.KeyAvailable)
                {
                    var cki = Console.ReadKey(true);
                    if (cki.Key == ConsoleKey.Q)
                    {
                        player.StopPlayback();
                    }
                }
            }
        }
Esempio n. 10
0
        public void OnRewindPictureBoxOnClick(object sender, EventArgs args)
        {
            if (Player == null)
            {
                return;
            }

            TStreamTime position = new TStreamTime();
            TStreamInfo info     = GetStreamInfo(ref Player);

            position.sec = Convert.ToUInt32(0.05 * info.Length.sec); // 5%
            Player?.Seek(TTimeFormat.tfSecond, ref position, TSeekMethod.smFromCurrentBackward);
        }
Esempio n. 11
0
		private void ProgressBar1_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			TStreamTime newpos = new TStreamTime();

            TStreamInfo Info = new TStreamInfo();
            player.GetStreamInfo(ref Info);

			newpos.sec = System.Convert.ToUInt32(e.X * Info.Length.sec / System.Convert.ToDouble(((ProgressBar)sender).Size.Width));
            player.Seek(TTimeFormat.tfSecond, ref newpos, TSeekMethod.smFromBeginning);
			


		}
Esempio n. 12
0
        public void SetPlayerPosition(int p)
        {
            TStreamStatus status = new TStreamStatus();

            if (status.fPlay)
            {
                player2.PausePlayback();
            }
            TStreamTime newpos = new TStreamTime();
            TStreamInfo info   = new TStreamInfo();
            TStreamTime time   = new TStreamTime();

            player2.GetStreamInfo(ref info);
            time = info.Length;

            newpos.sec = Convert.ToUInt32(p * time.sec / 100);
            player2.Seek(TTimeFormat.tfSecond, ref newpos, TSeekMethod.smFromBeginning);
            player2.StartPlayback();
        }
Esempio n. 13
0
		/// <summary>
		/// Show info
		/// </summary>
		/// <remarks></remarks>
        public void showinfo()
        {
           
            Label3.Text = "";
            Label4.Text = "";
            Label5.Text = "";
            Label6.Text = "";
            Label7.Text = "";
            Label8.Text = "";
            Label9.Text = "";

            TID3InfoEx info = new TID3InfoEx();
            if (player.LoadID3Ex(ref info, true))
            {
                 Label3.Text = info.Title;
                Label4.Text = info.Artist;
                Label5.Text = info.Album;
                Label6.Text = info.Year;
                Label7.Text = info.Track;
                Label8.Text = info.Encoder;
                Label9.Text = info.Comment;

            }


            descr.Text = "Format:" + System.Environment.NewLine + "Length:" + System.Environment.NewLine + "Samplerate:" + System.Environment.NewLine + "Bitrate:" + System.Environment.NewLine + "Channel:" + System.Environment.NewLine + "VBR:";

            TStreamInfo StreamInfo = new TStreamInfo();
            player.GetStreamInfo(ref StreamInfo);
            descr1.Text = StreamInfo.Description + System.Environment.NewLine + System.Convert.ToString(StreamInfo.Length.hms.hour) + " : " + System.Convert.ToString(StreamInfo.Length.hms.minute) + " : " + System.Convert.ToString(StreamInfo.Length.hms.second) + System.Environment.NewLine + System.Convert.ToString(StreamInfo.SamplingRate) + " Hz" + System.Environment.NewLine + System.Convert.ToString(StreamInfo.Bitrate) + " kbps" + System.Environment.NewLine + System.Convert.ToString(StreamInfo.ChannelNumber) + System.Environment.NewLine + System.Convert.ToString(StreamInfo.VBR);

            if (info.Picture.PicturePresent)
                pictureBox2.Image = info.Picture.Bitmap;

            ProgressBar1.Minimum = 0;
            ProgressBar1.Maximum = System.Convert.ToInt32((int)(StreamInfo.Length.sec));
            ProgressBar1.Value = 0;
            
            Timer1.Enabled = true;
            Timer2.Enabled = true;

          
        }
Esempio n. 14
0
public void GetStreamInfo(ref TStreamInfo info);
Esempio n. 15
0
        private void RegisterControlsEvents()
        {
            #region Menu Buttons

            loadAudioFileButtonAdv.Click += (sender, args) => OpenAudioFile(ref Player);

            //secondLoadAudioFileButtonAdv.Click +=
            //    (sender, args) =>
            //    {
            //        OpenAudioFile(secondAxWindowsMediaPlayer, ref _secondAudioFilePath);
            //        this.Height = 600;
            //        secondAxWindowsMediaPlayer.Location = new Point(
            //            firstAxWindowsMediaPlayer.Left,
            //            secondAxWindowsMediaPlayer.Top
            //        );
            //    };

            #endregion

            pitchTrackBarEx.MouseUp += (sender, args) =>
            {
                int pitchValue = ((TrackBarEx)sender).Value;
                pitchNumericUpDown.Value = pitchValue >= 10 ? pitchValue : 10;
            };

            pitchNumericUpDown.ValueChanged += (sender, args) =>
            {
                int pitchValue = (int)((NumericUpDown)sender).Value;
                pitchTrackBarEx.Value = pitchValue;

                Player?.SetPitch(pitchValue);
            };


            // freeeeeeeeeeeee

            frequencyTrackBarEx.MouseUp += (sender, args) =>
            {
                int pitchValue = ((TrackBarEx)sender).Value;
                frequencyNumericUpDown.Value = pitchValue >= 20 ? pitchValue : 20;
            };

            frequencyNumericUpDown.ValueChanged += (sender, args) =>
            {
                int pitchValue = (int)((NumericUpDown)sender).Value;
                frequencyTrackBarEx.Value = pitchValue;

                _metronomePlayer?.SetPitch(pitchValue);
            };

            // periooooooooooooooo

            periodicityTrackBarEx.MouseUp += (sender, args) =>
            {
                int tempoValue = ((TrackBarEx)sender).Value;
                //periodicityTextBox.Text = $@"{BpmToPeriodicity(tempoValue >= 20 ? tempoValue : 20)}";
                periodicityTextBox.Text =
                    $@"{BpmToPeriodicity(periodicityTrackBarEx.Maximum - tempoValue + periodicityTrackBarEx.Minimum)}";
            };

            periodicityTextBox.TextChanged += (sender, args) =>
            {
                decimal periodicityValue = decimal.Parse(periodicityTextBox.Text);
                periodicityTrackBarEx.Value = periodicityTrackBarEx.Maximum - PeriodicityToBPM(periodicityValue) +
                                              periodicityTrackBarEx.Minimum;

                _metronomePlayer?.SetTempo(periodicityTrackBarEx.Maximum - periodicityTrackBarEx.Value +
                                           periodicityTrackBarEx.Minimum);
            };


            //rateTrackBarEx.Click += (sender, args) =>
            //{
            //    int rateValue = ((TrackBarEx)sender).Value;
            //    Player?.SetTempo(rateValue);
            //};

            tempoTrackBarEx.MouseUp += (sender, args) =>
            {
                int tempoValue = ((TrackBarEx)sender).Value;
                tempoNumericUpDown.Value = tempoValue >= 10 ? tempoValue : 10;
            };

            tempoNumericUpDown.ValueChanged += (sender, args) =>
            {
                int tempoValue = (int)((NumericUpDown)sender).Value;
                tempoTrackBarEx.Value = tempoValue;

                Player?.SetTempo(tempoValue);
            };

            reversePlaybackToggleButton.ToggleStateChanged += (sender, args) =>
            {
                if (Player == null)
                {
                    return;
                }

                ToggleButton self = (ToggleButton)sender;

                if (self.ToggleState == ToggleButtonState.Active)
                {
                    Player?.ReverseMode(true);
                }
                else
                {
                    // ToggleButtonState.Inactive
                    Player?.ReverseMode(false);
                }
            };

            playbackProgressBarAdv.MouseDown += (sender, args) =>
            {
                //if (args.Button != MouseButtons.Left)
                //    return;

                TStreamTime newPosition = new TStreamTime();
                TStreamInfo info        = GetStreamInfo(ref Player);

                newPosition.ms = Convert.ToUInt32(
                    args.X * info.Length.ms / Convert.ToDouble(((ProgressBarAdv)sender).Size.Width));


                Player?.Seek(TTimeFormat.tfMillisecond, ref newPosition, TSeekMethod.smFromBeginning);
            };

            _volumeRadialMenuSlider.SliderValueChanged += (sender, args) =>
            {
                int volumeLevel = (int)((RadialMenuSlider)sender).SliderValue;

                if (FFTPictureBox.InvokeRequired)
                {
                    FFTPictureBox.Invoke((MethodInvoker)(() => { Player?.SetPlayerVolume(volumeLevel, volumeLevel); }));
                }
                else
                {
                    Player?.SetPlayerVolume(volumeLevel, volumeLevel);
                }
            };

            volumePictureBox.Click += (sender, args) =>
            {
                _radialMenu = new RadialMenu();

                #region Volume Radial Menu Slider

                _volumeRadialMenuSlider.MinimumValue = 0;
                _volumeRadialMenuSlider.MaximumValue = 100;
                _volumeRadialMenuSlider.SliderValue  = 50;
                _volumeRadialMenuSlider.Text         = "VOLUME";

                #endregion

                #region Radial Menu Properties Settings

                _radialMenu.WedgeCount = 1;

                _radialMenu.MenuIcon =
                    Image.FromFile($@"{Path.GetDirectoryName(Application.ExecutablePath)}\Icons\Volume-high-icon.png");

                _radialMenu.MenuVisibility       = true;
                _radialMenu.PersistPreviousState = true;
                _radialMenu.UseIndexBasedOrder   = true;

                _radialMenu.RadialMenuSliderDrillDown(_volumeRadialMenuSlider);

                #region TRASH

                //_radialMenu.Items.Add(_volumeRadialMenuSlider);
                //_radialMenu.Icon = Image
                //    .FromFile($@"{Path.GetDirectoryName(Application.ExecutablePath)}\Icons\arrow-back-icon.png");


                //ImageCollection ic = new ImageCollection();
                //ic.Add(Image.FromFile($@"{Path.GetDirectoryName(Application.ExecutablePath)}\Icons\arrow-back-icon.png"));

                //_radialMenu.ImageCollection = ic;

                //_radialMenu.DisplayStyle = DisplayStyle.TextAboveImage;
                //ImageList imageList = new ImageList();
                //string[] files = Directory.GetFiles($@"{Path.GetDirectoryName(Application.ExecutablePath)}\Icons");

                //foreach (string file in files)
                //{
                //    imageList.Images.Add("volume", Image.FromFile(file));
                //}

                //_radialMenu.ImageList = ImageListAdv.FromImageList(imageList);

                #endregion

                #endregion

                #region Show Radial Menu

                this.Controls.Add(_radialMenu);
                _radialMenu.ShowRadialMenu();
                //_radialMenu.HidePopup();
                //_radialMenu.ShowPopup(new Point());

                #endregion

                _radialMenu.PreviousLevelOpened += (radialMenuSender, opening) => _radialMenu.Dispose();

                // Emulate mouse click on 50% Volume on _volumeRadialMenuSlider
                // because there's a library bug that cannot update value
                // by .SliderValue property as it's meant to be updated.
                Point location = MousePosition;
                LeftMouseClick(location.X - 40, location.Y + 15);
            };


            FFTPictureBox.Paint += (sender, args) =>
            {
                IntPtr MyDeviceContext = default(IntPtr);
                MyDeviceContext = args.Graphics.GetHdc();
                Player?.DrawFFTGraphOnHDC(MyDeviceContext, 0, 0, FFTPictureBox.Width, FFTPictureBox.Height);
                args.Graphics.ReleaseHdc(MyDeviceContext);
            };

            playToggleButton.ToggleStateChanged += (sender, args) =>
            {
                if (Player == null)
                {
                    return;
                }

                if (playToggleButton.ToggleState == ToggleButtonState.Active)
                {
                    Player.StartPlayback();
                    //_timer.Start();
                    return;
                }
                else
                {
                    Player.StopPlayback(); // ToggleButtonState.Inactive
                    //_timer.Stop();
                }
            };

            metronomeToggleButton.ToggleStateChanged += (sender, args) =>
            {
                if (metronomeToggleButton.ToggleState == ToggleButtonState.Active)
                {
                    if (_metronomePlayer == null)
                    {
                        _metronomePlayer = new ZPlay();
                    }

                    if (_metronomePlayer.OpenFile(@"Resources\metronom.mp3", TStreamFormat.sfAutodetect) == false)
                    {
                        MessageBox.Show($@"ERROR {_metronomePlayer.GetError()}");
                        return;
                    }

                    _metronomePlayer.StartPlayback();

                    _metronomePlayer.SetMasterVolume(100, 100);
                    _metronomePlayer.SetPlayerVolume(100, 100);

                    _isMetronomeSwitch = true;
                }
                else
                {
                    _metronomePlayer.StopPlayback(); // ToggleButtonState.Inactive
                    _isMetronomeSwitch = false;
                }
            };

            playerVolumeTrackBarEx.Scroll += (sender, args) =>
            {
                int volumeLevel = ((TrackBarEx)sender).Value;
                Player?.SetPlayerVolume(volumeLevel, volumeLevel);
            };

            masterVolumeTrackBarEx.Scroll += (sender, args) =>
            {
                int volumeLevel = ((TrackBarEx)sender).Value;
                Player?.SetMasterVolume(volumeLevel, volumeLevel);
            };

            this.MouseDown += (sender, mouseEventArgs) =>
            {
                if (mouseEventArgs.Button == MouseButtons.Left)
                {
                    ReleaseCapture();
                    SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
                }
            };

            closePictureBox.Click += (sender, args) => this.Close();

            #region _secondForm Control Buttons

            ReplayPictureBox.Click      += OnReplayPictureBoxOnClick;
            PlayResumePictureBox.Click  += OnPlayResumePictureBoxOnClick;
            PausePictureBox.Click       += OnPausePictureBoxOnClick;
            StopPictureBox.Click        += OnStopPictureBoxOnClick;
            RewindPictureBox.Click      += OnRewindPictureBoxOnClick;
            FastForwardPictureBox.Click += OnFastForwardPictureBoxOnClick;

            #endregion
        }
Esempio n. 16
0
 public void GetStreamInfo(ref TStreamInfo info)
 {
     zplay_GetStreamInfoW(objptr, ref info);
 }
Esempio n. 17
0
 private extern static void zplay_GetStreamInfoW(uint objptr, ref TStreamInfo pInfo);
Esempio n. 18
0
 public void GetStreamInfo(ref TStreamInfo info);