Пример #1
0
		}, "Central European Standard Time") {} // Viduseiropas laika josla.

		public override Channel GetChannel(uint number) {
			if (number == 0 || number > 6) throw new ChannelNotFoundException(number);
			if (brand == null)
				brand=new Brand(Colors.White, Colors.White, Colors.White, 0x088484.ToColor(), 0x088484.ToColor(), 0x0CB6B5.ToColor(), 0x0CB6B5.ToColor());
			// Astkaņošanas adrese no http://www.euronewsradio.com/ (.ru, .fr, utt.) oriģinālā ir .aac, bet strādā arī .mp3.
			return new UrlChannel(string.Format("http://euronews-0{0}.ice.infomaniak.ch/euronews-0{0}.mp3", number),
				GetResourceImage("Euronews.png"), timezone, true, brand);
		}
Пример #2
0
		}, "E. Europe Standard Time") {} // Ukrainas laika josla.

		public override Channel GetChannel(uint number) {
			if (number == 0 || number > 4) throw new ChannelNotFoundException(number);
			if (brand == null)
				brand=new Brand(0x003F8F.ToColor(), 0x005CAA.ToColor(), 0x003F8F.ToColor(), 0x005CAA.ToColor(),
					0xD6F5FF.ToColor(), 0xA8EAFF.ToColor(), 0xA8EAFF.ToColor(), 0xFCEEAB.ToColor());
			return new IcyChannel(string.Concat("http://nrcu.gov.ua:8000/ur", number, "-mp3"),
				GetResourceImage(number == 2 ? "Promin.png":"UkrRadio.png"),
				timezone, true, brand, number == 2 ? new ProminMenu():null);
		}
Пример #3
0
		public UrlChannel(string url, BitmapSource logo, TimeZoneInfo timezone, bool hasGuide, Brand brand, Menu<Channel> menu=null)
			: base(logo, timezone, hasGuide, brand, menu) {
			player=new MediaPlayer();
			this.url=new Uri(url);
			player.BufferingStarted+=player_BufferingStarted;
			player.BufferingEnded+=player_BufferingEnded;
			player.MediaFailed+=player_MediaFailed;
			//player.MediaEnded+=player_MediaEnded;
		}
Пример #4
0
		}, "E. Europe Standard Time") {} // Latvijas laika josla.

		public override Channel GetChannel(uint number) {
			if (brand == null) brand=new Brand(Colors.Black, 0xAC040B.ToColor(), Colors.White, Colors.Black, new SolidColorBrush(0xAB040B.ToColor()), Brushes.White);
			string name; // Nosaukums ir reģistrjūtīgs.
			switch (number) {
				case 1: name="995"; break;
				case 2: name="MixFM"; break;
				case 3: name="baltkom"; break;
				case 4: name="GoldFM"; break;
				default: throw new ChannelNotFoundException(number);
			}
			return new UrlChannel("http://91.90.255.111:80/"+name, GetResourceImage(name+".png"), timezone, false, brand, number == 2 || number == 3 ? new ChannelMenu():null);
		}
Пример #5
0
		public override Channel GetChannel(uint number) {
			if (brand == null)
				brand=new Brand(Colors.White, 0XF5BC48.ToColor(), Colors.White, 0x0168B5.ToColor(),
					new LinearGradientBrush(0xE74CB5.ToColor(), 0xBE358E.ToColor(), 90), new LinearGradientBrush(0x0168B5.ToColor(), 0x015797.ToColor(), 90));
			switch (number) {
				case 1: return new IcyChannel("http://retro128.streamr.ru/", GetResourceImage("Retro.png"), // Pastāv vēl "Hi-Fi" 256 bitu plūsma un šaurākas plūsmas.
					TimeZoneInfo.FindSystemTimeZoneById("Russian Standard Time"), true, brand);
				case 2:
				case 3:
				case 4:
				case 5:
					return new IcyChannel(number == 2 ? "http://cast.retro.ua/retro":(number == 3 ? "http://cast2.retro.ua/retro_romantic":(number == 4 ? "http://cast2.retro.ua/retro_russian":"http://cast2.retro.ua/retro_dance")),
						GetResourceImage("Retro.png"), TimeZoneInfo.FindSystemTimeZoneById("E. Europe Standard Time"), true, brand);
				case 6: return new ForcedIcyChannel("http://lifemedia.cloud.makonix.com:8000/", GetResourceImage("Retro.png"), TimeZoneInfo.FindSystemTimeZoneById("E. Europe Standard Time"), false, brand);
				default: throw new ChannelNotFoundException(number);
			}
		}
