Skip to Content
It is currently November 21st, 2019, 12:12 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: April 30th, 2018, 2:23 pm 
Offline
New User
New User

Joined: February 25th, 2018, 6:25 am
Posts: 10
When I faced the problem of getting the current track to put on my web page I was advised to investigate api used by samcloud inline widget. And hence I found the solution: http://samcloud.spacial.com/api/listen?sid=[sid]&rid=[rid]&f=aac,any&br=64000,any&m=sc. But it could give me only current track's mp3 tag info and some about play history. In general everything the samcloud widgets can show we can get using these api which actually not publicly described.
But now I'm searching for the way to get current play block name and scheduled events calendar information to automatically show some kind of timetable etc. Is any work around for that?


Top
 Profile  
Reply with quote  
PostPosted: May 2nd, 2018, 3:41 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7882
Location: Aachen (Germany)
There must be a documentation somewhere in the Spacial archives.
At some point in time the API was completely public and documented in a PDF or Word document. But that was while the whole thing was still in Beta and was named SAM Vibe.

Current Show:
Code:
https://listen.samcloud.com/webapi/station/<YOUR-STATION-ID>/RetrieveOnAirShow?token=<YOUR-TOKEN>&format=json&_=<OPTIONAL-CACHE-BUSTER>


Upcoming Shows for the next 8 hours:
Code:
https://listen.samcloud.com/webapi/station/<YOUR-STATION-ID>/RetrieveScheduledShows?token=<YOUR-TOKEN>&hours=8&format=json&_=<OPTIONAL-CACHE-BUSTER>


You need to get the Station ID and a valid token yourself.
The Cache Buster is optional for server-side scripting, but might be neccessary for JavaScript in the Browser as you might receive outdated cached information otherwise. Usually the current unix timestamp is used for the cachebuster, but any random string that's not repeated will do.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: May 11th, 2018, 3:30 am 
Offline
New User
New User

Joined: March 25th, 2018, 12:59 am
Posts: 1
I'm facing a similar issue, only I don't seem to be getting the "Now Playing" info.

The ShoutCast link is https://samcloud.spacial.com/api/listen ... 0,any&m=sc

I'm trying to use third-party player widgets and while they can get the audio, they don't seem to be getting the Now Playing info.

I've been trying to work through with the Player developer and Spacial support but it seems like the Player developer seems to think the metadata is stored in a separate file, and Spacial support says that the link I've pasted above should carry the Now Playing info with it.

Has anyone else had any success using third-party widgets?

In particular, I'm trying to use this one: http://heroradioplayer.lambertgroupprod ... ntrollers/


Top
 Profile  
Reply with quote  
PostPosted: May 14th, 2018, 9:05 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7882
Location: Aachen (Germany)
Penmonicus wrote:
I've been trying to work through with the Player developer and Spacial support but it seems like the Player developer seems to think the metadata is stored in a separate file, and Spacial support says that the link I've pasted above should carry the Now Playing info with it.

HTML5 Audio doesn't have any means to interpret metadata sent along a file and doesn't provide any direct access to the raw data of the audio stream.
There are ways to read the metadata of a local file (by grabbing the local file via JavaScript and passing the raw data through to the audio element instead of trying to grab the metadata from the audio element), but those won't work for streaming audio.

Almost all Streaming Audio Players in JavaScript get around that limitation by accessing the exposed stats APIs of typical streaming servers (i.e.: 7.html for Shoutcast v1 or /stats for Shoutcast v2) and reading the Metadata independently from the Audio source. (you could even access the metadata page of one stream while listening to a completely different one)

For SAM Cloud you will need to write your own MetaData parser similar to this minimalistic one:
Code:
<!DOCTYPE html>
<html>
   <head>
       <meta charset="UTF-8">
       <title>SAMCloud Parser - Demo</title>
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
      <script type="text/javascript">
         function updateFromMediaItem(metadataObj) {
            if (metadataObj && metadataObj.m_Item2) {
               var titleTag = document.getElementById('titleTagDisplay');
               titleTag.innerHTML = metadataObj.m_Item2.Artist + ' - ' + metadataObj.m_Item2.Title;
            }
         }
      </script>
      <script type="text/javascript">
            // CONFIGURE HERE
            var stationID = 42879;
            var apiToken = '2ee74261ab6012de69ee5a94662a9bb6ead9066f';
            // refresh MetaData every 5 seconds
         function fetchMetadata(stationID, apiToken) {
            var url = 'http://listen.samcloud.com/webapi/station/'+stationID+'/history/npe?token='+apiToken+'&format=json&callback=updateFromMediaItem';
            $.ajax({
               url,
               cache: false,
               datatype: 'jsonp',
               type: 'GET',
               timeout: 10000
            });
         }
         fetchMetadata(stationID, apiToken);
         window.setInterval(function() {
            fetchMetadata(stationID, apiToken);
         }, 5000);
      </script>
   </head>
   <body>
      <h1 id="titleTagDisplay">We haven't fetched any metadata yet.</h1>
   </body>
</html>


In theory there is a way to get your own token, but I've misplaced the API documentation from the SAM Vibe era where this was explained.
For now you can just use whatever token the "Free Player Site" in your SAM Cloud account under widgets uses:
Open the site from SAM Cloud and view the source (rightclick->view source somewhere on the page).
Then look for a hidden input field with the id Token (<input type="hidden" value="2ee74261ab6012de69ee5a94662a9bb6ead9066f" id="Token" />)
Copy the value and replace the demo value of the apiToken variable in my script above.
The Station ID is the number in almost all samcloud URLs for your station. (i.e. the widgets page URL looks like this: https://samcloud.spacial.com/Station/Ma ... idgets-tab - Here 42879 is my Station ID)

Note: The above code won't work as I deliberately modified the apiToken so you can't use it to communicate with my station.
The demo page will just have an h1 element with the Artist - Title string.
From there on you'll have to do the work yourself. Your Player script demo pages only show the minified code. Unless you get the full sourcecode it's hard to modify the obfuscated code.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group