/// <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"); }
/// <summary> /// This example shows how to refreash a resource inside the repository. /// </summary> public static void RefreshExample() { ExampleHelper.ExampleMethodPrint("Refresh a previously loaded tag", MethodInfo.GetCurrentMethod()); _repository.RefreshResource(tag.TagHash, new Uri("http://localhost:18292"), DateTime.Now.AddHours(1)); KademliaResource rs = _repository.Get(tag.TagHash); ExampleHelper.DumpObjectProperties(rs); }
/// <summary> /// Sets the current handling resource. If the player is handling the same resource then the methods call <see cref="restartStream"/> /// otherwise it calls <see cref="setupLocalStream"/> /// </summary> /// <param name="rsc">Resource that has to be handled</param> private void setResource(KademliaResource rsc) { this.stop(); if (rsc == null) { return; } if ((this.rsc != null) && (rsc.Id.Equals(this.rsc.Id))) { restartStream(); } else { this.rsc = rsc; setupLocalStream(this.rsc, 0); } }
/// <summary> /// Default constructor /// </summary> /// <param name="rs"></param> public StreamRequestedArgs(KademliaResource rs = null) { res = rs; }