Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toggle playback mode button in the player. #309

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/renderer/components/core/Icons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/19
// 220.847 220.847
path(d='M199.948,188.028c11.536,0,20.898-13.811,20.898-30.842V63.66c0-17.026-9.367-30.841-20.898-30.841c-11.548,0-20.899,13.815-20.899,30.841v25.8l-75.96-43.559C88.634,37.604,76.89,44.1,76.39,60.351l48.558,27.848c9.579,5.489,15.079,13.595,15.079,22.232c0,8.645-5.5,16.744-15.079,22.243L76.39,160.511c0.5,16.239,12.244,22.743,26.699,14.447l75.96-43.548v25.776C179.044,174.223,188.4,188.028,199.948,188.028z')
path(d='M112.525,95.091L26.75,45.901C11.982,37.427,0,44.369,0,61.404v98.062c0,17.025,11.982,23.969,26.75,15.492l85.781-49.177C127.294,117.305,127.294,103.565,112.525,95.091z')
g#icon-listLoop(fill='currentColor')
path(d="M0 0h24v24H0z" fill="none")
path(d='M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z')
g#icon-singleLoop(fill='currentColor')
path(d="M0 0h24v24H0z" fill="none")
path(d="M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4zm-4-2V9h-1l-2 1v1h1.5v4H13z")
g#icon-random(fill='currentColor')
path(d="M0 0h24v24H0z" fill="none")
path(d="M10.59 9.17L5.41 4 4 5.41l5.17 5.17 1.42-1.41zM14.5 4l2.04 2.04L4 18.59 5.41 20 17.96 7.46 20 9.5V4h-5.5zm.33 9.41l-1.41 1.41 3.13 3.13L14.5 20H20v-5.5l-2.04 2.04-3.13-3.13z")
g#icon-list(fill='currentColor')
path(d="M0 0h24v24H0z" fill="none")
path(d="M4 10h12v2H4zm0-4h12v2H4zm0 8h8v2H4zm10 0v6l5-3z")
// 205.857 205.857
//- path(d='M174.522,0h-26.848c-9.885,0-17.897,8.013-17.897,17.899v62.533L37.513,2.522c-3.483-2.406-7.807-2.005-11.072-2.005c-13.061,0-13.004,11.7-13.004,14.666v175.983c0,2.507-0.057,14.666,13.004,14.666c3.265,0,7.589,0.401,11.072-2.005l92.265-77.91v62.016c0,9.885,8.012,17.898,17.897,17.898h26.848c9.885,0,17.898-8.013,17.898-17.898V17.899C192.421,8.013,184.408,0,174.522,0z')
g#icon-sound(fill='currentColor')
Expand Down
21 changes: 19 additions & 2 deletions src/renderer/components/core/Player.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,17 @@ div(:class="$style.player")
div(:class="$style.playBtn" @click='handleNext' :title="$t('core.player.next')")
svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 220.847 220.847' space='preserve')
use(xlink:href='#icon-nextMusic')
div(:class="$style.playBtn" @click='changePlaybackMode' :title="$t('core.player.next')")
svg(v-if="playbackMode == 'listLoop'" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 24 24' space='preserve')
use(xlink:href="#icon-listLoop")
svg(v-else-if="playbackMode == 'random'" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 24 24' space='preserve')
use(xlink:href="#icon-random")
svg(v-else-if="playbackMode == 'singleLoop'" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 24 24' space='preserve')
use(xlink:href="#icon-singleLoop")
svg(v-else-if="playbackMode == 'list'" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 24 24' space='preserve')
use(xlink:href="#icon-list")
//- transition(enter-active-class="animated lightSpeedIn"
transition(enter-active-class="animated lightSpeedIn"
leave-active-class="animated slideOutDown")
transition(enter-active-class="animated lightSpeedIn" leave-active-class="animated slideOutDown")
core-player-detail(v-if="isShowPlayerDetail" :musicInfo="musicInfo"
:lyric="lyric" :list="list" :listId="listId"
:playInfo="{ nowPlayTimeStr, maxPlayTimeStr, progress, nowPlayTime, status }"
Expand Down Expand Up @@ -134,6 +142,9 @@ export default {
progress() {
return this.nowPlayTime / this.maxPlayTime || 0
},
playbackMode() {
return this.setting.player.togglePlayMethod
},
},
mounted() {
this.init()
Expand Down Expand Up @@ -477,6 +488,12 @@ export default {
index = this.list.indexOf(list[index])
this.setPlayIndex(index)
},
async changePlaybackMode() {
let modes = ['listLoop', 'random', 'list', 'singleLoop']
let idx = modes.indexOf(this.setting.player.togglePlayMethod)
let modeIdx = idx + 1 > 3 ? 0 : idx + 1
this.setting.player.togglePlayMethod = modes[modeIdx]
},
hanldeListRandom(list, index) {
return getRandom(0, list.length)
},
Expand Down