Cannot read properties of undefined (reading 'params'), Vue3
See original GitHub issueIssue Description
Description
When using wavesurfer plugin, it seems the surfer never gets initiated which result in params not found within the wavesurfermiddleware.
Steps to reproduce
Vue component file
<template>
<div id="media-canvas" class="relative">
<video class="video-js vjs-default-skin" id="media-player" playsinline>
<source v-for="media of medias" :key="media.media_path" :src="media.media_path">
</video>
</div>
</template>
<script>
import videojs from 'video.js';
import WaveSurfer from 'wavesurfer.js';
import wavesurfer from 'videojs-wavesurfer';
export default {
props: ['medias'],
data() {
return {
player : null,
playing : false,
mediaConfig: {//https://github.com/videojs/video.js/blob/master/docs/guides/options.md
controls : true,
bigPlayButton: false,
loop : false,
autoplay : false,
fluid : true,
controlBar: {
deviceButton : false,
pipToggle : false,
recordToggle : false,
fullscreenToggle: false
},
plugins : {
wavesurfer: { //https://wavesurfer-js.org/docs/options.html
backend : 'WebAudio',
displayMilliseconds: true,
debug : true,
waveColor : '#c2ebff',
progressColor : 'black',
cursorWidth : 2,
hideScrollbar : true
}
}
}
}
},
mounted() {
toast.loading();
this.initMedia().then(()=>toast.hide_loading());
},
beforeUnmount() {
if (this.player) {
this.player.dispose();
}
},
methods: {
initMedia() {
return new Promise((resolve, reject) => {
try {
if (this.player) {
this.player.dispose();
}
this.player = videojs('#media-player', this.mediaConfig);
this.player.on('deviceReady', () => {
this.loading = false;
this.ready = true;
});
this.player.on('error', (element, error) => {
this.mediaError.push(error);
});
resolve();
} catch (e) {
reject(e);
}
});
}
}
}
</script>
Results
Expected
Please describe what you expected to see. wavesufer should display
Actual
when using the component and loading a webm file via the medias prop.getting error The error is coming from videojs.wavesurfer.js -> WavesurferMiddleware()-> var backend=this.player.wavesurfer().surfer.params.backend;
Seems wavesurfer().sufer is undefined.
Error output
Uncaught TypeError: Cannot read properties of undefined (reading 'params')
at Object.setSource (videojs.wavesurfer.js?66e3:144:1)
at setSourceHelper (video.es.js?31bb:10175:1)
at setSourceHelper (video.es.js?31bb:10193:1)
at Player.eval (video.es.js?31bb:9931:1)
at eval (video.es.js?31bb:5140:1)
Versions
videojs/wavesurfer
video.js:7.17 videojs-wavesurfer:3.8.0 wavesurfer.js:6.0.1
Browsers
chrome
OSes
Linux
Issue Analytics
- State:
- Created a year ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Cannot read properties of undefined (reading '$router') ...
Calling this inside a callback function creates a new binding to the this object instead of the Vue object in a regular function...
Read more >Cannot read property '$route' of undefined in vue3 - Get Help
I am following the tutorial on Vue School. It seems okay until using the named routes and params. It renders a blank page...
Read more >Cannot read properties of undefined (reading) in Vue3-Vue.js
[Solved]-Cannot read properties of undefined (reading) in Vue3-Vue.js ... switch the function in forEach for a arrow function. by using 'function' you create...
Read more >cannot read properties of undefined (reading 'router' ...
Here's an example of a JavaScript TypeError: Cannot read property of undefined thrown when a property is attempted to be read on an...
Read more >How to get url params ?
@nakov. Here the message I got :` Copy Code app.js:127994 [Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'query' of undefined"...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I fixed the issue in the guide, please try again.
Looks like vue had a new major release (v5). I followed the guide and ended up with errors while running
npm run serve
. I’ll take a look at the problem later.