Sonos: Player not calling getMediaURI - sonos

Working on a Sonos API implementation for a streaming service.
I've got the getMetadata flow setup as:
Open Music Source: Return a list of station groups as a mediaCollection.itemType = container
Click Group: Return a list of stations for the selected group as mediaCollection.itemType = program
Click Play: Returns a single mediaMetadata with itemType = stream
I see a number of calls to getExtendedMetadata from the Windows controller on my dev machine and the player I'm trying to send the stream to.
The Now Playing shows Track and Album information, but the player does not make the getMediaURI request.
When I look at the controller log, I see the follow two errors:
<ApplicationData>#Module:asyncio #Message:Async get failed 1. Error 0x80000002</ApplicationData>
<ApplicationData>#Module:asyncio #Message:RAsyncGETIOOperation failed. Error (1000, 0x00000000)</ApplicationData>

Michael,
A program on Sonos is defined as a programmed radio station. This is a case where you can return a selection of tracks on each request and they are played sequentially. (Think Pandora, 8Tracks, Songza or similar DMCA style radio).
If you are returning a list of radio streams (even if it is only a list of one) the type for that mediaCollection should be collection, container or other.
If you do this and return the stream as a playable item and then click play on the stream you should see the appropriate calls and playback should begin.

Related

YouTube API - how to fetch all playlists of a channel, even the ones who were added from other channels

I stumbled across this problem as I wanted to transfer all playlists (my own and those who I added from other channels) to another channel.
The code I use returns only my own playlists and not the ones I added to my channel from another channel.
I tested this behaviour in the target account which contains a private playlist I created and two playlists from another channel. The script I created uses oauth in order to 'see' my private playlist, but is not able to find the certainly public playlist from the other channel.
My code:
request = youtube.playlists().list(
part="snippet,contentDetails,status",
channelId="UC_x5XG1OV2P6uZZ5FSM9Ttw",
maxResults=25
)
maxResults does not play a role here as I only have got all together three playlist on the test account.
The playlist from another channel is clearly visible when I use the "Library" link and scroll down to "Playlists".
I would appreciate any hint to solve this 'mystery'. TIA!
This is how I added the playlist from the other channel:
go to the other channel
list the playlists
click on "VIEW THE FULL PLAYLIST"
click on the icon which looks like a sandwich combined with a plus sign (hovering on it gives 'save playlist')

How to get multiple streams from WebRTC PeerConnection

According to RTCPeerConnection.ontrack documentation, "ontrack" event suppose to fire for each incoming streams. I have a PeerConnection with two video streams, after connection, "ontrack" fires two times (up to here everything is OK). But both times it sends same stream out, so I end up with two identical video, I am sure sender is sending two different streams, dimension and frame rate of them are different and I can clearly see in chrome://webrtc-internals/ that 2 video streams have different frame size/rate.
Here is PeerConnection ontrack code:
this.peerConnection.ontrack = function(evt) {
console.log("PeerConnection OnTrack event: ", evt.streams);
that.emit('onRemoteStreamAdded', evt.streams);
};
I don't assume evt.streams has 1 object, so I did not write evt.streams[0].
Here is Chrome console log:
As it is obvious from log getRemoteStreams() returns only one object. How is it possible ontrack fires two time when it has only one stream, and why second RTCRtpTransceiver does not make a new stream?
I solved it after few hours of struggling with different browsers and reading documentations several times!
Problem starts at MediaStream.id, it suppose to be unique but <video> element in HTML5 only listens to first track inside each stream. PeerConnection adds new transceivers (as MediaStreamTrack) to same MediaStream, so no matter how many times ontrack handler fires, you get exact same MediaStream objects, but each time you have new unique MediaStreamTrack inside the RTCTrackEvent.
Solution is to create new MediaStream object for each new MediaStreamTrack inside ontrack handler.
this.peerConnection.ontrack = function(event) {
that.emit('onRemoteStreamAdded', new MediaStream([event.track]));
};
Or, more like standard examples:
pc.ontrack = function(event) {
document.getElementById("received_video").srcObject = new MediaStream([event.track]);
};
You get two tracks which are part of a single stream. You can see that in the event.track property, one of them should be audio, the other video.
See https://blog.mozilla.org/webrtc/the-evolution-of-webrtc/ for background information on how streams and tracks work.

