- 01-06-2013, 06:12 AM #1
Hey guys, as part of my app, I am wanting to pull in information about things like the on-air DJ, the currently playing song, etc. Now, my station manager has provided a plain text HTML page for displaying the data (eg the artist bio can be found here http://1radio.org/listen/bio.html). My question is, how can I import that into the phone with it sticking to the themes. So it appears on the Listen Panorama control that I have set up within my app, which follows the phone's theming (I use a dark theme with magenta accent so white or magenta text with font Segoe WP on a black background for me, however your themes may cause different results). I also want it to re-poll the data every ten seconds so as to always show the latest data. Note: there are zero APIs available for me to do this. I am having to use workarounds to achieve this.
- 01-06-2013, 04:21 PM #2
Create a method that contains the logic that you want to execute on the fixed interval. In your case, you'll want to:
- Download the required HTML pages (you can use WebClient.DownloadStringAsync Method (System.Net) to download the content of each page)
- Parse the required HTML pages (I'd recommend using Html Agility Pack - Home for this; The HTML Agility Pack exposes the contents of HTML pages as XML-like documents so it's much easier to work with and less error-prone).
- Update the GUI with the updated data (either set up data binding beforehand and update the properties of the bound object accordingly, or update the GUI directly)
To have the UI update every 10 seconds, check out the DispatcherTimer Class (System.Windows.Threading) class. With that class you can specify the time interval (in your case, 10 seconds) between executions of the code you want to execute. Then set the Tick event handler to call the method that you wrote to fetch the pages.
- By mjgates in forum Windows Phone 7Replies: 2Last Post: 09-02-2012, 11:11 PM
- By mbranscum in forum Nokia Lumia 900Replies: 6Last Post: 07-02-2012, 11:33 AM
- By pdawg17 in forum Windows Phone 7Replies: 8Last Post: 10-29-2011, 06:09 AM
- By justletmesignup in forum HTC TrophyReplies: 2Last Post: 10-24-2011, 10:33 AM