Android Google Music API - All Access
Asked Answered
K

1

7

This is only a day after Google released All Access for Google Music but the URL array in the JSON response for streamed (not owned) media contains URLs that wont stream. Has anybody looked into this? They play for a fraction of a second and then terminate.

Katey answered 17/5, 2013 at 1:4 Comment(0)
T
2

I've been looking into it and though I haven't found a solution I believe this may be helpful in determining what needs to be done:

Notice that the URLs have a range param but notice that the first one may be like:

 range=0-39706

But the next one would be:

 range=37615-119118

Which seems odd that the next segment would start at a value less than where the previous segment ended. My high level guess is that we will need to write to a file using this range and append the bytes appropriately so that they ARE in order.

But this is just my guess, haven't attempted doing this but I am working on it.

UPDATE

I have successfully accomplished the above, but in C++ using the Qt framework so not Android. But there does seem to be somewhat of an issue in my implementation because every segment has a strange squeak noise so I may need to adjust the byte position a little, but I can get through the whole song now.

Not exactly sure how this would translate to Android but I think it would be something like:

File file = new File("tempFile");
file.open(WRITE_ONLY);
file.write(startingByte, data);

And as you loop through just parse out the starting byte for each segment.

EDIT

Found out my issue was that I was closing the file after each segment. If I leave the file open until I finish writing all the segments then the song plays through perfectly.

Tigrinya answered 29/5, 2013 at 17:38 Comment(2)
How did you handle the overlapping bytes ranges? Did you rewind the byte position for each successive file? In my first attempt, I left the file output stream open as you noted, but I just wrote all the bytes out sequentially, ignoring the overlap and I am getting that squeak.Interstratify
Got it figured out...yes, you have to rewind the byte position in the final output file as you add the data from each part using the range start value shown in the url for each part.Interstratify

© 2022 - 2024 — McMap. All rights reserved.