Skip to content

Commit

Permalink
feat: play music
Browse files Browse the repository at this point in the history
  • Loading branch information
amorist committed Oct 4, 2018
1 parent 504a932 commit b2f7814
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Your Desktop Platelet
## Features
* toggle dark mode
* take photo
* play music

## Download
* mac https://github.com/amorist/platelet/releases
Expand Down
31 changes: 23 additions & 8 deletions assets/js/platelet.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,26 @@ re.toString = function () {
return '';
};

$(document).on('copy', function () {
showMessage('你都复制了些什么呀,转载要记得加上出处哦', 5000, true);
});

$('.platelet-tool .fui-home').click(function () {
// window.location = '';
});

$('.platelet-tool .eye').click(function () {
switchNightMode();
showMessage('你会做眼保健操吗?', 3000, true);
});

let is_play = false

$('.platelet-tool .music').click(function () {
let text = '播放血小板之歌了哦';
if (is_play) {
is_play = false;
text = '停止播放血小板之歌了哦';
} else {
is_play = true;
text = '播放血小板之歌了哦';
}
showMessage(text, 3000, true);
playVoice('./assets/music/platelet.mp3', is_play)
});

$('.platelet-tool .comment').click(function () {
showHitokoto();
});
Expand Down Expand Up @@ -167,4 +174,12 @@ function formatSeconds(value) {
if (days > 0)
result = "" + parseInt(days) + "天" + result;
return result;
}

function playVoice(file, is_play) {
if (is_play) {
$('.music').html('<audio controls="controls" id="audio_player" style="display:none;"> <source src="' + file + '" > </audio><embed id="MPlayer_Alert" src="' + file + '" loop="false" width="0px" height="0px" /></embed>');
} else {
$('.music').html('');
}
}
Binary file added assets/music/platelet.mp3
Binary file not shown.
6 changes: 6 additions & 0 deletions assets/platelet-tips.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"深夜时要爱护眼睛呀"
]
},
{
"selector": ".platelet-tool .music",
"text": [
"洛天依,血小板之歌哦"
]
},
{
"selector": ".platelet-tool .comment",
"text": [
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</div>
<div class="platelet-tool">
<i class="fa fa-eye eye"></i>
<i class="fa fa-music music"></i>
<i class="fa fa-comment comment"></i>
<i class="fa fa-camera camera"></i>
</div>
Expand Down

0 comments on commit b2f7814

Please sign in to comment.