WaitForMore() public method

Sets the waiting state for the stream and sets the position waited.
public WaitForMore ( int how_many = 15000 ) : void
how_many int Number of bytes needed. Default is 15000
return void
Ejemplo n.º 1
0
        /// <summary>
        /// This callback is called everytime a sample is player. This method handles current time and current position updates,
        /// the stop of the playing at the end of the track and the buffering state.
        /// </summary>
        /// <param name="sender">Unused params</param>
        /// <param name="e">Unused params</param>
        private void wc_Sample(object sender, SampleEventArgs e)
        {
            if (wc == null)
            {
                return;
            }
            if (wc.CurrentTime.TotalSeconds != currentTime)
            {
                currentTime = wc.CurrentTime.TotalSeconds;
                NotifyPropertyChanged("CurrentTime");
                NotifyPropertyChanged("BufferPortion");
                pos = lmem.Position;
                NotifyPropertyChanged("Position");
            }
            if (lmem.Position == lmem.Length)
            {
                this.stop(); return;
            }
            long myBufferSize = 20480;

            if ((!BufferingState) && (localstream.Position != rsc.Tag.FileSize) && ((localstream.Position - lmem.Position) < myBufferSize))
            {
                Console.WriteLine("Paused ... waiting!");
                BufferingState = true;
                this.pause();
                localstream.WaitForMore();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets all configuration to enable the playback and the downloading of the track from the network.
        /// After setting all configuration, the player will wait for the buffer to be full enough to start playing.
        /// </summary>
        /// <param name="rsc">Resource to Handle</param>
        /// <param name="spos">Starting position</param>
        private void setupLocalStream(KademliaResource rsc, long spos)
        {
            if (localstream != null)
            {
                localstream.Close();
            }
            EnableFlowRestart = true;
            Dictionary <string, float> tD = new Dictionary <string, float>();

            foreach (DhtElement de in rsc.Urls)
            {
                Console.WriteLine(de.Url);
                tD[de.Url.ToString()] = 0;
            }
            this.streambuff = new byte[rsc.Tag.FileSize];
            localstream     = new ObservableStream(streambuff);
            startPosition   = spos;
            localstream.Seek(spos, SeekOrigin.Begin);
            pos = spos;
            NotifyPropertyChanged("Position");
            NotifyPropertyChanged("BufferPortion");
            localstream.WaitedPositionReached += resumePlay;
            localstream.PositionChanged       += (sender, args) => { NotifyPropertyChanged("BufferPortion"); };
            peer.GetFlow(rsc.Tag.FileHash, (int)startPosition, (int)rsc.Tag.FileSize, tD, localstream);
            BufferingState = true;
            NotifyPropertyChanged("PlayingState");
            startPhaseBuffering = true;
            localstream.WaitForMore(60000);
            NotifyPropertyChanged("ResourceTag");
            NotifyPropertyChanged("Length");
            NotifyPropertyChanged("BigBufferSize");
            NotifyPropertyChanged("HasResource");
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets all configuration to enable the playback and the downloading of the track from the network.
 /// After setting all configuration, the player will wait for the buffer to be full enough to start playing.
 /// </summary>
 /// <param name="rsc">Resource to Handle</param>
 /// <param name="spos">Starting position</param>
 private void setupLocalStream(KademliaResource rsc,long spos)
 {
     if (localstream != null)
     {
         localstream.Close();
     }
     EnableFlowRestart = true;
     Dictionary<string, float> tD = new Dictionary<string, float>();
     foreach (DhtElement de in rsc.Urls)
     {
         Console.WriteLine(de.Url);
         tD[de.Url.ToString()] = 0;
     }
     this.streambuff = new byte[rsc.Tag.FileSize];
     localstream = new ObservableStream(streambuff);
     startPosition = spos;
     localstream.Seek(spos, SeekOrigin.Begin);
     pos = spos;
     NotifyPropertyChanged("Position");
     NotifyPropertyChanged("BufferPortion");
     localstream.WaitedPositionReached += resumePlay;
     localstream.PositionChanged += (sender, args) => { NotifyPropertyChanged("BufferPortion"); };
     peer.GetFlow(rsc.Tag.FileHash,(int)startPosition, (int)rsc.Tag.FileSize, tD, localstream);
     BufferingState = true;
     NotifyPropertyChanged("PlayingState");
     startPhaseBuffering = true;
     localstream.WaitForMore(60000);
     NotifyPropertyChanged("ResourceTag");
     NotifyPropertyChanged("Length");
     NotifyPropertyChanged("BigBufferSize");
     NotifyPropertyChanged("HasResource");
 }