ArrowDB - how to get event listener of a chat sent to group?

I'm developing a real time chat app using Titanium Appcelerator. I have everything working with ArrowDB and one user can send another user a message through a group.
https://docs.appcelerator.com/arrowdb/latest/#!/api/Chats
However there doesn't seem to be a method or listener to identify when a new message has been sent to the group.
What I'd like to see is when the other user is typing, and as soon as the message is sent it bubbles up on the recipients chat window. Exactly like how iMessage works.
The only way I can pull new messages from the group to the local users device is to have a refresh button or to use a setInterval with a function call to refresh the messages.
obviously this is not a great way to handle the situation as with a few hundred users every month this would make for hundreds of thousands of api calls and probably not good for device performance.
Does anyone have any ideas how to get real time chat working? Is there a method or event listener I am missing that isn't document?
Push notifications only work while the app is in the background, so this is not an option unfortunately.

Sonos music service: 'No Music' message when playing a program media collection

I have a music service added to Sonos in production,
I received a complaint about a user who plays from a calendar of us, and often the music stops and he gets the message 'No Music' in the player. If he presses 'play' again, Sonos continues to play again till the next 'No Music' message.
The problem happens at an element with these properties:
<ns1:mediaCollection xsi:type="ns1:mediaCollection" readOnly="true" userContent="false" renameable="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns1:id>calendar:34685</ns1:id>
<ns1:itemType>program</ns1:itemType>
<ns1:displayType>List</ns1:displayType>
<ns1:title>Stylish Restaurant</ns1:title>
<ns1:canPlay>true</ns1:canPlay>
<ns1:canEnumerate>false</ns1:canEnumerate>
<ns1:containsFavorite>false</ns1:containsFavorite>
<ns1:albumArtURI requiresAuthentication="false">images/menu/green_legacy.png</ns1:albumArtURI>
<ns1:canAddToFavorite>false</ns1:canAddToFavorite>
</ns1:mediaCollection>
The method GetMetadata with calendar:34685 works fine and returns 2 songs, to be responsive on changes in the calendar.
Is it possible that sometimes this request does not return a valid answer? If so, does anyone know which error type or error return code causes this 'no music' message? Or does it return a valid answer without any songs?
Is there a way to see all sent requests and received responses from a sonos controller or sonos device?
Thanks!

Quickblox--placing/receiving a call while chat page is loaded--- Cordova

we are building an application for chatting and audio/video calling using code for cordova.
In your (quickblox) video call sample, both users have to be in the video page to receive call from each other,
which means that if user1 leaves video page and user2 wants to call him so user 1 wont receive the call.
But in our app we need to allow user to receice call even if he is in chat page, so that we customize your sample to achieve this goal but when we add javascript files related to video call to those related to chat, the app stops loading chat history.
(i think that the problem is in "retrieveChatMessages(dialog, beforeDateSent)" function under "message.js" file )
How we can fix this issue?
Thank you
Regards
I think that the problem is in "retrieveChatMessages(dialog,beforeDateSent)" function under "message.js" file - in the logs sould be an error.
The video-chat sample just for show the possibilities of video and audio calls.
You can call to your opponent with extension like dialog_id, which user from or other params that your need (or look in session object, may be it has all parameters which you need). And opponent recieve your call in onCallListener with this extension object and session (https://quickblox.com/developers/Sample-webrtc-web#Make_a_call).
So the next logic:
user1 call to user2 - session.call(extension, function(error) {...})
user2 has incoming call to QB.webrtc.onCallListener = function(session, extension) {...}
and user2 show for himself popup about incoming call (for example), if he accept call then he open dialog (that he took from parameters), build UI for call and send accept to user1 session.accept(extension)(https://quickblox.com/developers/Sample-webrtc-web#Accept_a_call);
If I don't understand correctly, show errors from the console and we will continue...