18 Star 120 Fork 33

会PS的小码农 / vue-aplayer for electron-vue

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
MIT

Vue-APlayer

Vue-APlayer

fork star

Vue implementation of APlayer prototype. Demo

Screenshot

特性

  • Beautiful clean UI
  • Lyrics scroll
  • Playlist with repeat & shuffle controls
  • Custom theme color / Self-adapting theme color
  • Drag and place anywhere
  • Mutex play
  • HLS support
  • Easy props and API
  • Dependency free and light-weight (gzipped 16KB)

Using Vue-APlayer in your project? Let me know!

运行时要求

使用

<aplayer autoplay
  :music="{
    title: 'secret base~君がくれたもの~',
    artist: 'Silent Siren',
    src: 'https://cn-east-17-aplayer-35525609.oss.dogecdn.com/secretbase.mp3',
    pic: 'https://cn-east-17-aplayer-35525609.oss.dogecdn.com/secretbase.jpg'
  }"
/>

以下方法只是实现思路,仅供参考

<!--下面是electron使用方法,该方法需要node fs支持-->
<aplayer autoplay ref="player" theme="pic" repeat="list" showLrc :narrow="false" :music="music" :list="music_list" />

<script>
    import { remote } from "electron";
    import path from "path";
    const fs = require("fs");
    import VueAplayer from "vue-aplayer";
    export default {
        name: "index",
        components: {
            //别忘了引入组件
            aplayer: VueAplayer
        },
        data() {
            return {
                music_list: [],
                music: {
                    // title: "王菲 - 红豆",
                    // src: "file:/home/edison/Music/王菲 - 红豆.mp3",
                    // lrc: "file:/home/edison/Music/王菲 - 红豆.lrc",
                    // artist: "王菲",
                    // pic: "file:/home/edison/Music/王菲 - 红豆.jpg"
                },
            }
        },
        created: function() {
            this.onload_music()
        },
        methods: {
            onload_music() {
                //获取歌词和图片等
                let resources = (basename, ext) => {
                    return new Promise((resolve, reject) => {
                        let res_path = path.join(music_path, basename + "." + ext);
                        fs.exists(res_path, exists => {
                            if (exists) {
                                resolve("file:" + res_path);
                            } else {
                                resolve(false);
                            }
                        });
                    });
                };
                //自动获取 ~/Music 目录下的所有音乐
                let music_path = path.join(remote.app.getPath("music"));
                //使用fs遍历目录
                fs.readdir(music_path, (err, files) => {
                    if (err) throw err;
                    //写入数组
                    let basename = path.basename(fPath).split(".")[0];
                    music = {
                        title: basename,
                        src: "file:" + fPath,
                        mus_id: md5(fPath),

                        artist: basename.split("-")[0].trim()
                    };
                    let lrc = await resources(basename, "lrc");
                    let pic =
                        (await resources(basename, "jpg")) ||
                        (await resources(basename, "png"));

                    if (lrc) {
                        music.lrc = lrc;
                    }
                    if (pic) {
                        music.pic = pic;
                    }

                    this.music_list.unshift(music);
                })
            }
        }
    }
</script>
// ES6
import Aplayer from 'vue-aplayer'

new Vue({
    components: {
        Aplayer
    }
})

开发者参考文档

贡献

如果你有好建议或则发现bug请 点这里提交

来历

-Vue-APlayer名称应该用完全相同的大小写。 -版本Vue-APlayer@1.x (github)或vue-aplayer@1.x(npm)。

相关项目

鸣谢

@DIYgod, for creating APlayer and sharing cloud storage for hosting Vue-APlayer's demo page media resources.

版权

Vue-APlayer 使用 MIT版权.

Copyright (c) 2016-present Shenghao "Doma" Lei Copyright (c) 2020-present EdisonLiu_

开发

使用npm/cnpm开发

npm install
npm run dev

使用 Yarn 开发

yarn
yarn run dev

测试地址 http://localhost:4000

排错

1.如下错误说明node没有使用11以上版本 An unexpected error occurred: "EPERM: operation not permitted, copyfile

MIT License Copyright (c) 2016-present Shenghao "Doma" Lei Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

github上一款比较好的vue音乐播放器,本人修改了其中一些地方,使其能兼容electron-vue。欢迎兄弟们提交优秀的源码 expand collapse
JavaScript and 4 more languages
MIT
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
JavaScript
1
https://gitee.com/liushuai05/electron-vue-player.git
git@gitee.com:liushuai05/electron-vue-player.git
liushuai05
electron-vue-player
vue-aplayer for electron-vue
master

Search