Comments (3)
@rob030 If you are using the latest version you should use:
player = new MediaElementPlayer('videoPlayer');
because your code has a typo.
This is the code I tried and worked for me (FYI, you don't need jQuery for the player anymore):
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="../build/mediaelementplayer.css" />
<script src="../build/mediaelement-and-player.js"></script>`
<script type="text/javascript">
// global for movie player
var player;
document.addEventListener('DOMContentLoaded', function() {
player = new MediaElementPlayer('videoPlayer');
});
function ChangeVideo(vid) {
var newSrc = '';
switch (vid) {
case 1:
newSrc = 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4';
break;
case 2:
newSrc = 'https://media.w3.org/2010/05/sintel/trailer.mp4';
break;
case 3:
newSrc = 'https://www.youtube.com/watch?v=twYp6W6vt2U';
break;
}
player.setSrc(newSrc);
player.load();
player.play();
return false;
}
</script>
</head>
<body>
<div style="width: 800px;height:600px">
<video id="videoPlayer" style="width:100%; height:100%;" src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" width="100%" height="100%"></video>
</div>
<a href="#" onclick="return ChangeVideo(1)">video 1</a><br />
<a href="#" onclick="return ChangeVideo(2)">video 2</a><br />
<a href="#" onclick="return ChangeVideo(3)">video 3</a>
</body>
</html>
Let me know if it works for you and please star both https://github.com/mediaelement/mediaelement and https://github.com/mediaelement/mediaelement-plugins to continue improving the package and giving it more popularity; also tell your friends/coworkers/etc. that have a GitHub account to do the same to support the project, if you don't mind. It would be greatly appreciated it.
from mediaelement-plugins.
Hi Rafael,
That works very well. Days and days I have spent trying to sort this and the demo. You are a star. Thankyou very very much.
I really appreciate it.
Will definitely be starring both. When I have finished my project and all works well, mediaelement will be getting alot of publicity. I always use mediaelement for any websites that I built that require video.
Again, thanks Rafael
Cheers
Rob
from mediaelement-plugins.
Great. We really want more people to star the project. We don't ask for anything but that. If you can help us with that, that would be awesome. It is good to know that this worked for you. :)
from mediaelement-plugins.
Related Issues (20)
- mediaelementjs marker plugins not working with youtube link or embed HOT 1
- how do i add a subtitle in a11y plugin HOT 1
- Picture-in-Picture plugin isn't build like other plugins ? HOT 1
- Add audio track switcher HOT 1
- Picture-in-Picture don't work when Player is load m3u8 LiveBroadcast
- Quality plugin plays mp4 first by default (2nd <source>) and only switches source once. HOT 2
- Error on building Player using playlist plugin on safari
- Quality switch doesn't work with m3u8 file HOT 1
- Audio description in a11y not working for external YouTube videos
- End behavior differs depending on during-play action
- Broken Controls display
- Timeslider disappearing with individual settings
- Audio file storage
- mediaelement Web site problems HOT 1
- Help in Ads plugin to run on specific event HOT 10
- Player SBS, TaB (3D) to anaglyph or VR
- Playlist plugin fails at the end of playlist run
- Playlist fails to play next audio after first ends HOT 1
- Change color of audio player
- HLS Quality Selection
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mediaelement-plugins.