├── .browserslistrc ├── .eslintrc.js ├── .gitignore ├── README.md ├── babel.config.js ├── package.json ├── public ├── favicon.ico └── index.html ├── src ├── App.vue ├── assets │ └── logo.png ├── components │ └── VideoPlayer.vue ├── main.js ├── router │ └── index.js ├── store │ └── index.js ├── utils │ └── request.js └── views │ └── Home.vue └── yarn.lock /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | 'extends': [ 7 | 'plugin:vue/vue3-essential', 8 | 'eslint:recommended' 9 | ], 10 | parserOptions: { 11 | parser: 'babel-eslint' 12 | }, 13 | rules: { 14 | 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 15 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 工程介绍 2 | 视频播放 vue3版本 3 | 4 | # 功能介绍 5 | - [x] 播放摄像头rtsp 6 | - [x] 播放编码器rtsp 7 | - [x] 开关播放 8 | - [x] 开关静音控制 9 | - [x] 全屏 10 | 11 | # 文件说明 12 | - 组件位置: @/components/VideoPlayer.vue 13 | - 使用案例: @/views/Home.vue 14 | - 后台访问地址: @/utils/request.js [baseURL] 15 | 16 | # 组件说明 17 | 18 | ```vue 19 | 30 | 57 | ``` 58 | 59 | 60 | # 启动 61 | - 控制台 yarn serve 62 | 63 | # 完整运行 64 | - 需要配合后端项目 我的另一个仓库 [videoplayer_backend](https://github.com/PittYao/videoPlayer_backend) 65 | - 然后在本仓库的utils/request.js中修改后端ip和端口 66 | ```js 67 | const instance = axios.create({ 68 | baseURL: 'http://192.168.99.177:7778', 69 | timeout: 10000 70 | }) 71 | ``` 72 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "videoplayer", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.21.1", 12 | "core-js": "^3.6.5", 13 | "vue": "^3.0.0", 14 | "vue-router": "^4.0.0-0", 15 | "vuex": "^4.0.0-0" 16 | }, 17 | "devDependencies": { 18 | "@vue/cli-plugin-babel": "~4.5.0", 19 | "@vue/cli-plugin-eslint": "~4.5.0", 20 | "@vue/cli-plugin-router": "~4.5.0", 21 | "@vue/cli-plugin-vuex": "~4.5.0", 22 | "@vue/cli-service": "~4.5.0", 23 | "@vue/compiler-sfc": "^3.0.0", 24 | "babel-eslint": "^10.1.0", 25 | "eslint": "^6.7.2", 26 | "eslint-plugin-vue": "^7.0.0", 27 | "sass": "^1.26.5", 28 | "sass-loader": "^8.0.2" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PittYao/VideoPlayer/8010189d10f078c5598719f1c04e247839cb1429/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 31 | -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PittYao/VideoPlayer/8010189d10f078c5598719f1c04e247839cb1429/src/assets/logo.png -------------------------------------------------------------------------------- /src/components/VideoPlayer.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 257 | 258 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import App from './App.vue' 3 | import router from './router' 4 | import store from './store' 5 | 6 | createApp(App).use(store).use(router).mount('#app') 7 | -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import { createRouter, createWebHistory } from 'vue-router' 2 | import Home from '../views/Home.vue' 3 | 4 | const routes = [ 5 | { 6 | path: '/', 7 | name: 'Home', 8 | component: Home 9 | }, 10 | ] 11 | 12 | const router = createRouter({ 13 | history: createWebHistory(process.env.BASE_URL), 14 | routes 15 | }) 16 | 17 | export default router 18 | -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | import { createStore } from 'vuex' 2 | 3 | export default createStore({ 4 | state: { 5 | }, 6 | mutations: { 7 | }, 8 | actions: { 9 | }, 10 | modules: { 11 | } 12 | }) 13 | -------------------------------------------------------------------------------- /src/utils/request.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | 3 | // 后台地址 4 | const instance = axios.create({ 5 | baseURL: 'http://192.168.99.177:7778', 6 | // baseURL: 'http://127.0.0.1:7778', 7 | timeout: 10000 8 | }) 9 | 10 | // 封装get请求 11 | export const get = (url, params = {}) => { 12 | return new Promise((resolve, reject) => { 13 | instance.get(url, { params }).then((response) => { 14 | resolve(response.data) 15 | }, err => { 16 | reject(err) 17 | }) 18 | }) 19 | } 20 | 21 | // 封装post请求 22 | export const post = (url, data = {}) => { 23 | return new Promise((resolve, reject) => { 24 | instance.post(url, data, { 25 | headers: { 26 | 'Content-Type': 'application/json' 27 | } 28 | }).then((response) => { 29 | resolve(response.data) 30 | }, err => { 31 | reject(err) 32 | }) 33 | }) 34 | } 35 | -------------------------------------------------------------------------------- /src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 149 | 150 | --------------------------------------------------------------------------------