Page 1 of 1

How to capture REST XML response and use SoundManager2 API or is there a better way?

Posted: Wed Apr 01, 2015 4:20 pm
by Bruce Hoffman

I'm using soundmanager2 api. I've created 2 new javascript (objects), soundmanager2.js and bar-ui.js (the user interface) and a new CSS (object), bar-ui.css.

I've got an HTML control on my starting page. If I put the following code (with hard coded url to audio file) in the control, everything works fine.

<!--
<div class="sm2-bar-ui compact full-width flat"
<div class="bd sm2-main-controls"
<div class="sm2-inline-texture"<
<div class="sm2-inline-gradient"<
<div class="sm2-inline-element sm2-button-element"
<div class="sm2-button-bd"
<a href="#play" class="sm2-inline-button play-pause"Play / pause</a
<
<
<div class="sm2-inline-element sm2-inline-status"
<div class="sm2-playlist"
<div class="sm2-playlist-target"
<noscript<pJavaScript is required.</p</noscript
<
<
<div class="sm2-progress"
<div class="sm2-row"
<div class="sm2-inline-time"0:00<
<div class="sm2-progress-bd"
<div class="sm2-progress-track"
<div class="sm2-progress-bar"<
<div class="sm2-progress-ball"<div class="icon-overlay"<<
<
<
<div class="sm2-inline-duration"0:00<
<
<
<
<div class="sm2-inline-element sm2-button-element sm2-volume"
<div class="sm2-button-bd"
<span class="sm2-inline-button sm2-volume-control volume-shade"</span
<a href="#volume" class="sm2-inline-button sm2-volume-control"volume</a
<
<
<
<div class="bd sm2-playlist-drawer sm2-element"
<div class="sm2-inline-texture"
<div class="sm2-box-shadow"<
<
<div class="sm2-playlist-wrapper"
<ul class="sm2-playlist-bd"
<li<a href="http://www.somewebsite.com/20150322.m... Johnson</b - The Power of the Mind</a</li
</ul
<
<
<
--

But...I need to pull the audio file name from an RSS feed to get the latest available file. I've tried mapping the service to the control and using javascript (in the mapping) to return the updated html and while it renders fine, it does not execute the code within the bar-ui.js (and subsequently the soundmanager2.js).

I found that if I map the RSS to a control on the page, then set a local storage variable to the latest file name using javascript (in the mapping), then create an external function to assemble the html (using the local storage variable) and set the HTML control in the page load event...it works, but not the first time. The first time through the local storage variable is not yet set. So...I figured if I could (via javascript) essentially read the RSS response and build the html for the control in the page load event, it should work.

Problem is, I can't figure out how to read the RSS response (XML). I would imagine it would be some code in the success or complete function of the code that executes the REST service, but I haven't seen any examples of capturing that XML response in javascript. I know how to execute the service, but am stuck on how to capture the XML response.

If there's a better way to do this, I'm all ears. If not, I need to know what to put in the success or completion function to capture the XML.

Thanks!