Esempio n. 1
0
 public FormTrackMetadata(TrackMetadata aMetadata)
 {
     InitializeComponent();
     this.Icon            = Icon.FromHandle(Properties.Resources.Track.GetHicon());
     textBoxMetadata.Text = aMetadata.ToString();
     iAlbumArtFileName    = aMetadata.AlbumArtPath;
     Refresh();
     pictureBoxAlbumArt.Select();
 }
Esempio n. 2
0
        private void CreateLocalRadio()
        {
            string        geoLocation    = "Unknown";
            List <string> links          = new List <string>();
            XmlTextReader reader         = null;
            TreeNode      nodeLocalRadio = new TreeNode();

            try {
                iProgressChanged(0, "Adding: Local Radio", Progress.State.eInProgress);
                // generate list of local locations and links based on geoId (from server IP)
                reader = new XmlTextReader(GetHttpResponse(kTuneInLocalQuery).GetResponseStream());
                reader.WhitespaceHandling = WhitespaceHandling.None;
                reader.MoveToContent();
                while (reader.Read())
                {
                    if (reader.Name == "outline" && reader.IsStartElement())
                    {
                        if (reader.GetAttribute("type") == "link")
                        {
                            links.Add(reader.GetAttribute("URL"));
                        }
                        else if (reader.GetAttribute("type") == "audio")
                        {
                            links.Add(kTuneInLocalQuery); // no links - just local stations (will generate 1 preset only)
                            break;
                        }
                    }
                    else if (reader.Name == "title" && reader.IsStartElement()) // geoId location
                    {
                        reader.Read();
                        geoLocation = reader.Value;
                    }
                    else if (reader.Name == "body" && !reader.IsStartElement()) // end tag
                    {
                        break;
                    }
                }
                // create single bookmark node for local radio
                nodeLocalRadio.Text               = "Local Radio (" + geoLocation + ") Powered by TuneIn Radio";
                nodeLocalRadio.Name               = "1";
                nodeLocalRadio.ImageIndex         = 0;
                nodeLocalRadio.SelectedImageIndex = 0;
                int i = 0;
                // generate list of stations based on location based links
                foreach (string link in links)
                {
                    iProgressChanged(i++ *100 / links.Count, "Adding: Local Radio", Progress.State.eInProgress);
                    reader = new XmlTextReader(GetHttpResponse(link).GetResponseStream());
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    reader.MoveToContent();
                    TreeNode nodeAllStations = new TreeNode();
                    while (reader.Read())
                    {
                        if (reader.Name == "outline" && reader.IsStartElement())
                        {
                            if (reader.GetAttribute("type") == "audio")
                            {
                                Upnp.musicTrack upnpTrack = new Upnp.musicTrack();
                                upnpTrack.Title = reader.GetAttribute("text");
                                Upnp.artist artist = new Upnp.artist();
                                artist.Artist = "Powered by TuneIn Radio";
                                upnpTrack.Artist.Add(artist);
                                string info = reader.GetAttribute("subtext") + " (Bitrate: " + reader.GetAttribute("bitrate") + "kbps, Reliability: " + reader.GetAttribute("reliability") + "%)";
                                upnpTrack.Album.Add(info);
                                Upnp.resource res = new Upnp.resource();
                                res.Uri = reader.GetAttribute("URL");
                                upnpTrack.Res.Add(res);
                                upnpTrack.ArtworkUri.Add(reader.GetAttribute("image"));
                                upnpTrack.AlbumArtUri.Add(reader.GetAttribute("image"));
                                TrackMetadata data = new TrackMetadata(upnpTrack);

                                TreeNode item = new TreeNode(data.Title);
                                item.Tag                = data;
                                item.ToolTipText        = data.ToString();
                                item.ImageIndex         = 2;
                                item.SelectedImageIndex = 2;
                                nodeAllStations.Nodes.Add(item);
                            }
                        }
                        else if (reader.Name == "title" && reader.IsStartElement()) // geoId location
                        {
                            reader.Read();
                            geoLocation = reader.Value;
                        }
                        else if (reader.Name == "body" && !reader.IsStartElement()) // end tag
                        {
                            break;
                        }
                    }
                    // create region preset node and add all stations
                    TreeNode subnodeRegion = new TreeNode(geoLocation);
                    subnodeRegion.Name               = "1";
                    subnodeRegion.ImageIndex         = 1;
                    subnodeRegion.SelectedImageIndex = 1;
                    foreach (TreeNode node in nodeAllStations.Nodes)
                    {
                        subnodeRegion.Nodes.Add((TreeNode)node.Clone());
                    }
                    subnodeRegion.ToolTipText = "Count: " + subnodeRegion.Nodes.Count;
                    nodeLocalRadio.Nodes.Add(subnodeRegion);
                }
                nodeLocalRadio.ToolTipText = "Count: " + nodeLocalRadio.Nodes.Count;
                iNodeCreated(nodeLocalRadio);
            }
            catch (Exception e) {
                UserLog.WriteLine("CreateLocalRadio Error: " + e);
            }
            finally {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Esempio n. 3
0
        private void LoadPlaylistTracks(string aPlaylist, TreeNode aPreset)
        {
            string pl         = Path.GetFullPath(aPlaylist);
            uint   trackCount = 0;

            if (File.Exists(pl))
            {
                iPlaylist.Load(pl);
                if (iPlaylist.Tracks.Count > 0)
                {
                    foreach (Upnp.upnpObject track in iPlaylist.Tracks)
                    {
                        if (track is Upnp.musicTrack)
                        {
                            trackCount++;
                            if (trackCount > MediaCollection.kPlaylistMaxTracks)
                            {
                                return; // only import max playlist tracks
                            }
                            // offer to update IP address (IpV4 only) for imported tracks if it is different from the user setup IP address
                            if (track.Res.Count > 0)
                            {
                                Uri imported = new Uri(track.Res[0].Uri);
                                Uri stored;
                                if (!iHelper.OptionPageSetup.UseHttpServer)
                                {
                                    stored = new Uri(iHelper.OptionPageSetup.CollectionHttpLocation);
                                }
                                else
                                {
                                    stored = new Uri(iHelper.HttpServer.Uri("FILE"));
                                }
                                if (stored.Scheme == Uri.UriSchemeHttp && stored.HostNameType == UriHostNameType.IPv4 && imported.HostNameType == UriHostNameType.IPv4)
                                {
                                    if (stored.Host != imported.Host)
                                    {
                                        if (!iReplaceIpAddressMessage)
                                        {
                                            DialogResult result = MessageBox.Show("Would you like to update the imported IP addresses to match the user configured IP address?" + Environment.NewLine + Environment.NewLine + "User configured IP address: " + stored.Host + Environment.NewLine + "Imported IP address: " + imported.Host + Environment.NewLine, "Import: IP Address Mismatch Detected", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                                            if (result == DialogResult.Yes)
                                            {
                                                iReplaceIpAddress = true;
                                            }
                                            iReplaceIpAddressMessage = true;
                                        }
                                        if (iReplaceIpAddress)
                                        {
                                            track.Res[0].Uri = track.Res[0].Uri.Replace(imported.Host, stored.Host);
                                            if (track.AlbumArtUri.Count > 0)
                                            {
                                                track.AlbumArtUri[0] = track.AlbumArtUri[0].Replace(imported.Host, stored.Host);
                                            }
                                            if (track.ArtworkUri.Count > 0)
                                            {
                                                track.ArtworkUri[0] = track.ArtworkUri[0].Replace(imported.Host, stored.Host);
                                            }
                                        }
                                    }
                                }
                            }

                            // track nodes
                            TrackMetadata data = new TrackMetadata(track);
                            TreeNode      item = new TreeNode(data.Title);
                            item.Tag                = data;
                            item.ToolTipText        = data.ToString();
                            item.ImageIndex         = 2;
                            item.SelectedImageIndex = 2;
                            aPreset.Nodes.Add(item);
                        }
                    }
                }
            }
        }