File tree 2 files changed +25
-3
lines changed
music-player/src/components
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 28
28
<SongPlayer
29
29
:song =" list[currentSongIndex]"
30
30
@goback =" isPlayerVisible = !isPlayerVisible"
31
+ @next =" playNext"
32
+ @previous =" playPrevious"
31
33
/>
32
34
</div >
33
35
</template >
@@ -79,6 +81,20 @@ export default {
79
81
this .currentSongIndex = index;
80
82
this .isPlayerVisible = true ;
81
83
},
84
+ playNext () {
85
+ if (this .currentSongIndex < this .list .length - 1 ) {
86
+ this .currentSongIndex += 1 ;
87
+ } else {
88
+ this .currentSongIndex = 0 ;
89
+ }
90
+ },
91
+ playPrevious () {
92
+ if (this .currentSongIndex != 0 ) {
93
+ this .currentSongIndex -= 1 ;
94
+ } else {
95
+ this .currentSongIndex = this .list .length - 1 ;
96
+ }
97
+ },
82
98
},
83
99
};
84
100
</script >
Original file line number Diff line number Diff line change 16
16
<p class =" text-gray-400" >{{ song.year }}</p >
17
17
</div >
18
18
<div class =" grid grid-cols-3 mt-10" >
19
- <div class =" flex items-center justify-center" >
19
+ <div class =" flex items-center justify-center" @click = " previous " >
20
20
<button >Previous</button >
21
21
</div >
22
22
<div class =" flex items-center justify-center" >
26
26
Play
27
27
</button >
28
28
</div >
29
- <div class =" flex items-center justify-center" >
29
+ <div class =" flex items-center justify-center" @click = " next " >
30
30
<button >Next</button >
31
31
</div >
32
32
</div >
@@ -47,11 +47,17 @@ export default {
47
47
songSrc: String ,
48
48
},
49
49
},
50
- emits: [" goback" ],
50
+ emits: [" goback" , " next " , " previous " ],
51
51
methods: {
52
52
goback () {
53
53
this .$emit (" goback" );
54
54
},
55
+ next () {
56
+ this .$emit (" next" );
57
+ },
58
+ previous () {
59
+ this .$emit (" previous" );
60
+ },
55
61
},
56
62
};
57
63
</script >
You can’t perform that action at this time.
0 commit comments