protected void StartRecording()
		{
			//Create or overwrite tempfile
			this.TempFile = File.Create(PathSettings.TempFilePath);

			//Getting stream
			WebRequest wReq = WebRequest.Create(this.StreamURL);
			HttpWebResponse hRes = (HttpWebResponse)wReq.GetResponse();
			System.IO.Stream RadioStream = hRes.GetResponseStream();

			//Start reading process
			this.ReadHandle = RadioStream.BeginRead(this.Buffer, 0, this.Buffer.Length, new System.AsyncCallback(this.TempSave), RadioStream);
		}
		protected void SaveSong(MetaInfo SongInfo)
		{
			System.Boolean DownloadCovers = false;
			System.String AlbumPath = "";
			System.String NewFilePath = "";

			lock (LastManager.StreamLocker)
			{
				Stream RadioStream = (Stream)this.ReadHandle.AsyncState;
				System.Int32 Count = RadioStream.EndRead(this.ReadHandle);

				if (this.SkipSave || !SongInfo.Streaming)
				{
					//Close file
					this.TempFile.Close();

					//Create or overwrite tempfile
					this.TempFile = File.Create(PathSettings.TempFilePath);

					//Start recording agian
					this.ReadHandle = RadioStream.BeginRead(this.Buffer, 0, this.Buffer.Length, new System.AsyncCallback(this.TempSave), RadioStream);

					//Change SkipSave
					this.SkipSave = false;
				}
				else
				{

					//Write last data from stream
					this.TempFile.Write(this.Buffer, 0, Count);

					//Write metadata to stream as ID3v1
					SongInfo.AppendID3(this.TempFile);

					//Write the file, and close it
					this.TempFile.Flush();
					this.TempFile.Close();
					this.TempFile.Dispose();

					//Filesystem paths
					AlbumPath = this.MusicPath + System.IO.Path.DirectorySeparatorChar + LastManager.RemoveIllegalChars(SongInfo.Artist) + System.IO.Path.DirectorySeparatorChar + LastManager.RemoveIllegalChars(SongInfo.Album) + System.IO.Path.DirectorySeparatorChar;
					NewFilePath = AlbumPath + LastManager.RemoveIllegalChars(SongInfo.Track) + ".mp3";

					//Dont overwrite file if it already exist, new rip may be bad, and we should leave it to the user to sort them manually
					if (File.Exists(NewFilePath))
					{
						File.Delete(PathSettings.TempFilePath);
					}
					else
					{
						if (!Directory.Exists(AlbumPath))
						{
							Directory.CreateDirectory(AlbumPath);
						}
						File.Move(PathSettings.TempFilePath, NewFilePath);
					}

					//Create or overwrite tempfile
					this.TempFile = File.Create(PathSettings.TempFilePath);

					//Start recording agian
					this.ReadHandle = RadioStream.BeginRead(this.Buffer, 0, this.Buffer.Length, new System.AsyncCallback(this.TempSave), RadioStream);

					//Set download covers, do this outside the lock.
					DownloadCovers = true;
				}
			}
			if (DownloadCovers)
			{
				//Download covers
				WebClient Client = new WebClient();

				if ((!File.Exists(AlbumPath + "SmallCover.jpg")) && SongInfo.AlbumcoverSmall != null)
					Client.DownloadFile(SongInfo.AlbumcoverSmall, AlbumPath + "SmallCover.jpg");

				if ((!File.Exists(AlbumPath + "MediumCover.jpg")) && SongInfo.AlbumcoverMedium != null)
					Client.DownloadFile(SongInfo.AlbumcoverMedium, AlbumPath + "MediumCover.jpg");

				if ((!File.Exists(AlbumPath + "LargeCover.jpg")) && SongInfo.AlbumcoverLarge != null)
					Client.DownloadFile(SongInfo.AlbumcoverLarge, AlbumPath + "LargeCover.jpg");
			}
		}
예제 #3
0
 /// <remarks/>
 public string EndgetStatus(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((string)(results[0]));
 }
예제 #4
0
 /// <remarks/>
 public string EndRecvSalePayFunc(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((string)(results[0]));
 }
예제 #5
0
 /// <remarks/>
 public System.Xml.XmlNode EndnfeAutorizacaoLote(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((System.Xml.XmlNode)(results[0]));
 }
 /// <remarks/>
 public psRETURN_VALUES EndDebug(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((psRETURN_VALUES)(results[0]));
 }
예제 #7
0
 /// <remarks/>
 public ServiceProviderItemType[] EndGetImportableItemTypes(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((ServiceProviderItemType[])(results[0]));
 }
예제 #8
0
 /// <remarks/>
 public string[] EndGetImportableItems(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((string[])(results[0]));
 }
예제 #9
0
 /// <remarks/>
 public ZktmobilChkStorageLocationResponse EndZktmobilChkStorageLocation(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((ZktmobilChkStorageLocationResponse)(results[0]));
 }
예제 #10
0
 /// <remarks/>
 public ZktmobilRegionStockResponse EndZktmobilRegionStock(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((ZktmobilRegionStockResponse)(results[0]));
 }
예제 #11
0
 /// <remarks/>
 public ZktmobilChckWerksResponse EndZktmobilChckWerks(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((ZktmobilChckWerksResponse)(results[0]));
 }
예제 #12
0
 /// <remarks/>
 public string EndGetG2CompanyId(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((string)(results[0]));
 }
예제 #13
0
 /// <remarks/>
 public string EndIsG2Running(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((string)(results[0]));
 }
