Skip to content

Commit 45b1612

Browse files
committed
Bumping version to 1.5.17
1 parent aa2fe7f commit 45b1612

File tree

5 files changed

+40
-24
lines changed

5 files changed

+40
-24
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release Notes
22

3-
## 1.5.16 - 2019-08-21
3+
## 1.5.17 - 2019-08-21
44
* Sonos support
55
* Removed Youtube
66

src/Client/ReleaseNotes.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module internal ReleaseNotes
22

3-
let Version = "1.5.16"
3+
let Version = "1.5.17"
44

55
let IsPrerelease = false
66

77
let Notes = """
88
# Release Notes
99
10-
## 1.5.16 - 2019-08-21
10+
## 1.5.17 - 2019-08-21
1111
* Sonos support
1212
* Removed Youtube
1313

src/PiServer/PiServer.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ let previousFile (model:Model,token:string) = task {
155155

156156
let getStartupAction (model:Model) = task {
157157
use webClient = new System.Net.WebClient()
158-
let url = sprintf @"%s/api/startup" model.TagServer
158+
let url = sprintf @"%s/api/startup/%s" model.TagServer model.UserID
159159
let! result = webClient.DownloadStringTaskAsync(System.Uri url)
160160

161161
match Decode.fromString (TagActionForBox.Decoder) result with

src/Server/Server.fs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,33 @@ let historyEndPoint userID =
241241
})
242242
}
243243

244-
let startupEndpoint =
244+
let startupEndpoint userID =
245245
pipeline {
246246
set_header "Content-Type" "application/json"
247247
plug (fun next ctx -> task {
248-
let! sas = getSASMediaLink "d97cdddb-8a19-4690-8ba5-b8ea43d3641f"
249-
let action = TagActionForBox.PlayMusik sas
248+
match! AzureTable.getUser userID with
249+
| None ->
250+
return! Response.notFound ctx userID
251+
| Some user ->
252+
let! sas = getSASMediaLink "d97cdddb-8a19-4690-8ba5-b8ea43d3641f"
250253

251-
let txt =
252-
action
253-
|> TagActionForBox.Encoder
254-
|> Encode.toString 0
255-
return! setBodyFromString txt next ctx
254+
match user.SpeakerType with
255+
| SpeakerType.Local ->
256+
let txt =
257+
TagActionForBox.PlayMusik sas
258+
|> TagActionForBox.Encoder
259+
|> Encode.toString 0
260+
return! setBodyFromString txt next ctx
261+
| SpeakerType.Sonos ->
262+
let logger = ctx.GetLogger "Startup"
263+
let! session = Sonos.createOrJoinSession logger user.SonosAccessToken Sonos.group
264+
do! Sonos.playURL logger user.SonosAccessToken session "StartupSound" sas "StartupSound"
265+
266+
let txt =
267+
TagActionForBox.Ignore
268+
|> TagActionForBox.Encoder
269+
|> Encode.toString 0
270+
return! setBodyFromString txt next ctx
256271
})
257272
}
258273

@@ -293,7 +308,7 @@ let webApp =
293308
getf "/api/volumedown/%s" volumeDownEndpoint
294309
postf "/api/upload/%s" uploadEndpoint
295310
getf "/api/history/%s" historyEndPoint
296-
get "/api/startup" startupEndpoint
311+
getf "/api/startup/%s" startupEndpoint
297312
get "/api/firmware" firmwareEndpoint
298313
get "/api/latestfirmware" getLatestFirmware
299314
getf "/api/taghistorysocket/%s" (TagHistorySocket.openSocket tagHistoryBroadcaster)

src/Server/Sonos.fs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,29 @@ let volumeDown (log:ILogger) accessToken group = task {
9090
}
9191

9292

93-
94-
let playStream (log:ILogger) accessToken (session:Session) (tag:Tag) position = task {
93+
let playURL (log:ILogger) accessToken (session:Session) itemID mediaURL description = task {
9594
let headers = ["Authorization", "Bearer " + accessToken]
9695
let url = sprintf "https://api.ws.sonos.com/control/api/v1/playbackSessions/%s/playbackSession/loadStreamUrl" session.ID
9796

98-
99-
match tag.Action with
100-
| TagAction.PlayMusik stream ->
101-
let pos = System.Math.Abs(position % stream.Length)
102-
let body = sprintf """{
97+
let body = sprintf """{
10398
"streamUrl": "%s",
10499
"playOnCompletion": true,
105100
"stationMetadata": {
106101
"name": "%s"
107102
},
108103
"itemId" : "%s"
109-
}""" stream.[pos] (tag.Object + " - " + tag.Description) tag.Token
104+
}""" mediaURL description itemID
105+
110106

111-
log.LogCritical(body)
107+
let! _result = post log url headers body
108+
()
109+
}
112110

113-
let! _result = post log url headers body
114-
()
111+
let playStream (log:ILogger) accessToken (session:Session) (tag:Tag) position = task {
112+
match tag.Action with
113+
| TagAction.PlayMusik stream ->
114+
let pos = System.Math.Abs(position % stream.Length)
115+
do! playURL log accessToken session tag.Token stream.[pos] (tag.Object + " - " + tag.Description)
115116
| _ ->
116117
log.LogError(sprintf "TagAction %A can't be played on Sonos" tag.Action)
117118
}

0 commit comments

Comments
 (0)