Exemple #1
0
        /// <summary>
        /// 判断当前是否正在播放音频文件
        /// </summary>
        /// <returns></returns>
        public bool IsCurrentPlay()
        {
            TStreamStatus status = new TStreamStatus();

            m_currentPlayer.GetStatus(ref status);
            return(status.fPlay);
        }
Exemple #2
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);
 }
        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();
                    }
                }
            }
        }
Exemple #4
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();
        }
Exemple #5
0
        /// <summary>
        /// Gets called on average every 500ms. This is a console application, so no SynchronizationContext
        /// available. This means this function is called on theNetConnection thread
        /// watch out for that.!
        /// </summary>
        private void NC_OnTick(object sender)
        {
            // feed zplay with data received from netstream
            // Minimum buffer voordat we starten met afspelen
            TStreamStatus status = new TStreamStatus();

            zPlay.GetStatus(ref status);

            // Not playing and buffer has enough data to examine mp3 to start playing
            if (!status.fPlay && zPlayBuffer.UsedBytes >= 8192)
            {
                byte[] tmpBuffer = new byte[8192];
                zPlayBuffer.Read(tmpBuffer, 8192);

                if (!(zPlay.OpenStream(true, true, ref tmpBuffer, 8192, TStreamFormat.sfMp3)))
                {
                    // Got an error with libzplay
                    Console.WriteLine(zPlay.GetError());
                    return;
                }
                // Start playing audio
                zPlay.StartPlayback();
            }
            else if (status.fPlay && zPlayBuffer.UsedBytes > 0)
            {
                int    bufRead   = Convert.ToInt32(zPlayBuffer.UsedBytes);
                byte[] tmpBuffer = new byte[bufRead];
                zPlayBuffer.Read(tmpBuffer, bufRead);

                // Push data into libzplay so it can continue playing audio
                if (!zPlay.PushDataToStream(ref tmpBuffer, Convert.ToUInt32(bufRead)))
                {
                    // Got an error with libzplay
                    Console.WriteLine(zPlay.GetError());
                    return;
                }
            }
        }
Exemple #6
0
        void Button2Click(object sender, EventArgs e)
        {
            gStop = !gStop;
            if (gStop)
            {
                button2.Text = "Hemmini Qoy";
                gPlayer.StopPlayback();
                return;
            }
            else
            {
                button2.Text = "Toxta";
            }

            TStreamStatus sts    = new TStreamStatus();
            int           curSel = chkWaves.SelectedIndex;

            for (int i = curSel; i < chkWaves.Items.Count; i++)
            {
                chkWaves.SelectedIndex = i;
                ChkWavesSelectedIndexChanged(null, null);
                textBox1.Focus();
                gPlayer.StartPlayback();
                gPlayer.GetStatus(ref sts);
                while (sts.fPlay && gStop == false)
                {
                    gPlayer.GetStatus(ref sts);
                    Sleep(10);
                }
                if (gStop == true)
                {
                    break;
                }
                Sleep(2000);
            }
        }
