Getting microphone info with WebAudio API - web-audio-api

I want to be able to see which microphone WebAudio API picked up when it returns the MediaStream. It would be even better if I could select the microphone when more than one is available.
Is there any way to do this?
Thanks

There is, but it only works when your page is served securely (i.e. https:// instead of http://). (this is common with new security-sensitive apis.)
Check out https://webaudiodemos.appspot.com/input/index.html - the select dropdown lets you choose inputs.

Related

How to fetch playback statistics

I'd like to know if it's possible (and if yes: how) to fetch statistics for our soundcloud tracks via the soundcloud API.
I know that i can get the current playback count of my tracks but is it possible to get the playback count of yesterday and so on to draw a custom graph ?
Or do i have to poll the api and record the data myself?
Not officially. Latest and official api does not support this feature yet. It voilates the tos.
Check that question first, before you read further:
soundcloud: Is api-v2 allowed to be used and is there documentation on it?
For experimental use, you can try this:
soundcloud.com/{username}/stats
Is a good starting point to take a deeper look on the networks tab in the console.
Example calls:
totals -> all tracks
https://api-v2.soundcloud.com/users/soundcloud:users:1672444/stats/totals?from=1427846400000&to=1428364800000&client_id=b45b1aa10f1ac2941910a7f0d10f8e28&app_version=1d6991e
plays -> individual tracks
https://api-v2.soundcloud.com/users/soundcloud:users:1672444/tracks/soundcloud:tracks:148976759/stats/timeseries/plays?from=1427846400000&to=1428364800000&resolution=day&client_id=b45b1aa10f1ac2941910a7f0d10f8e28&app_version=1d6991e
The second call will give you, what you want - an array with the daily plays.
To make the calls working i had to manipulate the request headers.
Origin https://soundcloud.com
Referer https://soundcloud.com
Host api-v2.soundcloud.com
Authorization (copied from network tab)

How do I extract streamed "now playing" data embedded in an Icecast audio (radio) stream on Samsung Smart-TV

I am creating a Samsung TV app for a radio station and they provide the "Now Playing" info within the Icecast stream. Is it possible to (and how do I) extract this information?
Shoutcast supports "Icy-MetaData" - an additional field in the request header. When set, its a request to the shoutcast server to embed metadata about the stream at periodic intervals(once every "icy-metaint" bytes) in the encoded audio stream itself. The value of "icy-metaint" is decided by the shoutcast server configuration and is sent to the client as part of the initial reply.
Check out this post on Shoutcast Internet Radio Protocol for details on icy:metadata and sample code in C.
A somewhat more technical discussion is also available at
http://forums.radiotoolbox.com/viewtopic.php?t=74
Yes, this is possible. The metadata is interleaved into the stream data at a specified interval. Basically, you read 8192 bytes (or whatever is specified by the Icy-MetaInt response header), and then you read the metadata block.
The first byte of that metadata block tells you the length of the data. A length of 0 means there is no updated metadata.
Once you read the meta block, then you go back to reading stream data.
I have all of this in more detail on my answer here: https://stackoverflow.com/a/4914538/362536 While I know you're not writing PHP, the principal is identical no matter what language.
From native player there is no option to get this meta.
You could probably use jQuery.stream plugin to fetch the meta directly - but you need to setup Access-Control-Allow-Origin on you icecast server - but I have no idea if it will work.
The best solution here will be to use this script:
http://code.google.com/p/icecast-now-playing-script/
So you install this script on your web server and from the SmartTV application you will AJAX it once for a while, while your stream is playing.
I just created a radio player for icecast and centova, it uses lastFM api to extract the song meta data. https://github.com/johndavedecano/Icecast-Centova-LastFM-API
If you are doing this for a radio station, then they can provide this data through the XSLT feature of Icecast. Some random old XSLT examples for offering stream metadata that I did at some point.
The other option is to run Icecast 2.4.1 or add the two files (xml2json.xsl status-json.xsl) to an old version.
Note that only Icecast 2.4.1 or newer supports adding CORS/ACAO headers that might be necessary to access data from a web app / web site.
If you are not directly cooperating with the radio station and can't ask them to do this, then disregard this answer. Someone else might find it useful though.

How do I see the aggregates of my published "news.reads" actions?

I have a Facebook application that wants to publish document reads to a user's OpenGraph.
Since read is a reserved, built-in action, my objects have to have the type article. The publishing of reads to the user's graph works fine and the last read is also shown on the user's timeline.
Additionally, I have set up some aggregators that would show the last 5 reads, the most popular authors etc. The problem is that I can not find those aggregators anywhere in my timeline/profile or in the App section of my user.
Is it not possible to control/show the aggregators for built-in actions and objects?
I have a feeling it should be, since I can set them up and (for example) Spotifiy also uses the built-in music.song objects, as shown below - this is basically, what I also want.
All I am seeing on my app's timeline section, though, is this:
I believe you are not in control of when facebook displays your aggregations as you have defined them in your open graph settings, since facebook uses the so called 'GraphRank' to determine whether to show your aggregation or not. The calculation goes like this:
GraphRank = affinity * weight * interactions * time
affinity (score): this is the relationship between the viewing user and the creator of the action.
weight: if two users interact frequently with each other, the respective actions in the open graph are rated higher than for users who do not have the same interest and are not in close contact on Facebook.
interactions: how often does the user interact with the application and how do friends react to the activities in the social channels (if nobody clicks on the published actions it's bad for the GraphRank).
time: if an app is used irregularly or only once, actions will receive less attention in the long run and will be presented less prominently on the timeline.
See this article: http://www.insidefacebook.com/2011/12/27/edgerank-and-graph-rank-defined/
This is not the perfect answer to the actual question but I was able to solve the problem nevertheless. In case someone else is in the same spot, you might profit from my learnings:
The application I'm building wants to push read actions to a user's OpenGraph. My aggregation problem was that my reads from the built-in news.reads action did not get aggregated. To this day, I do not know why not.
Instead, I managed to create my own read action. It is not connected to the built-in one and exists in my own namespace.
This action can now be connected to my own objects as well and is not bound to the article object – as is the built-in one.
Having my own actions and objects, it was a breeze to follow the instructions for aggregations and create as many aggregations as I like. They also actually show up in my test users' profiles. Yeah.

Accessing iPhone playback data

I want to be able to pull out the user's 50 most recently played songs, then be able to sort that via artist/album/genre etc. How can I make this happen immediately upon the app's opening and what would be the best way (I'm thinking dictionary?) to bundle this up so I can send it to a server?
Thanks!
MPMediaItemPropertyLastPlayedDate might be what you're looking for. See this related question for how to access the various media item properties.
Your app delegate's applicationDidBecomeActive: method would be an appropriate place to scan on-launch, and an NSDictionary converted to JSON should be suitable serialization format.
Be sure to inform the user before sending their data off to your server, however.

Getting current location and posting it to a web service

Ok... maybe forbidden by Apple, but assuming this is permitted. What would be the best way to get the current location (not difficult) and posting it to a web service (also not much of a challenge). The app is for an artist who wants people to see where he is at the moment. Personally, I wouldn't want people to know where I am 24/7 but that's performance art I guess. An exact location is not wanted but a town or area would be preferred. I could modify the string when it gets to the server and make it more vague by rounding the LOG and LAT.
The app the fans would use would retrieve his current location from the server and update the map view with a location.
I suppose one way would be for him to find out his coordinates and post that to a web page but I'd like it to update automatically.
A response with code is not necessary, just a general opinion on methodology/advisability would be appreciated
I would probably give him a webpage to go to that records his position every time he visits. It would be a private URL, and perhaps use some lightweight authentication. For versatility, I'd record the exact position in the database (in case he changes his mind on how it should work later on). However, you could use an external service or another purchased database with zips or city information with lat/lng data, so you could just provide users of the client app with his general vicinity rather than exact location.
The alternative would be to give him an ad hoc app that does the same thing, but putting together that location recording webpage would be a much simpler process. Could be handy for other things, too.
Here's a little writeup about getting location from mobile Safari, just as a reference: http://mobiforge.com/developing/story/location-iphone-web-apps
Why wouldn't you just use google latitude and read out his status?
I think this should really be done as a web page web-app. You can get coordinates from the device through mobile safari and you can skip the app approval process. You can also set it up so it runs fullscreen on his phone and he won't know the difference. You can also put a password on it.
There is a good chance it would not get approved as a regular app.
You can always meta refresh the page to keep it updating.
http://smithsrus.com/gps-geolocation-in-safari-on-iphone-os-3-0/
"Artist" must log in to his application (thus insuring that he want to share his coordinates with your webserver), then you use CLLocationManager to get his coordinates and make a reverse geocoding using Google Maps API to get country and city for given coordinates.
Can't see anything special about it :)