Logic Machine Forum
Youtube playback - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Amati.linea Streaming Player (https://forum.logicmachine.net/forumdisplay.php?fid=18)
+--- Thread: Youtube playback (/showthread.php?tid=919)



Youtube playback - Jayce - 28.07.2017

Hello, I'd like to ask if there's a possibility of amati.linea playing youtube videos as it's doing with soundcloud. I'm referring to this example tutorial:
http://openrb.com/stream-soundcloud-song-by-click-of-knx-push-button/

Thank you very much for any response.


RE: Youtube playback - morak - 02.08.2017

Hi
I'm using Chromecast and HDMI to optical converter. Works perfect.
BR


RE: Youtube playback - admin - 08.08.2017

We have Spotify Connect support coming soon, but it will require Spotify premium account


RE: Youtube playback - Hippolyte - 03.02.2018

(08.08.2017, 12:55)admin Wrote: We have Spotify Connect support coming soon, but it will require Spotify premium account

Any update concerning Spotify Connect ?


RE: Youtube playback - edgars - 05.02.2018

Spotify Connect is already supported. We are doing some tests and will release the firmware soon on our website. Please note that you need Premium subscription in order to work. I'll send you a test firmware to email to try it out Wink


RE: Youtube playback - Thomas_LV - 14.03.2018

(05.02.2018, 08:02)edgars Wrote: Spotify Connect is already supported. We are doing some tests and will release the firmware soon on our website. Please note that you need Premium subscription in order to work. I'll send you a test firmware to email to try it out Wink

Can you send me that firmware to email CEST189@gmail.com?
Thanks


RE: Youtube playback - admin - 15.03.2018

Try this image:
https://dl.openrb.com/audio/imx28-20180313.img


RE: Youtube playback - Thomas_LV - 16.03.2018

[attachment=821 Wrote:admin pid='7741' dateline='1521125084']Try this image:
https://dl.openrb.com/audio/imx28-20180313.img


Thank you,
But i update to my device " ERROR" .
look pic.


RE: Youtube playback - admin - 16.03.2018

Looks like you have older hardware which is not supported anymore.


RE: Youtube playback - Thomas_LV - 16.03.2018

(16.03.2018, 08:18)admin Wrote: Looks like you have older hardware which is not supported anymore.

Help me, pls

thanks


RE: Youtube playback - DGrandes - 04.02.2020

Hi!

Any new with spotify connect?

I´ll try to integrate with Spotify developer but I cant´t get new token. (token expire in 1 hour)

I´ve tried to get token with this but i can´t:

https://developer.spotify.com/documentation/general/guides/authorization-guide/#client-credentials-flow

Code:
local headers_token = {
    ['Authorization'] = "Basic "..Id_Psw_Encode64,   
  }
function Data_Pedir_Token ()
  url = "https://accounts.spotify.com/api/token"
  data = json.encode({
      ['grant_type'] = "client_credentials",
    }) 
  --log(data,url)
  return data, url
end

function Comando_token (data,url)

  headers = headers_token
  url = url
res, err = dorequestPostSpoty(url, headers,"POST", data)
  log(res,err)
  resjson = json.decode(res)
  if resjson[1] == nil then
    return nil
  end 
  return resjson

end

function PedirToken ()
  local data,url = Data_Pedir_Token ()
  Comando_token(data,url)
end



PedirToken ()

If I get token manualy it works perfectly


RE: Youtube playback - Daniel - 04.02.2020

Hi
What do you mean? Spotify was implemented years ago Smile
BR


RE: Youtube playback - DGrandes - 04.02.2020

(04.02.2020, 15:56)Daniel. Wrote: Hi
What do you mean? Spotify was implemented years ago Smile
BR

I don´t understand. How is implemented?


RE: Youtube playback - Daniel - 04.02.2020

Which fw do you have?

You need Spotify Premium account to be able to stream music to SP.


RE: Youtube playback - DGrandes - 04.02.2020

(04.02.2020, 16:05)Daniel. Wrote: Which fw do you have?

You need Spotify Premium account to be able to stream music to SP.
I have 20191015 fw and I have spotify premium.
How can I stream music in LM?


RE: Youtube playback - Daniel - 04.02.2020

In LM you cant as it doesn't have speakers Wink You can stream to amati players. When you play music in spotify app you can select device and one of them will be amati or what name you given to it.


RE: Youtube playback - DGrandes - 04.02.2020

Sorry I haven´t explained well, 

I don´t want to stream in LM.

I want to send an order from LM to spotify acount and spotify speakers/devices (play specific playlist, pause, get status...) and I can do it with manual token but it expires.
When I try to get token by script with this script I can´t do it.

Code:
local headers_token = {
    ['Authorization'] = "Basic "..Id_Psw_Encode64,   
  }
function Data_Pedir_Token ()
  url = "https://accounts.spotify.com/api/token"
  data = json.encode({
      ['grant_type'] = "client_credentials",
    }) 
  --log(data,url)
  return data, url
end

function Comando_token (data,url)

  headers = headers_token
  url = url
res, err = dorequestPostSpoty(url, headers,"POST", data)
  log(res,err)
  resjson = json.decode(res)
  if resjson[1] == nil then
    return nil
  end 
  return resjson

end

function PedirToken ()
  local data,url = Data_Pedir_Token ()
  Comando_token(data,url)
end



PedirToken ()

It is posible?


RE: Youtube playback - Daniel - 04.02.2020

OK, I completely misunderstood you as you posted it under Streaming Player category. Admin should look at it.
PS. I still don't know what is the use for that.


RE: Youtube playback - admin - 05.02.2020

While this can be implemented with manual copying of tokens this solution might stop working at any point. The problem is that OAuth is means for end-user apps with UI not for server-to-server communication (Spotify server-to-server API does not provide player control). You will need a script to refresh the token periodically as it has a short expiration time.

This example might be helpful. It's for different OAuth service but quite similar. You need to put refresh token into storage variable and use access token from storage in scripts that send API requests.
Code:
url = require('socket.url')
http = require('ssl.https')
ltn12 = require('ltn12')
json = require('json')

refresh_token = storage.get('oauth_refresh_token')
if not refresh_token then
  log('missing refresh_token')
  return
end

local function buildqs(chunks)
  local qs = {}
  for k, v in pairs(chunks) do
    qs[ #qs + 1 ] = url.escape(tostring(k)) .. '=' .. url.escape(tostring(v))
  end
  return table.concat(qs, '&')
end

payload = buildqs({
  grant_type = 'refresh_token',
  client_id = 'CLIENT_ID',
  client_secret = 'CLIENT_SECRET',
  refresh_token = refresh_token,
})

source = ltn12.source.string(payload)

headers = {
  ['content-length'] = tostring(#payload),
  ['content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8',
}

sink, output = ltn12.sink.table()

local one, code, hdrs, status = http.request({
  url = 'ENDPOINT_URL',
  sink = sink,
  source = source,
  method = 'POST',
  headers = headers,
})

res = table.concat(output)

if code == 200 then
  res, err = json.pdecode(res)

  if type(res) == 'table' then
    storage.set('oauth_access_token', res.access_token)
    storage.set('oauth_refresh_token', res.refresh_token)
  else
    log('json decode failed', res, err)
  end
else
  log('error', code, res)
end