Skip to content

Commit

Permalink
Merge pull request #189 from camphor-/set-position-to-zero
Browse files Browse the repository at this point in the history
  • Loading branch information
p1ass authored Aug 6, 2020
2 parents 61feab1 + ce1867f commit fbafd5c
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 32 deletions.
28 changes: 0 additions & 28 deletions domain/mock_spotify/player.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions domain/spotify/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
// Player はSpotifyの曲の操作に関連するAPIを呼び出すためのインターフェースです。
type Player interface {
CurrentlyPlaying(ctx context.Context) (*entity.CurrentPlayingInfo, error)
Play(ctx context.Context, deviceID string) error
PlayWithTracks(ctx context.Context, deviceID string, trackURIs []string) error
PlayWithTracksAndPosition(ctx context.Context, deviceID string, trackURIs []string, position time.Duration) error
Pause(ctx context.Context, deviceID string) error
Enqueue(ctx context.Context, trackURI string, deviceID string) error
Expand Down
3 changes: 2 additions & 1 deletion usecase/session_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

"github.com/camphor-/relaym-server/domain/entity"
"github.com/camphor-/relaym-server/domain/event"
Expand Down Expand Up @@ -230,7 +231,7 @@ func (s *SessionStateUseCase) stopToPlay(ctx context.Context, sess *entity.Sessi
}
for i := 0; i < len(trackURIs); i++ {
if i == 0 {
if err := s.playerCli.PlayWithTracks(ctx, sess.DeviceID, trackURIs[:1]); err != nil {
if err := s.playerCli.PlayWithTracksAndPosition(ctx, sess.DeviceID, trackURIs[:1], 500*time.Millisecond); err != nil {
return fmt.Errorf("call play api with tracks %v: %w", trackURIs[:1], err)
}
continue
Expand Down
2 changes: 1 addition & 1 deletion web/handler/session_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func TestSessionHandler_State_PLAY(t *testing.T) {
m.EXPECT().SetRepeatMode(gomock.Any(), false, "device_id").Return(nil)
m.EXPECT().SetShuffleMode(gomock.Any(), false, "device_id").Return(nil)
m.EXPECT().DeleteAllTracksInQueue(gomock.Any(), "device_id", "spotify:track:5uQ0vKy2973Y9IUCd1wMEF").Return(nil)
m.EXPECT().PlayWithTracks(gomock.Any(), "device_id", []string{"spotify:track:5uQ0vKy2973Y9IUCd1wMEF"}).Return(nil)
m.EXPECT().PlayWithTracksAndPosition(gomock.Any(), "device_id", []string{"spotify:track:5uQ0vKy2973Y9IUCd1wMEF"}, 500*time.Millisecond).Return(nil)
m.EXPECT().Enqueue(gomock.Any(), "spotify:track:49BRCNV7E94s7Q2FUhhT3w", "device_id").Return(nil)
m.EXPECT().Enqueue(gomock.Any(), "spotify:track:3", "device_id").Return(nil)
},
Expand Down

0 comments on commit fbafd5c

Please sign in to comment.