vue-youtube-embed
vue-youtube-embed copied to clipboard
Cannot read property 'src' of null at W.g.C (https://s.ytimg.com/yts/jsbin/www-widgetapi-vflQKB5wA/www-widgetapi.js:121:84)
the player works great when i first load the component, but fails to play videos when component is destroyed and mounted again (that's what i think... ) in my site i use a router-view, when navigating to the player component the first time it works great, but if i go back to the home page and then forward again to the player component i get this error:
Cannot read property 'src' of null
this is the full stack trace
www-widgetapi.js:121 Uncaught TypeError: Cannot read property 'src' of null at W.g.C (https://s.ytimg.com/yts/jsbin/www-widgetapi-vflQKB5wA/www-widgetapi.js:121:84) at V (https://s.ytimg.com/yts/jsbin/www-widgetapi-vflQKB5wA/www-widgetapi.js:113:99) at W.(anonymous function).getCurrentTime.Mb.(anonymous function) [as loadVideoById] (https://s.ytimg.com/yts/jsbin/www-widgetapi-vflQKB5wA/www-widgetapi.js:130:11) at VueComponent.play (eval at
(http://localhost:8080/app.js:1037:1), :136:31) at VueComponent.boundFn [as play] (eval at (http://localhost:8080/app.js:729:1), :165:14) at Vue$3.eval (eval at (http://localhost:8080/app.js:1037:1), :73:18) at Vue$3.Vue.$emit (eval at (http://localhost:8080/app.js:729:1), :2207:16) at VueComponent.playSong (eval at (http://localhost:8080/app.js:1058:1), :123:73) at boundFn (eval at (http://localhost:8080/app.js:729:1), :165:14) at Proxy.invoker (eval at (http://localhost:8080/app.js:729:1), :1738:18)
the player seems to be fine, i only get this error when trying to play a video using the loadVideoById method
you can look at the error yourself in my site (WIP) https://mixtape-app.herokuapp.com/#/
- create a new station
- in the text input below the player you can search for youtube video, search for a video and click on it in the search results to add it to the playlist,
- you can now click on it in the playlist to play it.
- click the back button to go back to the main page.
- now go forward again to return to the station you created.
- trying to play the video again will produce the error.
any ideas??
i eventually solved this by just keeping the player component on all the time using v-show instead of v-if, hope this helps