├── static ├── .gitkeep ├── desktop.png └── player_default_cover.png ├── config ├── prod.env.js ├── test.env.js ├── dev.env.js └── index.js ├── src ├── assets │ └── logo.png ├── store │ ├── index.js │ └── playlist.js ├── router │ └── index.js ├── components │ ├── Artist.vue │ ├── Home.vue │ ├── common │ │ ├── header.vue │ │ └── sidebar.vue │ └── playlist │ │ ├── PlayList.vue │ │ └── Player.vue ├── main.js ├── App.vue └── api │ └── list.js ├── test ├── unit │ ├── .eslintrc │ ├── specs │ │ └── Hello.spec.js │ ├── index.js │ └── karma.conf.js └── e2e │ ├── specs │ └── test.js │ ├── custom-assertions │ └── elementCount.js │ ├── runner.js │ └── nightwatch.conf.js ├── .editorconfig ├── .postcssrc.js ├── .gitignore ├── index.html ├── .babelrc ├── README.md └── package.json /static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /static/desktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irustm/vuejs-music-player/HEAD/static/desktop.png -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irustm/vuejs-music-player/HEAD/src/assets/logo.png -------------------------------------------------------------------------------- /static/player_default_cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irustm/vuejs-music-player/HEAD/static/player_default_cover.png -------------------------------------------------------------------------------- /test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "mocha": true 4 | }, 5 | "globals": { 6 | "expect": true, 7 | "sinon": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /config/test.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const devEnv = require('./dev.env') 4 | 5 | module.exports = merge(devEnv, { 6 | NODE_ENV: '"testing"' 7 | }) 8 | -------------------------------------------------------------------------------- /config/dev.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const prodEnv = require('./prod.env') 4 | 5 | module.exports = merge(prodEnv, { 6 | NODE_ENV: '"development"' 7 | }) 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vuex from 'vuex' 2 | import Vue from 'vue' 3 | import playlist from './playlist' 4 | 5 | Vue.use(Vuex) 6 | 7 | export default new Vuex.Store({ 8 | modules: { 9 | playlist 10 | } 11 | }) 12 | -------------------------------------------------------------------------------- /.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | // to edit target browsers: use "browserslist" field in package.json 6 | "autoprefixer": {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Home from '@/components/Home' 4 | 5 | Vue.use(Router) 6 | 7 | export default new Router({ 8 | routes: [ 9 | { 10 | path: '/', 11 | name: 'Hello', 12 | component: Home 13 | } 14 | ] 15 | }) 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | test/unit/coverage 8 | test/e2e/reports 9 | selenium-debug.log 10 | package-lock.json 11 | 12 | # Editor directories and files 13 | .idea 14 | .vscode 15 | *.suo 16 | *.ntvs* 17 | *.njsproj 18 | *.sln 19 | -------------------------------------------------------------------------------- /src/components/Artist.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | lite vuejs music player 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] 7 | } 8 | }], 9 | "stage-2" 10 | ], 11 | "plugins": ["transform-runtime"], 12 | "env": { 13 | "test": { 14 | "presets": ["env", "stage-2"], 15 | "plugins": ["istanbul"] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/components/Home.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /test/unit/specs/Hello.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import HelloWorld from '@/components/HelloWorld' 3 | 4 | describe('HelloWorld.vue', () => { 5 | it('should render correct contents', () => { 6 | const Constructor = Vue.extend(HelloWorld) 7 | const vm = new Constructor().$mount() 8 | expect(vm.$el.querySelector('.hello h1').textContent) 9 | .to.equal('Welcome to Your Vue.js App') 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /test/unit/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | Vue.config.productionTip = false 4 | 5 | // require all test files (files that ends with .spec.js) 6 | const testsContext = require.context('./specs', true, /\.spec$/) 7 | testsContext.keys().forEach(testsContext) 8 | 9 | // require all src files except main.js for coverage. 10 | // you can also change this to match only the subset of files that 11 | // you want coverage for. 12 | const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/) 13 | srcContext.keys().forEach(srcContext) 14 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | import Vue from 'vue' 4 | import Vuetify from 'vuetify' 5 | import App from './App' 6 | import router from './router' 7 | import store from './store/index' 8 | import('../node_modules/vuetify/dist/vuetify.min.css') 9 | 10 | Vue.config.productionTip = false 11 | 12 | Vue.use(Vuetify) 13 | /* eslint-disable no-new */ 14 | new Vue({ 15 | el: '#app', 16 | router, 17 | store, 18 | template: '', 19 | components: { App } 20 | }) 21 | -------------------------------------------------------------------------------- /test/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // For authoring Nightwatch tests, see 2 | // http://nightwatchjs.org/guide#usage 3 | 4 | module.exports = { 5 | 'default e2e tests': function (browser) { 6 | // automatically uses dev Server port from /config.index.js 7 | // default: http://localhost:8080 8 | // see nightwatch.conf.js 9 | const devServer = browser.globals.devServerURL 10 | 11 | browser 12 | .url(devServer) 13 | .waitForElementVisible('#app', 5000) 14 | .assert.elementPresent('.hello') 15 | .assert.containsText('h1', 'Welcome to Your Vue.js App') 16 | .assert.elementCount('img', 1) 17 | .end() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 24 | 25 | 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vuejs-music-player 2 | 3 | > A Vue.js lite music player 4 | [Demo](https://jamaks.github.io/vuejs-music-player/dist/) 5 | 6 |

7 | 8 |

9 | 10 | ## Build Setup 11 | 12 | ``` bash 13 | # install dependencies 14 | npm install 15 | 16 | # serve with hot reload at localhost:8080 17 | npm run dev 18 | 19 | # build for production with minification 20 | npm run build 21 | 22 | # build for production and view the bundle analyzer report 23 | npm run build --report 24 | 25 | # run unit tests 26 | npm run unit 27 | 28 | # run e2e tests 29 | npm run e2e 30 | 31 | # run all tests 32 | npm test 33 | ``` 34 | 35 | For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 36 | -------------------------------------------------------------------------------- /test/e2e/custom-assertions/elementCount.js: -------------------------------------------------------------------------------- 1 | // A custom Nightwatch assertion. 2 | // the name of the method is the filename. 3 | // can be used in tests like this: 4 | // 5 | // browser.assert.elementCount(selector, count) 6 | // 7 | // for how to write custom assertions see 8 | // http://nightwatchjs.org/guide#writing-custom-assertions 9 | exports.assertion = function (selector, count) { 10 | this.message = 'Testing if element <' + selector + '> has count: ' + count 11 | this.expected = count 12 | this.pass = function (val) { 13 | return val === this.expected 14 | } 15 | this.value = function (res) { 16 | return res.value 17 | } 18 | this.command = function (cb) { 19 | var self = this 20 | return this.api.execute(function (selector) { 21 | return document.querySelectorAll(selector).length 22 | }, [selector], function (res) { 23 | cb.call(self, res) 24 | }) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/api/list.js: -------------------------------------------------------------------------------- 1 | const _playlist = [ 2 | { title: 'Blood And Iron', subtitle: 'Bathory', time: '04:35', avatar: 'http://avatars.yandex.net/get-music-content/42108/652d80b7.a.278291-1/400x400' }, 3 | { title: 'Heralder', subtitle: 'Falkenbach', time: '03:15', avatar: '/static/player_default_cover.png' }, 4 | { title: 'The Naglfar Saga: Sailing Into Eternity', subtitle: 'Black Messiah', time: '04:12', avatar: 'http://avatars.yandex.net/get-music-content/34131/3ec738e9.a.234071-1/400x400' }, 5 | { title: 'Oathbreaker', subtitle: 'Battlesoul', time: '02:12', avatar: '/static/player_default_cover.png' }, 6 | { title: 'Victory Song', subtitle: 'Ensiferum', time: '03:12', avatar: 'http://avatars.yandex.net/get-music-content/33216/09a70ba7.a.3379477-1/400x400' }, 7 | { title: 'The Mistress Of Wisdom', subtitle: 'Ereb Altor', time: '03:45', avatar: 'http://avatars.yandex.net/get-music-content/34131/ad6c4644.a.647543-1/400x400' } 8 | ] 9 | 10 | export default { 11 | getList (cb) { 12 | setTimeout(() => cb(_playlist), 100) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/unit/karma.conf.js: -------------------------------------------------------------------------------- 1 | // This is a karma config file. For more details see 2 | // http://karma-runner.github.io/0.13/config/configuration-file.html 3 | // we are also using it with karma-webpack 4 | // https://github.com/webpack/karma-webpack 5 | 6 | var webpackConfig = require('../../build/webpack.test.conf') 7 | 8 | module.exports = function (config) { 9 | config.set({ 10 | // to run in additional browsers: 11 | // 1. install corresponding karma launcher 12 | // http://karma-runner.github.io/0.13/config/browsers.html 13 | // 2. add it to the `browsers` array below. 14 | browsers: ['PhantomJS'], 15 | frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'], 16 | reporters: ['spec', 'coverage'], 17 | files: ['./index.js'], 18 | preprocessors: { 19 | './index.js': ['webpack', 'sourcemap'] 20 | }, 21 | webpack: webpackConfig, 22 | webpackMiddleware: { 23 | noInfo: true 24 | }, 25 | coverageReporter: { 26 | dir: './coverage', 27 | reporters: [ 28 | { type: 'lcov', subdir: '.' }, 29 | { type: 'text-summary' } 30 | ] 31 | } 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /test/e2e/runner.js: -------------------------------------------------------------------------------- 1 | // 1. start the dev server using production config 2 | process.env.NODE_ENV = 'testing' 3 | var server = require('../../build/dev-server.js') 4 | 5 | server.ready.then(() => { 6 | // 2. run the nightwatch test suite against it 7 | // to run in additional browsers: 8 | // 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings" 9 | // 2. add it to the --env flag below 10 | // or override the environment flag, for example: `npm run e2e -- --env chrome,firefox` 11 | // For more information on Nightwatch's config file, see 12 | // http://nightwatchjs.org/guide#settings-file 13 | var opts = process.argv.slice(2) 14 | if (opts.indexOf('--config') === -1) { 15 | opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js']) 16 | } 17 | if (opts.indexOf('--env') === -1) { 18 | opts = opts.concat(['--env', 'chrome']) 19 | } 20 | 21 | var spawn = require('cross-spawn') 22 | var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' }) 23 | 24 | runner.on('exit', function (code) { 25 | server.close() 26 | process.exit(code) 27 | }) 28 | 29 | runner.on('error', function (err) { 30 | server.close() 31 | throw err 32 | }) 33 | }) 34 | -------------------------------------------------------------------------------- /test/e2e/nightwatch.conf.js: -------------------------------------------------------------------------------- 1 | require('babel-register') 2 | var config = require('../../config') 3 | 4 | // http://nightwatchjs.org/gettingstarted#settings-file 5 | module.exports = { 6 | src_folders: ['test/e2e/specs'], 7 | output_folder: 'test/e2e/reports', 8 | custom_assertions_path: ['test/e2e/custom-assertions'], 9 | 10 | selenium: { 11 | start_process: true, 12 | server_path: require('selenium-server').path, 13 | host: '127.0.0.1', 14 | port: 4444, 15 | cli_args: { 16 | 'webdriver.chrome.driver': require('chromedriver').path 17 | } 18 | }, 19 | 20 | test_settings: { 21 | default: { 22 | selenium_port: 4444, 23 | selenium_host: 'localhost', 24 | silent: true, 25 | globals: { 26 | devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port) 27 | } 28 | }, 29 | 30 | chrome: { 31 | desiredCapabilities: { 32 | browserName: 'chrome', 33 | javascriptEnabled: true, 34 | acceptSslCerts: true 35 | } 36 | }, 37 | 38 | firefox: { 39 | desiredCapabilities: { 40 | browserName: 'firefox', 41 | javascriptEnabled: true, 42 | acceptSslCerts: true 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/components/common/header.vue: -------------------------------------------------------------------------------- 1 | 36 | 37 | -------------------------------------------------------------------------------- /src/store/playlist.js: -------------------------------------------------------------------------------- 1 | import list from '../api/list' 2 | 3 | const state = { 4 | all: [], 5 | currentIndex: 0, 6 | isPlay: false 7 | } 8 | 9 | const actions = { 10 | getAllPlayList ({commit}) { 11 | list.getList(playlist => { 12 | commit('recieve_list', playlist) 13 | }) 14 | }, 15 | playSound ({commit, state}, index) { 16 | if (state.currentIndex == index && state.isPlay) { 17 | commit('pause_sound') 18 | } else { 19 | commit('play_sound', index) 20 | } 21 | }, 22 | pauseSound ({commit}) { 23 | commit('pause_sound') 24 | }, 25 | nextSound ({commit, state}) { 26 | let index = 0 27 | if ((state.all.length - 1) > state.currentIndex) { 28 | index = state.currentIndex + 1 29 | } 30 | commit('play_sound', index) 31 | }, 32 | prevSound ({commit, state}) { 33 | let index = state.all.length - 1 34 | if (state.currentIndex >= 1) { 35 | index = state.currentIndex - 1 36 | } 37 | commit('play_sound', index) 38 | } 39 | } 40 | 41 | const mutations = { 42 | recieve_list (state, playlist) { 43 | state.all = playlist 44 | }, 45 | play_sound (state, index) { 46 | state.isPlay = true 47 | state.currentIndex = index 48 | }, 49 | pause_sound (state) { 50 | state.isPlay = false 51 | } 52 | } 53 | 54 | const getters = { 55 | allPlayList (state) { 56 | return state.all 57 | }, 58 | currentIndex (state) { 59 | return state.currentIndex 60 | }, 61 | isPlay (state) { 62 | return state.isPlay 63 | } 64 | } 65 | 66 | export default { 67 | state, 68 | actions, 69 | mutations, 70 | getters 71 | } 72 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | // Template version: 1.1.3 4 | // see http://vuejs-templates.github.io/webpack for documentation. 5 | 6 | const path = require('path') 7 | 8 | module.exports = { 9 | build: { 10 | env: require('./prod.env'), 11 | index: path.resolve(__dirname, '../dist/index.html'), 12 | assetsRoot: path.resolve(__dirname, '../dist'), 13 | assetsSubDirectory: 'static', 14 | assetsPublicPath: '/', 15 | productionSourceMap: true, 16 | // Gzip off by default as many popular static hosts such as 17 | // Surge or Netlify already gzip all static assets for you. 18 | // Before setting to `true`, make sure to: 19 | // npm install --save-dev compression-webpack-plugin 20 | productionGzip: false, 21 | productionGzipExtensions: ['js', 'css'], 22 | // Run the build command with an extra argument to 23 | // View the bundle analyzer report after build finishes: 24 | // `npm run build --report` 25 | // Set to `true` or `false` to always turn it on or off 26 | bundleAnalyzerReport: process.env.npm_config_report 27 | }, 28 | dev: { 29 | env: require('./dev.env'), 30 | port: process.env.PORT || 8085, 31 | autoOpenBrowser: true, 32 | assetsSubDirectory: 'static', 33 | assetsPublicPath: '/', 34 | proxyTable: {}, 35 | // CSS Sourcemaps off by default because relative paths are "buggy" 36 | // with this option, according to the CSS-Loader README 37 | // (https://github.com/webpack/css-loader#sourcemaps) 38 | // In our experience, they generally work as expected, 39 | // just be aware of this issue when enabling this option. 40 | cssSourceMap: false 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/components/playlist/PlayList.vue: -------------------------------------------------------------------------------- 1 | 45 | 46 | 71 | 76 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuejs-music-player", 3 | "version": "1.0.0", 4 | "description": "A Vue.js lite music player", 5 | "author": "jamaks", 6 | "private": true, 7 | "scripts": { 8 | "dev": "node build/dev-server.js", 9 | "start": "npm run dev", 10 | "build": "node build/build.js", 11 | "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run", 12 | "e2e": "node test/e2e/runner.js", 13 | "test": "npm run unit && npm run e2e" 14 | }, 15 | "dependencies": { 16 | "howler": "^2.0.7", 17 | "vue": "^2.5.2", 18 | "vue-router": "^3.0.1", 19 | "vuetify": "^0.17.6", 20 | "vuex": "^3.0.1" 21 | }, 22 | "devDependencies": { 23 | "autoprefixer": "^7.1.2", 24 | "babel-core": "^6.22.1", 25 | "babel-loader": "^7.1.1", 26 | "babel-plugin-transform-runtime": "^6.22.0", 27 | "babel-preset-env": "^1.3.2", 28 | "babel-preset-stage-2": "^6.22.0", 29 | "babel-register": "^6.22.0", 30 | "chalk": "^2.0.1", 31 | "connect-history-api-fallback": "^1.3.0", 32 | "copy-webpack-plugin": "^4.0.1", 33 | "css-loader": "^0.28.0", 34 | "eventsource-polyfill": "^0.9.6", 35 | "express": "^4.14.1", 36 | "extract-text-webpack-plugin": "^3.0.0", 37 | "file-loader": "^1.1.4", 38 | "friendly-errors-webpack-plugin": "^1.6.1", 39 | "html-webpack-plugin": "^2.30.1", 40 | "http-proxy-middleware": "^0.17.3", 41 | "webpack-bundle-analyzer": "^2.9.0", 42 | "cross-env": "^5.0.1", 43 | "karma": "^1.4.1", 44 | "karma-coverage": "^1.1.1", 45 | "karma-mocha": "^1.3.0", 46 | "karma-phantomjs-launcher": "^1.0.2", 47 | "karma-phantomjs-shim": "^1.4.0", 48 | "karma-sinon-chai": "^1.3.1", 49 | "karma-sourcemap-loader": "^0.3.7", 50 | "karma-spec-reporter": "0.0.31", 51 | "karma-webpack": "^2.0.2", 52 | "mocha": "^3.2.0", 53 | "chai": "^4.1.2", 54 | "sinon": "^4.0.0", 55 | "sinon-chai": "^2.8.0", 56 | "inject-loader": "^3.0.0", 57 | "babel-plugin-istanbul": "^4.1.1", 58 | "phantomjs-prebuilt": "^2.1.14", 59 | "chromedriver": "^2.27.2", 60 | "cross-spawn": "^5.0.1", 61 | "nightwatch": "^0.9.12", 62 | "selenium-server": "^3.0.1", 63 | "semver": "^5.3.0", 64 | "shelljs": "^0.7.6", 65 | "opn": "^5.1.0", 66 | "optimize-css-assets-webpack-plugin": "^3.2.0", 67 | "ora": "^1.2.0", 68 | "rimraf": "^2.6.0", 69 | "url-loader": "^0.5.8", 70 | "vue-loader": "^13.3.0", 71 | "vue-style-loader": "^3.0.1", 72 | "vue-template-compiler": "^2.5.2", 73 | "portfinder": "^1.0.13", 74 | "webpack": "^3.6.0", 75 | "webpack-dev-middleware": "^1.12.0", 76 | "webpack-hot-middleware": "^2.18.2", 77 | "webpack-merge": "^4.1.0" 78 | }, 79 | "engines": { 80 | "node": ">= 4.0.0", 81 | "npm": ">= 3.0.0" 82 | }, 83 | "browserslist": [ 84 | "> 1%", 85 | "last 2 versions", 86 | "not ie <= 8" 87 | ] 88 | } 89 | -------------------------------------------------------------------------------- /src/components/common/sidebar.vue: -------------------------------------------------------------------------------- 1 | 58 | 59 | -------------------------------------------------------------------------------- /src/components/playlist/Player.vue: -------------------------------------------------------------------------------- 1 | 39 | 148 | 154 | 155 | --------------------------------------------------------------------------------