예제 #14
0
 /// <remarks/>
 public System.Data.DataSet EndZRDGChroniken(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((System.Data.DataSet)(results[0]));
 }
예제 #15
0
 /// <remarks/>
 public System.Data.DataSet EndZRDGZeitstrahlEpocheEreignisse(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((System.Data.DataSet)(results[0]));
 }
		protected void TempSave(System.IAsyncResult Res)
		{
			if (System.Threading.Monitor.TryEnter(LastManager.StreamLocker))
			{
				try
				{
					Stream RadioStream = (Stream)Res.AsyncState;
					System.Int32 Count = RadioStream.EndRead(Res);

					if (Count > 0)
					{
						this.DeadStreamCount = 0;
						this.IsKickStarted = false;
						this.IsRestarted = false;
						this.TempFile.Write(this.Buffer, 0, Count);
						this.ReadHandle = RadioStream.BeginRead(this.Buffer, 0, this.Buffer.Length, new System.AsyncCallback(this.TempSave), RadioStream);
					}
					else
					{
						if (this.DeadStreamCount < 5)
						{
							this.DeadStreamCount += 1;
							this.ReadHandle = RadioStream.BeginRead(this.Buffer, 0, this.Buffer.Length, new System.AsyncCallback(this.TempSave), RadioStream);
						}
						else
						{
							//TODO: handle a "Not enough content left..." error
							if (this.IsKickStarted)
							{
								if (this.IsRestarted)
								{
									//Declare connection dead
									this.Status = ConnectionStatus.Created;
									//Give it a handshake, just to try
									this.Handshake(this.UserID, this.Password);
									this.IsRestarted = false;
									this.IsKickStarted = false;
								}
								else
								{
									RadioStream.Close();
									this.TempFile.Close();
									this.StartRecording();
									this.IsKickStarted = false;
									this.IsRestarted = true;
								}
							}
							else
							{
								this.IsKickStarted = true;
								this.DeadStreamCount = 0;
								this.SkipSong();
								this.ReadHandle = RadioStream.BeginRead(this.Buffer, 0, this.Buffer.Length, new System.AsyncCallback(this.TempSave), RadioStream);
							}
						}
					}
				}
				finally
				{
					System.Threading.Monitor.Exit(LastManager.StreamLocker);
				}
			}
		}
예제 #17
0
 /// <remarks/>
 public System.Byte[] EndReadFile(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((System.Byte[])(results[0]));
 }
예제 #18
0
 /// <remarks/>
 public ZktmobilGetOpnPoResponse EndZktmobilGetOpnPo(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((ZktmobilGetOpnPoResponse)(results[0]));
 }
예제 #19
0
 /// <remarks/>
 public int EndImportItems(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((int)(results[0]));
 }
예제 #20
0
 /// <remarks/>
 public ZktmobilCheckProductResponse EndZktmobilCheckProduct(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((ZktmobilCheckProductResponse)(results[0]));
 }
 /// <remarks/>
 public psPortfoliosVersionInfo[] EndGetAllVersions(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((psPortfoliosVersionInfo[])(results[0]));
 }
예제 #22
0
 /// <remarks/>
 public ZktmobilGetAdressContentResponse EndZktmobilGetAdressContent(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((ZktmobilGetAdressContentResponse)(results[0]));
 }
예제 #23
0
 /// <remarks/>
 public void EndLogout(
     System.IAsyncResult asyncResult
     )
 {
     this.EndInvoke(asyncResult);
 }
예제 #24
0
 /// <remarks/>
 public ZktmobilMalzemeAdrsMiktarResponse EndZktmobilMalzemeAdrsMiktar(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((ZktmobilMalzemeAdrsMiktarResponse)(results[0]));
 }
예제 #25
0
 /// <remarks/>
 public string[] EndgetCharFonts(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((string[])(results[0]));
 }
예제 #26
0
 public PW.ServiceCenter.ServiceUser.user[] Endquery(System.IAsyncResult result)
 {
     return(base.Channel.Endquery(result));
 }
 /// <remarks/>
 public Login[] EndGetLogins(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((Login[])(results[0]));
 }
예제 #28
0
 public PW.ServiceCenter.ServiceUser.PageInfoOfuserCLUigIiY EndqueryPage(System.IAsyncResult result)
 {
     return(base.Channel.EndqueryPage(result));
 }
예제 #29
0
 /// <remarks/>
 public wsResultType[] EndgetResultTypes(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((wsResultType[])(results[0]));
 }
예제 #30
0
 public int EndupdateById(System.IAsyncResult result)
 {
     return(base.Channel.EndupdateById(result));
 }
예제 #31
0
 public PW.ServiceCenter.ServiceUser.user EndgetById(System.IAsyncResult result)
 {
     return(base.Channel.EndgetById(result));
 }
예제 #32
0
 /// <remarks/>
 public System.Xml.XmlNode EndmdfeConsultaMDF(System.IAsyncResult asyncResult)
 {
     object[] results = this.EndInvoke(asyncResult);
     return((System.Xml.XmlNode)(results[0]));
 }
예제 #33
0
			public TestDelegate() 
			{ 
				ar = new CallBackFunction 
					(DoSomething).BeginInvoke 
					(null,null); 
			} 
예제 #34
0
 /// <remarks/>
 public void EndUpdateNavigation(System.IAsyncResult asyncResult)
 {
     this.EndInvoke(asyncResult);
 }