问题
I am trying to display an error message according to a specific condition in videojs.Is there any possible way of displaying a message without using any plugin like videojs-errors
?
I have tried using player.error()
but this only print an error in console but i need it on the player.
回答1:
You can use Video.js's inbuilt modal dialog:
player.createModal('Your message here!');
https://docs.videojs.com/tutorial-modal-dialog.html
回答2:
Have you tried creating an HTML element next to the video tag (not inside) and then placing it on the same container as the video tag? With CSS, absolute positioning and z-index you should be able to put it on top of the player itself.
回答3:
Luiz wrote (in his answer": "With CSS, absolute positioning and z-index you should be able to put it on top of the player itself."
I had tried that before myself, but no z-index value would fix the limitation of not seeing it when in full-screen mode. That attempt is here: https://weasel.firmfriends.us/HTMLVideoFromCloud/
But then it occurred to me that the ONE approach that would certainly be visible in full-screen is a VTT sub-titles/captions approach. I completed a prototype for that this morning. It does have a limitation...it works only in browsers that have full VTT support...i.e. Chrome and Opera. Both Firefox and Edge don't correctly implement VTT.)
That new prototype is here: https://weasel.firmfriends.us/DualSubs/
Hope this is helpful.
来源:https://stackoverflow.com/questions/51022671/videojs-displaying-a-custom-message-without-using-any-plugin