Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSaqib Ishfaq
13,912 Pointswhat am doing i wrong? setting different options for player won't work:/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Video and Audio</title>
<link rel="stylesheet" href="css/normalize.css">
<link href='http://fonts.googleapis.com/css?family=Nunito:400,300' rel='stylesheet' type='text/css'>
<link href="css/mediaelementplayer.css" rel="stylesheet">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<h1>HTML Video and Audio</h1>
<div class="videoWrapper">
<h2>Video Example</h2>
<video width="852" height="480">
<source src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.mp4" type="video/mp4">
<source src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.ogg" type="video/ogg">
<track label="English" kind="subtitles" srclang="en" src="bridge-captions.vtt" default>
</video>
</div>
<div class="audioWrapper">
<h2>Audio Example</h2>
<audio>
<source src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge-audio.mp3" type="audio/mp3">
</audio>
</div>
<script
src="http://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous">
</script>
<script>
$('video', 'audio').mediaelementplayer({
features: ['playpause', 'tracks', 'progress'],
startLanguage: 'en'
});
</script>
<script src="js/mediaelement-and-player.min.js"></script>
</body>
</html>
Xayaseth Boudsady
21,951 PointsTry rearranging your script elements.
jQuery First, mediaelement-and-player.min.js , 2nd and your custom <script> element last.
Your script might be trying to use a function/method from the 2nd script library.
Xayaseth Boudsady
21,951 PointsAlso, what Steven Parker said, add "controls" property to your <video> and <audio> element.
Saqib Ishfaq
13,912 PointsXayaseth Boudsady i tried rearranging that with every way possible, and i did what you suggested ,but that hasn't worked either.
Saqib Ishfaq
13,912 PointsXayaseth Boudsady Steven Parker figured it out, it was my custom jquery code causing the issue.instead of this>>> $('video', 'audio') it should be $('video, audio') as soon as i did that it worked just fine :)
1 Answer
Steven Parker
231,169 PointsDid you intend to have controls for the players? I didn't see the "controls" property on the audio and video elements. Otherwise, you probably need to load the mediaelement library before you try to use it. But if there's some problem with the external package it's not possible to diagnose just from this code.
To facilitate a complete analysis, make a snapshot of your workspace and post the link to it here.
Saqib Ishfaq
13,912 PointsSteven Parker i added controls to the video and audio but its the same default controls, what i am trying to do here with that custom script jquery code is to have the same consistent look across all the browsers, that's what joel is doing in the video so, he removed the controls from audio and video and added this code!!!
Steven Parker
231,169 PointsI understood the objective, but I was not able to observe the symptom directly without the snapshot.
It sounds like you spotted the problem with the selector syntax and fixed it already.
Saqib Ishfaq
13,912 PointsSaqib Ishfaq
13,912 PointsXayaseth Boudsady can you have a look please if you free :) Thanks in advance