Exemple #7
0
		private void Timer1_Tick(object sender, System.EventArgs e)
		{
            TStreamTime pos = new TStreamTime();

            player.GetPosition(ref pos);

            if(ProgressBar1.Maximum > pos.sec)
			    ProgressBar1.Value = System.Convert.ToInt32((int)(pos.sec));


		
            position.Text = System.String.Format("{0,2:G}", pos.hms.hour) + " : " + System.String.Format("{0,2:G}", pos.hms.minute) + " : " + System.String.Format("{0,2:G}", pos.hms.second) + " : " + System.String.Format("{0,3:G}", pos.hms.millisecond);
          

			TStreamStatus Status = new TStreamStatus();
			player.GetStatus(ref Status);

			statuslabel1.Text = "Eq:" + System.Environment.NewLine + "Fade:" + System.Environment.NewLine + "Echo:" + System.Environment.NewLine + "Bitrate:" + System.Environment.NewLine + "Vocal cut:" + System.Environment.NewLine + "Side cut:";

			statuslabel2.Text = "Loop:" + System.Environment.NewLine + "Reverse:" + System.Environment.NewLine + "Play:" + System.Environment.NewLine + "Pause:" + System.Environment.NewLine + "Channel mix:" + System.Environment.NewLine + "Load:";

			statusvalue1.Text = System.Convert.ToString(Status.fEqualizer) + System.Environment.NewLine + System.Convert.ToString(Status.fSlideVolume) + System.Environment.NewLine + System.Convert.ToString(Status.fEcho) + System.Environment.NewLine + System.Convert.ToString(player.GetBitrate(false)) + System.Environment.NewLine + System.Convert.ToString(Status.fVocalCut) + System.Environment.NewLine + System.Convert.ToString(Status.fSideCut);

			TStreamLoadInfo load = new TStreamLoadInfo();
			player.GetDynamicStreamLoad(ref load);
			statusvalue2.Text = System.Convert.ToString(Status.nLoop) + System.Environment.NewLine + System.Convert.ToString(Status.fReverse) + System.Environment.NewLine + System.Convert.ToString(Status.fPlay) + System.Environment.NewLine + System.Convert.ToString(Status.fPause) + System.Environment.NewLine + System.Convert.ToString(Status.fChannelMix) + System.Environment.NewLine + System.Convert.ToString(load.NumberOfBuffers);
            
			if (Status.fSlideVolume != false)
			{
                BlockLeft = true;
                BlockRight = true;

                int Left = 0;
                int Right = 0;
                player.GetPlayerVolume(ref Left, ref Right);

				leftplayervolume.Value = 100 - Left;
				rightplayervolume.Value = 100 - Right;
                
			}
            
			if (FadeFinished)
			{
                int Left = 0;
                int Right = 0;
                player.GetPlayerVolume(ref Left, ref Right);

                leftplayervolume.Value = 100 - Left;
                rightplayervolume.Value = 100 - Right;
				FadeFinished = false;
			}
            

            if(NextSong)
            {
                showinfo();
                NextSong = false;
            }
       


		}
Exemple #8
0
 private extern static void zplay_GetStatus(uint objptr, ref TStreamStatus pStatus);
Exemple #9
0
 public void GetStatus(ref TStreamStatus status)
 {
     zplay_GetStatus(objptr, ref status);
 }
 public RadioDeskClipPlayer()
 {
     this.player        = new ZPlay();
     this.stream_status = new TStreamStatus();
 }
Exemple #11
0
public void GetStatus(ref TStreamStatus status);
 public void GetStatus(ref TStreamStatus status);
Exemple #13
0
        public void Run()
        {
            zPlayBuffer   = new CircularBlockBuffer();
            zPlay         = new ZPlay();
            netConnection = new NetConnection();
            netConnection.OnDisconnect += new NC_OnDisconnect(OnDisconnect);
            netConnection.OnTick       += new NC_OnTick(NC_OnTick);
            try
            {
                int result = -1;
                // This is to connect to default vod app
                netConnection.Connect(new ServerLink("rtmp://localhost:1935/vod"), new NC_ResultCallBackConnect((sender, success) =>
                {
                    // Runs in RTMP thread (NOT MainThread!!!)
                    Console.WriteLine("NetConnection.Connect => Success=" + success.ToString());

                    if (success)
                    {
                        result = 1;
                    }
                    else
                    {
                        result = 0;
                    }
                }));

                // Wait until we are connected (needed because we run async)
                while (result == -1)
                {
                    Thread.Sleep(100);
                } //while


                // Succes for connecting to rtmp server
                if (result == 1)
                {
                    NetStream netStream = new NetStream(netConnection);
                    netStream.OnStatus      += new NS_OnStatus(NS_OnStatus);
                    netStream.OnAudioPacket += new NC_OnMediaPacket(NC_OnMediaPacket);

                    netStream.WaitForValidStream_ID(4000); // wait max 4 seconds for the netstream to become valid (for real test connect to event)

                    // This is to get and MP3 stream
                    netStream.Play("Comfort_Fit_-_03_-_Sorry.mp3", 0, -1, true);
                }


                Console.WriteLine("Press enter to stop.");
                Console.ReadLine();
            }
            finally
            {
                // Cleanup
                if (netConnection != null)
                {
                    netConnection.Close();
                    netConnection = null;
                }
                if (zPlay != null)
                {
                    TStreamStatus status = new TStreamStatus();
                    zPlay.GetStatus(ref status);
                    if (status.fPlay)
                    {
                        zPlay.StopPlayback();
                    }

                    zPlay.Close();
                    zPlay = null;
                }
                if (zPlayBuffer != null)
                {
                    zPlayBuffer = null;
                }
            }
        }