Skip to content

Commit

Permalink
Some fixes and added welcome track in SPOCCurrentlyPlaying
Browse files Browse the repository at this point in the history
  • Loading branch information
ronjakrg committed Jun 8, 2024
1 parent de464fc commit bad50ef
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 24 deletions.
21 changes: 20 additions & 1 deletion .squot-materialize
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
],
#encoding : @4
},
SquotPlaintextMapper {
#path : FSAbsolutePath [
'CodeGuidelines.md'
],
#encoding : 'TXT'
},
SquotPlaintextMapper {
#path : FSAbsolutePath [
'LICENSE'
],
#encoding : 'TXT'
},
SquotImageMapper {
#path : FSAbsolutePath [
'assets',
Expand All @@ -26,6 +38,13 @@
],
#encoding : 'TXT'
},
SquotImageMapper {
#path : FSAbsolutePath [
'assets',
'squeak-mouse.png'
],
#encoding : @4
},
SquotTonelMapper {
#package : MCPackage {
#name : 'BaselineOfSpotifyConnect'
Expand Down Expand Up @@ -58,7 +77,7 @@
#package : MCPackage {
#name : 'SpotifyConnect'
},
#path : @13
#path : @19
},
SquotPlaintextMapper {
#path : FSAbsolutePath [
Expand Down
Binary file modified assets/squeak-mouse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/SpotifyConnect/SPOCApiPlaybackState.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,16 @@ SPOCApiPlaybackState >> executeTest [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'RK 6/8/2024 22:40'
#'squeak_changestamp' : 'RK 6/9/2024 00:38'
}
SPOCApiPlaybackState >> tinkerReponseContent: aContentStream [

| artists artistItems album albumItem content device deviceItem playbackState track trackItem |
Transcript showln: aContentStream asString.
content := Json readFrom: aContentStream readStream.
deviceItem := content at: #device.
device := SPOCDevice new
id: (deviceItem at: #id);
device := SPOCDevice new.
device id: (deviceItem at: #id);
isActive: (deviceItem at: #is_active);
isPrivateSession: (deviceItem at: #is_private_session);
isRestricted: (deviceItem at: #is_restricted);
Expand Down
7 changes: 2 additions & 5 deletions src/SpotifyConnect/SPOCApp.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -584,14 +584,11 @@ SPOCApp >> searchbar: aSPOCSearchbar [

{
#category : #initialization,
#'squeak_changestamp' : 'RK 6/8/2024 23:02'
#'squeak_changestamp' : 'RK 6/9/2024 00:57'
}
SPOCApp >> setUpCurrentlyPlaying [

self currentlyPlaying: (SPOCCurrentlyPlaying new
app: self;
updateTrack;
yourself)
self currentlyPlaying: (SPOCCurrentlyPlaying new app: self)
]

{
Expand Down
8 changes: 4 additions & 4 deletions src/SpotifyConnect/SPOCCurrentlyPlaying.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ SPOCCurrentlyPlaying >> getPlayingTrack [

{
#category : #initialization,
#'squeak_changestamp' : 'RK 6/8/2024 23:08'
#'squeak_changestamp' : 'RK 6/9/2024 00:01'
}
SPOCCurrentlyPlaying >> initialize [

super initialize.
self track: self getPlayingTrack;
self track: SPOCStyle trackWelcome;
item: (SPOCResultListItem newWith: self track);
addMorph: item;
yourself.
Expand Down Expand Up @@ -70,8 +70,8 @@ SPOCCurrentlyPlaying >> track: anObject [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'RK 6/8/2024 23:02'
#'squeak_changestamp' : 'RK 6/9/2024 00:53'
}
SPOCCurrentlyPlaying >> updateTrack [

self item changeItemTo: self getPlayingTrack
]
34 changes: 34 additions & 0 deletions src/SpotifyConnect/SPOCDevice.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Class {
#name : #SPOCDevice,
#superclass : #Object,
#instVars : [
'id',
'name',
'isActive',
'isPrivateSession',
'isRestricted',
Expand All @@ -28,6 +30,22 @@ SPOCDevice >> equals: aDevice [
& (self volume = aDevice volume)
]

{
#category : #accessing,
#'squeak_changestamp' : 'RK 6/9/2024 00:30'
}
SPOCDevice >> id [
^ id
]

{
#category : #accessing,
#'squeak_changestamp' : 'RK 6/9/2024 00:30'
}
SPOCDevice >> id: aString [
id := aString
]

{
#category : #accessing,
#'squeak_changestamp' : 'VK 5/25/2024 19:05'
Expand Down Expand Up @@ -76,6 +94,22 @@ SPOCDevice >> isRestricted: anObject [
isRestricted := anObject
]

{
#category : #accessing,
#'squeak_changestamp' : 'RK 6/9/2024 00:30'
}
SPOCDevice >> name [
^ name
]

{
#category : #accessing,
#'squeak_changestamp' : 'RK 6/9/2024 00:30'
}
SPOCDevice >> name: aString [
name := aString
]

{
#category : #accessing,
#'squeak_changestamp' : 'VK 5/25/2024 19:07'
Expand Down
17 changes: 15 additions & 2 deletions src/SpotifyConnect/SPOCImage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ Class {
#instVars : [
'url'
],
#category : #SpotifyConnect
#category : #'SpotifyConnect-Utils'
}

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'RK 6/9/2024 00:11'
}
SPOCImage class >> newWithPath: aString [

| form |
form := (GitAssetLoader for: SPOCStyle gitRepoName) loadForm: aString.
form := form scaledToSize: (SPOCStyle resultListItemHeight - (2 * SPOCStyle defaultMargin)).
^ (SPOCImage new image: form)
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'RK 6/1/2024 15:10'
Expand All @@ -22,10 +34,11 @@ SPOCImage class >> newWithUrl: aString [

{
#category : #formatting,
#'squeak_changestamp' : 'RK 6/7/2024 10:59'
#'squeak_changestamp' : 'RK 6/9/2024 00:08'
}
SPOCImage >> scaledTo: aNumber [

url ifNil: [^ self].
^ SPOCImage new image: ((Form fromBinaryStream: (HTTPSocket httpGet: url)) scaledToSize: aNumber)
]

Expand Down
14 changes: 6 additions & 8 deletions src/SpotifyConnect/SPOCPlayer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,15 @@ SPOCPlayer >> updateIsPlaying [

{
#category : #'api-connection',
#'squeak_changestamp' : 'TL 6/8/2024 20:23'
#'squeak_changestamp' : 'RK 6/9/2024 00:46'
}
SPOCPlayer >> updateIsPlayingFromLogin [

| res |
res := self getPlaybackState.
(res isKindOf: SPOCApiEndpointResult)
ifFalse: [self deviceID: ((res at: #device) at: #id);
isPlaying: (res at: #is_playing)].
"self deviceID: apiEndpoint device id;
isPlaying: apiEndpoint isPlaying;"
| playbackState |
playbackState := self getPlaybackState.
self deviceID: playbackState device id;
isPlaying: playbackState isPlaying;
yourself.
self updatePlayPauseIcon
]

Expand Down
3 changes: 2 additions & 1 deletion src/SpotifyConnect/SPOCSearchbar.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ SPOCSearchbar >> buildSearchbar [

{
#category : #building,
#'squeak_changestamp' : 'RK 6/7/2024 11:02'
#'squeak_changestamp' : 'RK 6/9/2024 00:56'
}
SPOCSearchbar >> buildTextInputField [
"To do: specification irgendwie auslagern, damit Methode kürzer"
Expand All @@ -64,6 +64,7 @@ SPOCSearchbar >> buildTextInputField [
hScrollBarPolicy: #never;
vScrollBarPolicy: #never;
acceptOnCR: true;
setProperty: #indicateKeyboardFocus toValue: #never;
yourself.
^ textField
]
Expand Down
26 changes: 26 additions & 0 deletions src/SpotifyConnect/SPOCStyle.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ SPOCStyle class >> defaultMargin [
^ 10
]

{
#category : #'class variables',
#'squeak_changestamp' : 'RK 6/8/2024 23:35'
}
SPOCStyle class >> gitRepoName [

^ 'SpotifyConnect'
]

{
#category : #'class variables',
#'squeak_changestamp' : 'RK 6/7/2024 11:10'
Expand Down Expand Up @@ -129,3 +138,20 @@ SPOCStyle class >> textHeight [

^ 30
]

{
#category : #'class variables',
#'squeak_changestamp' : 'RK 6/9/2024 00:23'
}
SPOCStyle class >> trackWelcome [

| collection |
collection := OrderedCollection new.
collection add: (SPOCArtist new name: 'Spotify in Squeak').
^(SPOCTrack new
image: (SPOCImage newWithPath: '/assets/squeak-mouse.png');
name: 'Welcome!';
album: (SPOCAlbum new artists: collection);
duration: 0;
yourself)
]

0 comments on commit bad50ef

Please sign in to comment.