static void Main(string[] args) { if (args.Count() > 1) { switch (args[0]) { case "-url": using (Radio radio = new Radio(args[1])) { radio.OnCurrentSongChanged += (sender, eventArgs) => { Console.WriteLine(eventArgs.NewSong.Artist + " - " + eventArgs.NewSong.Title); }; Radio.OnMessageLogged += (sender, eventArgs) => { Console.WriteLine(eventArgs.Message); }; radio.Start(); Console.ReadLine(); GC.KeepAlive(radio); } break; } } }
public void ListenRadio(string channel) { _tv.On(); _radio.Start(); double channelFrequency = _radio.GetFrequency(channel); _radio.Tune(channelFrequency); }
private async Task PlaySource() { //stop playing any current radio await StopPlaying(); if (SelectSourceCombo.SelectedValue == null) { LogMessage("Please select a radio station to play"); return; } LogMessage("Starting playing..."); foreach (Source sourceChoice in SelectSourceCombo.Items) { sourceChoice.Selected = false; } Source source = (Source)SelectSourceCombo.SelectedValue; source.Selected = true; radio = new Radio(source.Url, source.ArtistTitleOrderInverted); radio.OnCurrentSongChanged += (s, eventArgs) => { Dispatcher.InvokeAsync(() => { string message = eventArgs.NewSong.Artist + " - " + eventArgs.NewSong.Title; LogMessage(message); Title = windowTitle + " - " + message; InfoArtistTxt.Text = eventArgs.NewSong.Artist; InfoTitleTxt.Text = eventArgs.NewSong.Title; }); }; Radio.OnMessageLogged += (s, eventArgs) => { Dispatcher.InvokeAsync(() => { LogMessage(eventArgs.Message); }); }; radio.OnPluginsLoaded += (s, eventArgs) => { Dispatcher.InvokeAsync(() => { AddPluginControls(s, eventArgs); }); }; radio.Start(); }
private static void StartRadio() { radio = new Radio("http://naxi64.streaming.rs:9160/;stream.nsv"); radio = new Radio("http://live2.okradio.net:8052/;?.mp3"); radio = new Radio("http://cdn.maksnet.tv/em/asmedia/?streamname=index&radio"); radio = new Radio("http://stream.b92.net:7999/radio-b92.mp3"); radio.OnCurrentSongChanged += (s, eventArgs) => { string message = eventArgs.NewSong.Artist + " - " + eventArgs.NewSong.Title; Console.WriteLine(message); }; radio.OnStreamUpdate += Radio_OnStreamUpdate; radio.Start(); }
/// <summary> /// Connects to the meter using ZigBee /// </summary> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 09/17/09 RCG 2.30.00 Created // 10/31/14 jrf 4.00.82 WR 542694 Added support for identifying Bridge meter with signed authorizaion. // 01/27/15 jrf 4.01.01 WR 557786 Adding ability for test to logon to meter using signed authorization. // 02/10/17 jrf 4.72.00 WR 645582 Adding try/catch around final logoff and close port. private bool LogonViaZigBee(ZigBeeRadioToken radioToken) { Radio ZigBeeRadio = CreateZigBeeRadio(radioToken); CPSEM ZigBeePSEM = null; CENTRON_AMI ZigBeeDevice = null; bool bCouldLogon = false; PSEMResponse Response; if (ZigBeeRadio != null) { ZigbeeResult ZBResult = ZigbeeResult.NOT_CONNECTED; ZigBeeRadio.OpenPort(radioToken.RadioIdentifier); if (ZigBeeRadio.IsOpen) { int counter = 0; while ((ZigbeeResult.SUCCESS != ZBResult) && (counter < 4)) { try { ZBResult = ZigBeeRadio.Start(Radio.C177_HANDHELD_PROGRAMMER_MAC, m_ulMACAddress, ZigbeeLogicalType.ENDDEVICE, m_byChannel); } catch { Thread.Sleep(5000); } counter++; } } if (!ZigBeeRadio.IsOpen || ZBResult != ZigbeeResult.SUCCESS) { // Make sure the radio is disconnected. ZigBeeRadio.ClosePort(); ZigBeeRadio = null; } else { try { // Logon to the meter ZigBeePSEM = new CPSEM(ZigBeeRadio); Response = ZigBeePSEM.Identify(); if (Response != PSEMResponse.Ok) { // Retry the identify in case the meter is in a bad state Response = ZigBeePSEM.Identify(); } if (Response == PSEMResponse.Ok) { Response = ZigBeePSEM.Negotiate(CPSEM.DEFAULT_MAX_PACKET_LEGNTH, CPSEM.DEFAULT_MAX_NUMBER_OF_PACKETS, (uint)9600); } if (Response == PSEMResponse.Ok) { Response = ZigBeePSEM.Logon("", CPSEM.DEFAULT_HH_PRO_USER_ID); } if (Response == PSEMResponse.Ok) { ZigBeeDevice = CreateDevice(ZigBeePSEM, m_AuthorizationKey); if (m_AuthorizationKey != null && m_AuthorizationKey.IsValid && ZigBeeDevice.SignedAuthorizationState != null && ZigBeeDevice.SignedAuthorizationState.Value != FeatureState.Disabled) { // We should use signed authorization to log on to the meter. ZigBeeDevice.Authenticate(m_AuthorizationKey); } else { ZigBeeDevice.Security(GetPasswords()); } if (ZigBeeDevice.HANMACAddress == m_ulMACAddress) { bCouldLogon = true; } else { bCouldLogon = false; } } } catch (Exception) { } finally { try { ZigBeeDevice.Logoff(); } catch { } } } if (ZigBeeRadio != null) { try { ZigBeeRadio.ClosePort(); } catch { } } } return(bCouldLogon); }