Пример #6
0
		public override Channel GetChannel(uint id) {
			if (brand == null)
				brand=new Brand(Colors.White, 0x606060.ToColor(), Colors.White, 0x6C54D5.ToColor(),
					0x6C54D5.ToColor(), 0x483998.ToColor(), Colors.Black, Colors.Black);
			if (id == 0 && Channels.ContainsKey(0)) // Nav izvēlēts neviens kanāls.
				return new EmptyChannel("101.ru", GetResourceImage("101ru.png"), brand, new ChannelMenu());
			var channel=channels.FirstOrDefault(c => c.Id == id);
			if (channel == null) throw new ChannelNotFoundException(id);

			BitmapSource logo=GetCachedImage(id.ToString());
			if (logo == null)
				using (var client=new ProperWebClient()) {
					using (Stream imageStreamSource=client.OpenRead(channel.LogoUrl))
					using (var srcBitmap=new D.Bitmap(imageStreamSource)) // Drawing.Bitmap, lai WPF neizstieptu attēlu, pārrēķinot DPI.
					// Ielādē caurspīdīguma masku, kura izveidota, apgriežot krāsas oriģinālajā cover_000_round.png.
					using (D.Bitmap bitmap=(D.Bitmap)D.Bitmap.FromStream(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(this.GetType(), "LogoMask.png"))) {
						var rect=new D.Rectangle(new D.Point(0, 0), bitmap.Size);
						var inBits=srcBitmap.LockBits(rect, DI.ImageLockMode.ReadOnly, DI.PixelFormat.Format32bppArgb);
						var outBits=bitmap.LockBits(rect, DI.ImageLockMode.WriteOnly, DI.PixelFormat.Format32bppArgb);
						unsafe { // Nedrošais kods ar norādēm labākai veiktspējai.
							// Izkrāso caurspīdīguma masku ar logotipa krāsām.
							for (int y = 0; y < bitmap.Height; y++) {
								byte* inRow=(byte*)inBits.Scan0+inBits.Stride*y;
								byte* outRow=(byte*)outBits.Scan0+outBits.Stride*y;
								for (int x = 0; x < bitmap.Width; x++) {
									outRow[4 * x]    =inRow[4 * x];     // zilā
									outRow[4 * x + 1]=inRow[4 * x + 1]; // zaļā
									outRow[4 * x + 2]=inRow[4 * x + 2]; // sarkanā
								}
							}
						}
						srcBitmap.UnlockBits(inBits); bitmap.UnlockBits(outBits);
						logo=System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(),
							IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
					}
					CacheImage(id.ToString(), logo);

					// {"status":0,"result":{"token":"09270779","playlist":[{"url":"http:\/\/ru2.101.ru:8000\/c14_24?tok=09270779"}]},"errorCode":0,"errorMsg":""}
					string urlPrefix="http://"+Settings.Default.Region; // Iznests mainīgajā, lai nepārrēķinātu katru reizi, meklējot atskaņošanas adresi.
					channel.StreamUrl=client.GetJsonSync("http://101.ru/api/getstationstream.php?station_id="+id).
						Element("result").Element("playlist").Elements("item").First(i => i.Element("url").Value.StartsWith(urlPrefix)).Element("url").Value;
				}

			return new IcyChannel(channel.StreamUrl, logo, timezone, true, brand, new ChannelMenu())
				{ UserAgent="Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:18.0) Gecko/20130119 Firefox/18.0" }; // Lai 101.ru neteiktu, ka jāklausās pārlūkā.
		}
