Clean up
This commit is contained in:
		@ -1,7 +1,7 @@
 | 
				
			|||||||
# Changelog
 | 
					# Changelog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# v1.5.0
 | 
					# v1.5.0
 | 
				
			||||||
- *Beta* Vimeo support (please report bugs) (fixes #8)
 | 
					- Vimeo support (fixes #8)
 | 
				
			||||||
- New options for initialization (you can now pass a selector, HTMLElement or NodeList) (fixes #118)
 | 
					- New options for initialization (you can now pass a selector, HTMLElement or NodeList) (fixes #118)
 | 
				
			||||||
- Switched to BEM methodology (you will need to change CSS and probably HTML)
 | 
					- Switched to BEM methodology (you will need to change CSS and probably HTML)
 | 
				
			||||||
- Decoupled CSS and JS hooks (fixes #129)
 | 
					- Decoupled CSS and JS hooks (fixes #129)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								dist/plyr.css
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/plyr.css
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								dist/plyr.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/plyr.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								docs/dist/docs.css
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/dist/docs.css
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -20,12 +20,12 @@
 | 
				
			|||||||
            <nav>
 | 
					            <nav>
 | 
				
			||||||
                <ul>
 | 
					                <ul>
 | 
				
			||||||
                    <li>
 | 
					                    <li>
 | 
				
			||||||
                        <a href="https://github.com/selz/plyr" target="_blank" class="btn btn--primary" data-shr-network="github">
 | 
					                        <a href="https://github.com/selz/plyr" target="_blank" class="btn btn--large btn--primary" data-shr-network="github">
 | 
				
			||||||
                            <svg class="icon"><use xlink:href="#icon-github"/></svg>Download on GitHub
 | 
					                            <svg class="icon"><use xlink:href="#icon-github"/></svg>Download on GitHub
 | 
				
			||||||
                        </a>
 | 
					                        </a>
 | 
				
			||||||
                    </li>
 | 
					                    </li>
 | 
				
			||||||
                    <li>
 | 
					                    <li>
 | 
				
			||||||
                        <a href="https://twitter.com/intent/tweet?text=A+simple+HTML5+media+player+with+custom+controls+and+WebVTT+captions.&url=http%3A%2F%2Fplyr.io&via=Sam_Potts" target="_blank" class="btn btn--twitter" data-shr-network="twitter">
 | 
					                        <a href="https://twitter.com/intent/tweet?text=A+simple+HTML5+media+player+with+custom+controls+and+WebVTT+captions.&url=http%3A%2F%2Fplyr.io&via=Sam_Potts" target="_blank" class="btn btn--large btn--twitter" data-shr-network="twitter">
 | 
				
			||||||
                            <svg class="icon"><use xlink:href="#icon-twitter"/></svg>Tweet
 | 
					                            <svg class="icon"><use xlink:href="#icon-twitter"/></svg>Tweet
 | 
				
			||||||
                        </a>
 | 
					                        </a>
 | 
				
			||||||
                    </li>
 | 
					                    </li>
 | 
				
			||||||
@ -46,7 +46,7 @@
 | 
				
			|||||||
                        <button type="button" class="btn btn--youtube" data-source="youtube"><svg class="icon"><use xlink:href="#icon-youtube"/></svg>YouTube</button>
 | 
					                        <button type="button" class="btn btn--youtube" data-source="youtube"><svg class="icon"><use xlink:href="#icon-youtube"/></svg>YouTube</button>
 | 
				
			||||||
                    </li>
 | 
					                    </li>
 | 
				
			||||||
                    <li>
 | 
					                    <li>
 | 
				
			||||||
                        <button type="button" class="btn btn--vimeo" data-source="vimeo"><svg class="icon"><use xlink:href="#icon-vimeo"/></svg>Vimeo <sup>BETA</sup></button>
 | 
					                        <button type="button" class="btn btn--vimeo" data-source="vimeo"><svg class="icon"><use xlink:href="#icon-vimeo"/></svg>Vimeo</button>
 | 
				
			||||||
                    </li>
 | 
					                    </li>
 | 
				
			||||||
                </ul>
 | 
					                </ul>
 | 
				
			||||||
            </nav>
 | 
					            </nav>
 | 
				
			||||||
 | 
				
			|||||||
@ -98,13 +98,14 @@ nav {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Buttons
 | 
					// Buttons
 | 
				
			||||||
.btn {
 | 
					.btn {
 | 
				
			||||||
	padding: (@padding-base / 2) @padding-base;
 | 
						padding: (@padding-base / 2) ((@padding-base / 2) + 2);
 | 
				
			||||||
	background: linear-gradient(lighten(@body-background, 2%), darken(@body-background, 3%));
 | 
						background: linear-gradient(lighten(@body-background, 2%), darken(@body-background, 3%));
 | 
				
			||||||
	border: 1px solid @gray-light;
 | 
						border: 1px solid @gray-light;
 | 
				
			||||||
	box-shadow: 0 1px 1px rgba(0,0,0, .05);
 | 
						box-shadow: 0 1px 1px rgba(0,0,0, .05);
 | 
				
			||||||
	text-shadow: 0 1px 1px #fff;
 | 
						text-shadow: 0 1px 1px #fff;
 | 
				
			||||||
	color: @gray;
 | 
						color: @gray;
 | 
				
			||||||
	transition: background .1s ease, color .1s ease;
 | 
						transition: background .1s ease, color .1s ease;
 | 
				
			||||||
 | 
						.font-size(@font-size-small);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	&:hover,
 | 
						&:hover,
 | 
				
			||||||
	&:focus {
 | 
						&:focus {
 | 
				
			||||||
@ -112,16 +113,15 @@ nav {
 | 
				
			|||||||
		color: @gray;
 | 
							color: @gray;
 | 
				
			||||||
		outline: 0;
 | 
							outline: 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	&--youtube .icon {
 | 
					 | 
				
			||||||
		color: @color-youtube;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	&--vimeo .icon {
 | 
					 | 
				
			||||||
		color: @color-vimeo;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	&--twitter .icon {
 | 
					 | 
				
			||||||
		color: @color-twitter;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Sizes
 | 
				
			||||||
 | 
					.btn--large {
 | 
				
			||||||
 | 
						padding: (@padding-base / 2) @padding-base;
 | 
				
			||||||
 | 
						.font-size();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Styles
 | 
				
			||||||
.btn--primary {
 | 
					.btn--primary {
 | 
				
			||||||
	background-image: linear-gradient(@link-color, darken(@link-color, 5%));
 | 
						background-image: linear-gradient(@link-color, darken(@link-color, 5%));
 | 
				
			||||||
	background-color: @link-color;
 | 
						background-color: @link-color;
 | 
				
			||||||
@ -136,9 +136,14 @@ nav {
 | 
				
			|||||||
		border-color: darken(@link-color, 20%);
 | 
							border-color: darken(@link-color, 20%);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
.btn--small {
 | 
					.btn--youtube .icon {
 | 
				
			||||||
	padding-top: ceil(@padding-base / 3);
 | 
						color: @color-youtube;
 | 
				
			||||||
	padding-bottom: ceil(@padding-base / 3);
 | 
					}
 | 
				
			||||||
 | 
					.btn--vimeo .icon {
 | 
				
			||||||
 | 
						color: @color-vimeo;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					.btn--twitter .icon {
 | 
				
			||||||
 | 
						color: @color-twitter;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Count bubble
 | 
					// Count bubble
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,8 @@
 | 
				
			|||||||
video,
 | 
					video,
 | 
				
			||||||
.plyr__video-embed {
 | 
					.plyr__video-embed {
 | 
				
			||||||
    border-radius: @border-radius-base;
 | 
					    border-radius: @border-radius-base;
 | 
				
			||||||
 | 
					    max-width: 100%;
 | 
				
			||||||
 | 
					    vertical-align: middle;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
.plyr__video-embed {
 | 
					.plyr__video-embed {
 | 
				
			||||||
    -webkit-mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
 | 
					    -webkit-mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
 | 
				
			||||||
 | 
				
			|||||||
@ -20,3 +20,7 @@ a .icon,
 | 
				
			|||||||
.btn .icon {
 | 
					.btn .icon {
 | 
				
			||||||
	margin-right: (@padding-base / 2);
 | 
						margin-right: (@padding-base / 2);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					.btn:not(.btn-large) .icon {
 | 
				
			||||||
 | 
						width: (@icon-size - 2);
 | 
				
			||||||
 | 
						height: (@icon-size - 2);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,7 @@ h2 {
 | 
				
			|||||||
    .font-smoothing();
 | 
					    .font-smoothing();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
h1 {
 | 
					h1 {
 | 
				
			||||||
    .font-size(64);
 | 
					    .font-size(@font-size-h1);
 | 
				
			||||||
    color: #3498DB;
 | 
					    color: #3498DB;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -24,11 +24,7 @@ small {
 | 
				
			|||||||
small {
 | 
					small {
 | 
				
			||||||
    display: block;
 | 
					    display: block;
 | 
				
			||||||
    padding: 0 (@padding-base / 2);
 | 
					    padding: 0 (@padding-base / 2);
 | 
				
			||||||
    .font-size(14);
 | 
					    .font-size(@font-size-small);
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
sup {
 | 
					 | 
				
			||||||
    vertical-align: 2px;
 | 
					 | 
				
			||||||
    .font-size(9);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Lists
 | 
					// Lists
 | 
				
			||||||
 | 
				
			|||||||
@ -18,6 +18,11 @@
 | 
				
			|||||||
// Base
 | 
					// Base
 | 
				
			||||||
@body-background: 			@off-white;
 | 
					@body-background: 			@off-white;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Type
 | 
				
			||||||
 | 
					@font-size-base:            16;
 | 
				
			||||||
 | 
					@font-size-small:           14;
 | 
				
			||||||
 | 
					@font-size-h1:              64;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Elements
 | 
					// Elements
 | 
				
			||||||
@link-color:                @blue;
 | 
					@link-color:                @blue;
 | 
				
			||||||
@padding-base:              20px;
 | 
					@padding-base:              20px;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										184
									
								
								src/js/plyr.js
									
									
									
									
									
								
							
							
						
						
									
										184
									
								
								src/js/plyr.js
									
									
									
									
									
								
							@ -980,6 +980,11 @@
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Toggle style hook
 | 
				
			||||||
 | 
					        function _toggleStyleHook() {
 | 
				
			||||||
 | 
					            _toggleClass(plyr.container, defaults.selectors.container.replace('.', ''), plyr.supported.full);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Setup aria attribute for play and iframe title
 | 
					        // Setup aria attribute for play and iframe title
 | 
				
			||||||
        function _setTitle(iframe) {
 | 
					        function _setTitle(iframe) {
 | 
				
			||||||
            // Find the current text
 | 
					            // Find the current text
 | 
				
			||||||
@ -1136,20 +1141,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // When embeds are ready
 | 
					        // When embeds are ready
 | 
				
			||||||
        function _embedReady() {
 | 
					        function _embedReady() {
 | 
				
			||||||
            // Inject and update UI
 | 
					            // Setup the UI
 | 
				
			||||||
            if (plyr.supported.full) {
 | 
					 | 
				
			||||||
                // Only setup controls once
 | 
					 | 
				
			||||||
                if (!plyr.container.querySelectorAll(config.selectors.controls.wrapper).length) {
 | 
					 | 
				
			||||||
            _setupInterface();
 | 
					            _setupInterface();
 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Set title
 | 
					            // Set title
 | 
				
			||||||
            _setTitle(_getElement('iframe'));
 | 
					            _setTitle(_getElement('iframe'));
 | 
				
			||||||
 | 
					 | 
				
			||||||
            // Set the volume
 | 
					 | 
				
			||||||
            _setVolume();
 | 
					 | 
				
			||||||
            _updateVolume();
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Handle YouTube API ready
 | 
					        // Handle YouTube API ready
 | 
				
			||||||
@ -1165,7 +1161,7 @@
 | 
				
			|||||||
            plyr.embed = new YT.Player(container.id, {
 | 
					            plyr.embed = new YT.Player(container.id, {
 | 
				
			||||||
                videoId: videoId,
 | 
					                videoId: videoId,
 | 
				
			||||||
                playerVars: {
 | 
					                playerVars: {
 | 
				
			||||||
                    autoplay: (config.autoplay ? 1 : 0),
 | 
					                    autoplay: 0,
 | 
				
			||||||
                    controls: (plyr.supported.full ? 0 : 1),
 | 
					                    controls: (plyr.supported.full ? 0 : 1),
 | 
				
			||||||
                    rel: 0,
 | 
					                    rel: 0,
 | 
				
			||||||
                    showinfo: 0,
 | 
					                    showinfo: 0,
 | 
				
			||||||
@ -1196,7 +1192,7 @@
 | 
				
			|||||||
                            plyr.media.paused = true;
 | 
					                            plyr.media.paused = true;
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
                        plyr.media.duration = instance.getDuration();
 | 
					                        plyr.media.duration = instance.getDuration();
 | 
				
			||||||
                        plyr.media.paused = !config.autoplay;
 | 
					                        plyr.media.paused = true;
 | 
				
			||||||
                        plyr.media.currentTime = instance.getCurrentTime();
 | 
					                        plyr.media.currentTime = instance.getCurrentTime();
 | 
				
			||||||
                        plyr.media.muted = instance.isMuted();
 | 
					                        plyr.media.muted = instance.isMuted();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1224,9 +1220,7 @@
 | 
				
			|||||||
                        _embedReady();
 | 
					                        _embedReady();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        // Display duration if available
 | 
					                        // Display duration if available
 | 
				
			||||||
                        if (config.displayDuration) {
 | 
					 | 
				
			||||||
                        _displayDuration();
 | 
					                        _displayDuration();
 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                    'onStateChange': function(event) {
 | 
					                    'onStateChange': function(event) {
 | 
				
			||||||
                        // Get the instance
 | 
					                        // Get the instance
 | 
				
			||||||
@ -1250,6 +1244,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                            case 1:
 | 
					                            case 1:
 | 
				
			||||||
                                plyr.media.paused = false;
 | 
					                                plyr.media.paused = false;
 | 
				
			||||||
 | 
					                                plyr.media.seeking = false;
 | 
				
			||||||
                                _triggerEvent(plyr.media, 'play');
 | 
					                                _triggerEvent(plyr.media, 'play');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                // Poll to get playback progress
 | 
					                                // Poll to get playback progress
 | 
				
			||||||
@ -1259,7 +1254,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                                    // Trigger timeupdate
 | 
					                                    // Trigger timeupdate
 | 
				
			||||||
                                    _triggerEvent(plyr.media, 'timeupdate');
 | 
					                                    _triggerEvent(plyr.media, 'timeupdate');
 | 
				
			||||||
                                }, 200);
 | 
					                                }, 100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                break;
 | 
					                                break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1293,7 +1288,7 @@
 | 
				
			|||||||
                    plyr.embed.api('stop');
 | 
					                    plyr.embed.api('stop');
 | 
				
			||||||
                    plyr.media.paused = true;
 | 
					                    plyr.media.paused = true;
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
                plyr.media.paused = !config.autoplay;
 | 
					                plyr.media.paused = true;
 | 
				
			||||||
                plyr.media.currentTime = 0;
 | 
					                plyr.media.currentTime = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Update UI
 | 
					                // Update UI
 | 
				
			||||||
@ -1310,9 +1305,7 @@
 | 
				
			|||||||
                    plyr.media.duration = value;
 | 
					                    plyr.media.duration = value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // Display duration if available
 | 
					                    // Display duration if available
 | 
				
			||||||
                    if (plyr.supported.full && config.displayDuration) {
 | 
					 | 
				
			||||||
                    _displayDuration();
 | 
					                    _displayDuration();
 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                plyr.embed.addEvent('play', function() {
 | 
					                plyr.embed.addEvent('play', function() {
 | 
				
			||||||
@ -1326,6 +1319,7 @@
 | 
				
			|||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                plyr.embed.addEvent('playProgress', function(data) {
 | 
					                plyr.embed.addEvent('playProgress', function(data) {
 | 
				
			||||||
 | 
					                    plyr.media.seeking = false;
 | 
				
			||||||
                    plyr.media.currentTime = data.seconds;
 | 
					                    plyr.media.currentTime = data.seconds;
 | 
				
			||||||
                    _triggerEvent(plyr.media, 'timeupdate');
 | 
					                    _triggerEvent(plyr.media, 'timeupdate');
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
@ -1352,7 +1346,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Setup captions
 | 
					        // Setup captions
 | 
				
			||||||
        function _setupCaptions() {
 | 
					        function _setupCaptions() {
 | 
				
			||||||
            if (plyr.type === 'video') {
 | 
					            if (plyr.type !== 'video') {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Inject the container
 | 
					            // Inject the container
 | 
				
			||||||
            if (!_getElement(config.selectors.captions)) {
 | 
					            if (!_getElement(config.selectors.captions)) {
 | 
				
			||||||
                plyr.videoContainer.insertAdjacentHTML('afterbegin', '<div class="' + _getClassname(config.selectors.captions) + '"><span></span></div>');
 | 
					                plyr.videoContainer.insertAdjacentHTML('afterbegin', '<div class="' + _getClassname(config.selectors.captions) + '"><span></span></div>');
 | 
				
			||||||
@ -1498,10 +1495,13 @@
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Setup fullscreen
 | 
					        // Setup fullscreen
 | 
				
			||||||
        function _setupFullscreen() {
 | 
					        function _setupFullscreen() {
 | 
				
			||||||
 | 
					            if (!plyr.supported.full) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ((plyr.type != 'audio' || config.fullscreen.allowAudio) && config.fullscreen.enabled) {
 | 
					            if ((plyr.type != 'audio' || config.fullscreen.allowAudio) && config.fullscreen.enabled) {
 | 
				
			||||||
                // Check for native support
 | 
					                // Check for native support
 | 
				
			||||||
                var nativeSupport = fullscreen.supportsFullScreen;
 | 
					                var nativeSupport = fullscreen.supportsFullScreen;
 | 
				
			||||||
@ -1609,24 +1609,28 @@
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            catch(e) {}
 | 
					            catch(e) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Trigger timeupdate for embed and restore pause state
 | 
					            // Embeds
 | 
				
			||||||
            if ('embed' in plyr) {
 | 
					            if(_inArray(config.types.embed, plyr.type)) {
 | 
				
			||||||
                // YouTube
 | 
					                // YouTube
 | 
				
			||||||
                if (plyr.type === 'youtube') {
 | 
					                switch(plyr.type) {
 | 
				
			||||||
 | 
					                    case 'youtube':
 | 
				
			||||||
                        plyr.embed.seekTo(targetTime);
 | 
					                        plyr.embed.seekTo(targetTime);
 | 
				
			||||||
                }
 | 
					                        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Vimeo
 | 
					                    case 'vimeo':
 | 
				
			||||||
                if (plyr.type === 'vimeo') {
 | 
					 | 
				
			||||||
                        plyr.embed.api('seekTo', targetTime);
 | 
					                        plyr.embed.api('seekTo', targetTime);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Trigger timeupdate
 | 
					 | 
				
			||||||
                _triggerEvent(plyr.media, 'timeupdate');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (paused) {
 | 
					                if (paused) {
 | 
				
			||||||
                    _pause();
 | 
					                    _pause();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Trigger timeupdate for embeds
 | 
				
			||||||
 | 
					                _triggerEvent(plyr.media, 'timeupdate');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Set seeking flag
 | 
				
			||||||
 | 
					                plyr.media.seeking = true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Logging
 | 
					            // Logging
 | 
				
			||||||
@ -1754,24 +1758,20 @@
 | 
				
			|||||||
            // Set mute on the player
 | 
					            // Set mute on the player
 | 
				
			||||||
            plyr.media.muted = muted;
 | 
					            plyr.media.muted = muted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Embeds
 | 
				
			||||||
 | 
					            if(_inArray(config.types.embed, plyr.type)) {
 | 
				
			||||||
                // YouTube
 | 
					                // YouTube
 | 
				
			||||||
            if (plyr.type === 'youtube') {
 | 
					                switch(plyr.type) {
 | 
				
			||||||
 | 
					                    case 'youtube':
 | 
				
			||||||
                        plyr.embed[plyr.media.muted ? 'mute' : 'unMute']();
 | 
					                        plyr.embed[plyr.media.muted ? 'mute' : 'unMute']();
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Trigger timeupdate
 | 
					                    case 'vimeo':
 | 
				
			||||||
                _triggerEvent(plyr.media, 'volumechange');
 | 
					                        plyr.embed.api('setVolume', plyr.media.muted ? 0 : parseFloat(config.volume / 10));
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Vimeo
 | 
					                // Trigger volumechange for embeds
 | 
				
			||||||
            if (plyr.type === 'vimeo') {
 | 
					 | 
				
			||||||
                if (plyr.media.muted) {
 | 
					 | 
				
			||||||
                    plyr.embed.api('setVolume', 0);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else {
 | 
					 | 
				
			||||||
                    plyr.embed.api('setVolume', parseFloat(config.volume / 10));
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                // Trigger timeupdate
 | 
					 | 
				
			||||||
                _triggerEvent(plyr.media, 'volumechange');
 | 
					                _triggerEvent(plyr.media, 'volumechange');
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -1803,18 +1803,20 @@
 | 
				
			|||||||
            // Store in config
 | 
					            // Store in config
 | 
				
			||||||
            config.volume = volume;
 | 
					            config.volume = volume;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Embeds
 | 
				
			||||||
 | 
					            if(_inArray(config.types.embed, plyr.type)) {
 | 
				
			||||||
                // YouTube
 | 
					                // YouTube
 | 
				
			||||||
            if (plyr.type === 'youtube') {
 | 
					                switch(plyr.type) {
 | 
				
			||||||
 | 
					                    case 'youtube':
 | 
				
			||||||
                        plyr.embed.setVolume(plyr.media.volume * 100);
 | 
					                        plyr.embed.setVolume(plyr.media.volume * 100);
 | 
				
			||||||
            }
 | 
					                        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Vimeo
 | 
					                    case 'vimeo':
 | 
				
			||||||
            if (plyr.type === 'vimeo') {
 | 
					 | 
				
			||||||
                        plyr.embed.api('setVolume', plyr.media.volume);
 | 
					                        plyr.embed.api('setVolume', plyr.media.volume);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Trigger volumechange for embeds
 | 
					                // Trigger volumechange for embeds
 | 
				
			||||||
            if ('embed' in plyr) {
 | 
					 | 
				
			||||||
                _triggerEvent(plyr.media, 'volumechange');
 | 
					                _triggerEvent(plyr.media, 'volumechange');
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1970,6 +1972,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Show the duration on metadataloaded
 | 
					        // Show the duration on metadataloaded
 | 
				
			||||||
        function _displayDuration() {
 | 
					        function _displayDuration() {
 | 
				
			||||||
 | 
					            if (!plyr.supported.full) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var duration = plyr.media.duration || 0;
 | 
					            var duration = plyr.media.duration || 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // If there's only one time display, display duration there
 | 
					            // If there's only one time display, display duration there
 | 
				
			||||||
@ -1988,6 +1994,11 @@
 | 
				
			|||||||
            // Duration
 | 
					            // Duration
 | 
				
			||||||
            _updateTimeDisplay(plyr.media.currentTime, plyr.currentTime);
 | 
					            _updateTimeDisplay(plyr.media.currentTime, plyr.currentTime);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Ignore updates while seeking
 | 
				
			||||||
 | 
					            if(event && event.type == 'timeupdate' && plyr.media.seeking) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Playing progress
 | 
					            // Playing progress
 | 
				
			||||||
            _updateProgress(event);
 | 
					            _updateProgress(event);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -2041,7 +2052,7 @@
 | 
				
			|||||||
                window.clearInterval(plyr.timer.buffering);
 | 
					                window.clearInterval(plyr.timer.buffering);
 | 
				
			||||||
                window.clearInterval(plyr.timer.playing);
 | 
					                window.clearInterval(plyr.timer.playing);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else if (plyr.type === 'video') {
 | 
					            else if (plyr.type === 'video' && plyr.videoContainer) {
 | 
				
			||||||
                // Remove video wrapper
 | 
					                // Remove video wrapper
 | 
				
			||||||
                _remove(plyr.videoContainer);
 | 
					                _remove(plyr.videoContainer);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -2105,6 +2116,7 @@
 | 
				
			|||||||
            // Restore class hooks
 | 
					            // Restore class hooks
 | 
				
			||||||
            _toggleClass(plyr.container, config.classes.fullscreen.active, plyr.isFullscreen);
 | 
					            _toggleClass(plyr.container, config.classes.fullscreen.active, plyr.isFullscreen);
 | 
				
			||||||
            _toggleClass(plyr.container, config.classes.captions.active, plyr.captionsEnabled);
 | 
					            _toggleClass(plyr.container, config.classes.captions.active, plyr.captionsEnabled);
 | 
				
			||||||
 | 
					            _toggleStyleHook();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Autoplay the new source?
 | 
					            // Autoplay the new source?
 | 
				
			||||||
            config.autoplay = (source.autoplay || config.autoplay);
 | 
					            config.autoplay = (source.autoplay || config.autoplay);
 | 
				
			||||||
@ -2117,41 +2129,29 @@
 | 
				
			|||||||
            // Set up from scratch
 | 
					            // Set up from scratch
 | 
				
			||||||
            _setupMedia();
 | 
					            _setupMedia();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Trigger media updated
 | 
					 | 
				
			||||||
            _mediaUpdated();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // HTML5 stuff
 | 
					            // HTML5 stuff
 | 
				
			||||||
            if (_inArray(config.types.html5, plyr.type)) {
 | 
					            if (_inArray(config.types.html5, plyr.type)) {
 | 
				
			||||||
                // Set volume
 | 
					 | 
				
			||||||
                _setVolume();
 | 
					 | 
				
			||||||
                _updateVolume();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                // UI updates
 | 
					 | 
				
			||||||
                if (plyr.supported.full) {
 | 
					 | 
				
			||||||
                    // Reset time display
 | 
					 | 
				
			||||||
                    _timeUpdate();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    // Update the UI
 | 
					 | 
				
			||||||
                    _checkPlaying();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                // Setup captions
 | 
					                // Setup captions
 | 
				
			||||||
                if ('tracks' in source) {
 | 
					                if ('tracks' in source) {
 | 
				
			||||||
                    _insertChildElements('track', source.tracks);
 | 
					                    _insertChildElements('track', source.tracks);
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    // Captions
 | 
					 | 
				
			||||||
                    _setupCaptions();
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Load HTML5 sources
 | 
					                // Load HTML5 sources
 | 
				
			||||||
                plyr.media.load();
 | 
					                plyr.media.load();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Display duration if available
 | 
				
			||||||
 | 
					                _displayDuration();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Setup interface
 | 
				
			||||||
 | 
					                _setupInterface();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Play if autoplay attribute is present
 | 
					            // Play if autoplay attribute is present
 | 
				
			||||||
            if (config.autoplay) {
 | 
					            if (config.autoplay) {
 | 
				
			||||||
                _play();
 | 
					                _play();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Set aria title and iframe title
 | 
				
			||||||
            if ('title' in source) {
 | 
					            if ('title' in source) {
 | 
				
			||||||
                config.title = source.title;
 | 
					                config.title = source.title;
 | 
				
			||||||
                _setTitle();
 | 
					                _setTitle();
 | 
				
			||||||
@ -2376,9 +2376,6 @@
 | 
				
			|||||||
            // Get the media element
 | 
					            // Get the media element
 | 
				
			||||||
            plyr.media = plyr.container.querySelectorAll('audio, video, div')[0];
 | 
					            plyr.media = plyr.container.querySelectorAll('audio, video, div')[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Add style hook
 | 
					 | 
				
			||||||
            _toggleClass(plyr.container, defaults.selectors.container.replace('.', ''), true);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // Get original classname
 | 
					            // Get original classname
 | 
				
			||||||
            plyr.originalClassName = plyr.container.className;
 | 
					            plyr.originalClassName = plyr.container.className;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2403,6 +2400,9 @@
 | 
				
			|||||||
            // Check for full support
 | 
					            // Check for full support
 | 
				
			||||||
            plyr.supported = api.supported(plyr.type);
 | 
					            plyr.supported = api.supported(plyr.type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Add style hook
 | 
				
			||||||
 | 
					            _toggleStyleHook();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // If no native support, bail
 | 
					            // If no native support, bail
 | 
				
			||||||
            if (!plyr.supported.basic) {
 | 
					            if (!plyr.supported.basic) {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
@ -2415,7 +2415,7 @@
 | 
				
			|||||||
            _setupMedia();
 | 
					            _setupMedia();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Setup interface
 | 
					            // Setup interface
 | 
				
			||||||
            if (plyr.type == 'video' || plyr.type == 'audio') {
 | 
					            if (_inArray(config.types.html5, plyr.type)) {
 | 
				
			||||||
                // Bail if no support
 | 
					                // Bail if no support
 | 
				
			||||||
                if (!plyr.supported.full) {
 | 
					                if (!plyr.supported.full) {
 | 
				
			||||||
                    // Successful setup
 | 
					                    // Successful setup
 | 
				
			||||||
@ -2428,11 +2428,6 @@
 | 
				
			|||||||
                // Setup UI
 | 
					                // Setup UI
 | 
				
			||||||
                _setupInterface();
 | 
					                _setupInterface();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Display duration if available
 | 
					 | 
				
			||||||
                if (config.displayDuration) {
 | 
					 | 
				
			||||||
                    _displayDuration();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                // Set title on button and frame
 | 
					                // Set title on button and frame
 | 
				
			||||||
                _setTitle();
 | 
					                _setTitle();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -2442,31 +2437,40 @@
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        function _setupInterface() {
 | 
					        function _setupInterface() {
 | 
				
			||||||
 | 
					            // Don't setup interface if no support
 | 
				
			||||||
 | 
					            if (!plyr.supported.full) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Inject custom controls
 | 
				
			||||||
 | 
					            if (!plyr.container.querySelectorAll(config.selectors.controls.wrapper).length) {
 | 
				
			||||||
                // Inject custom controls
 | 
					                // Inject custom controls
 | 
				
			||||||
                _injectControls();
 | 
					                _injectControls();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Find the elements
 | 
					            // Find the elements
 | 
				
			||||||
            if (!_findElements()) {
 | 
					            if (!_findElements()) {
 | 
				
			||||||
                return false;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Captions
 | 
					 | 
				
			||||||
            _setupCaptions();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // Media updated
 | 
					 | 
				
			||||||
            _mediaUpdated();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // Set volume
 | 
					 | 
				
			||||||
            _setVolume();
 | 
					 | 
				
			||||||
            _updateVolume();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        function _mediaUpdated() {
 | 
					 | 
				
			||||||
            // Setup fullscreen
 | 
					            // Setup fullscreen
 | 
				
			||||||
            _setupFullscreen();
 | 
					            _setupFullscreen();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Listeners
 | 
					            // Listeners
 | 
				
			||||||
            _listeners();
 | 
					            _listeners();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Captions
 | 
				
			||||||
 | 
					            _setupCaptions();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Set volume
 | 
				
			||||||
 | 
					            _setVolume();
 | 
				
			||||||
 | 
					            _updateVolume();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Reset time display
 | 
				
			||||||
 | 
					            _timeUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Update the UI
 | 
				
			||||||
 | 
					            _checkPlaying();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Initialize instance
 | 
					        // Initialize instance
 | 
				
			||||||
 | 
				
			|||||||
@ -583,7 +583,7 @@
 | 
				
			|||||||
    // Hide sound controls on iOS
 | 
					    // Hide sound controls on iOS
 | 
				
			||||||
    // It's not supported to change volume using JavaScript:
 | 
					    // It's not supported to change volume using JavaScript:
 | 
				
			||||||
    // https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html
 | 
					    // https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html
 | 
				
			||||||
    &--is-ios &-volume,
 | 
					    &--is-ios &__volume,
 | 
				
			||||||
    &--is-ios [data-plyr='mute'],
 | 
					    &--is-ios [data-plyr='mute'],
 | 
				
			||||||
    &--is-ios.plyr--audio &__controls--right {
 | 
					    &--is-ios.plyr--audio &__controls--right {
 | 
				
			||||||
        display: none;
 | 
					        display: none;
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user