Пример #7
0
		}, "E. Europe Standard Time") {} // Latvijas laika josla.

		public override Channel GetChannel(uint number) {
			if (number == 5)
				return new ForcedIcyChannel("http://nabamp0.latvijasradio.lv:8016/", GetResourceImage("Naba.png"), timezone, true,
					new Brand(0x58595B.ToColor(), 0xEE3A43.ToColor(), Colors.White, Colors.Black, Colors.Black, Colors.White, Colors.White), new NabaChannelMenu());
			Int32 baseHex, guideHex; string prefix, port;
			switch (number) {
				case 1: baseHex=0xF20000; guideHex=0xFFD1D1; prefix="1mp1"; port="12"; break;
				case 2: baseHex=0xFFBF00; guideHex=0xFFF1CC; prefix="2mp1"; port="02"; break;
				case 3: baseHex=0xBF7200; guideHex=0xF2D5AE; prefix="3mp0"; port="04"; break;
				case 4: baseHex=0x408CFF; guideHex=0xCCE0FF; prefix="4mp1"; port="20"; break;
				default: throw new ChannelNotFoundException(number);
			}
			var brand=new Brand(Colors.Black, baseHex.ToColor(), Colors.White, baseHex.ToColor(), baseHex.ToColor(), guideHex.ToColor(), guideHex.ToColor());
			if (number == 4) // LR4 nezināmu iemeslu pēc HTTP plūsmas tikai AAC formātā, tāpēc lieto MMS.
				return new UrlChannel("mms://lr4w.latvijasradio.lv/pplr4",
					GetResourceImage("LR4.png"), timezone, true,
					brand, new LrChannelMenu());
			// Kopš LR1 ieciklēšanās atteicāmies no MMS. Meta datu plūsmā nav.
			return new ForcedIcyChannel(string.Format("http://lr{0}.latvijasradio.lv:80{1}/", prefix, port),
				GetResourceImage(string.Format("LR{0}.png", number)),
				timezone, true, brand,
				number == 1 /*|| number == 4*/ ? new LrChannelMenu():null);
		}
Пример #8
0
		protected Channel(BitmapSource logo, TimeZoneInfo timezone, bool hasGuide, Brand brand, Menu<Channel> menu) {
			if (logo == null)
				this.logo=(BitmapImage)Application.Current.Resources["RadioLogo"];
			else this.logo=logo;
			this.Timezone=timezone; this.HasGuide=hasGuide;
			if (brand == null) {
				if (defaultBrand == null)
					defaultBrand=new Brand(0x33537C.ToColor(), 0x568CC6.ToColor(), 0xD2CFBC.ToColor(), 0x33537C.ToColor(),
						new LinearGradientBrush(
							new GradientStopCollection {
								new GradientStop(0x191919.ToColor(), 0),
								new GradientStop(0x4F4F4F.ToColor(), 0.48),
								new GradientStop(0x191919.ToColor(), 0.48)
							}, new Point(0,0), new Point(205, 30)) { MappingMode=BrushMappingMode.Absolute },
						new LinearGradientBrush(
							new GradientStopCollection {
								new GradientStop(0xE2F1F7.ToColor(), 0),
								new GradientStop(0xB8CBD8.ToColor(), 0.85),
								new GradientStop(0xD8E7F2.ToColor(), 1)
							}, 90.0),
						new LinearGradientBrush(
							new GradientStopCollection {
								new GradientStop(0xE7F2F8.ToColor(), 0),
								new GradientStop(0xD7E3ED.ToColor(), 0.85),
								new GradientStop(0xDFECF4.ToColor(), 1)
							}, 90.0));
				this.brand=defaultBrand;
			} else this.brand=brand;
			this.Menu=menu;
			if (menu != null) menu.Source=this;
		}
Пример #9
0
		public EmptyChannel(string caption, BitmapSource logo, Brand brand, Menu<Channel> menu) : base(logo, null, false, brand, menu) {
			Caption=caption;
			openJumplist=false;
		}
Пример #10
0
		public ForcedIcyChannel(string url, BitmapSource logo, TimeZoneInfo timezone, bool hasGuide, Brand brand, Menu<Channel> menu=null)
			: base(url, logo, timezone, hasGuide, brand, menu) {
			UserAgent="Winamp/2.x"; // Ja UserAgent būs līdzīgs pārlūkprogrammai, tad ShoutCast serveris atgriezīs HTML nevis MP3.
			EnableUnsafeHeaderParsing();
		}