Results 1 to 4 of 4

Thread: background video not working

  1. #1
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    915
    Thanks
    118
    Thanked 2 Times in 2 Posts

    Default background video not working

    No idea why, but since recent this script doesn't seem to work anymore. It shows the first frame of the video, but doesn't play.

    This is the js:
    Code:
        //background video settings
    	if (matchMedia('(min-width: 640px)').matches) {
    		var videobackground = new $.backgroundVideo($('body'), {
    			"align": "centerXY",
    			"autoplay": 1,
    			"controls": 0,
    			"autohide": 1,
    			"loop": 1,
    			"muted": true,
    			"volume": 0,
    			"width": 1280,
    			"height": 720,
    			"path": "portfolio/videos/",
    			"filename": "namefile",
    			"types": ["mp4"]
    		});		
    	}
    	else
    	{
    		$('body').addClass('no-video');
    	}
    and here: jQuery Background video plugin for jQuery

    You can see it "work" on top of this page: https://brunomazereel.com/

    Could anyone help me out, please?
    Thanks.

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,366
    Thanks
    1
    Thanked 243 Times in 238 Posts

    Default

    Hi there chechu,

    Both Google Chrome and firefox now prevent video and
    audio autoplay unless the muted attribute is included.

    Your basic code should look something like this...

    Code:
    
     <video preload muted autoplay loop>
      <source src="portfolio/videos/sofahost2.mp4" type="video/mp4">
     </video>
    ...for it to play as you desire.

    Of course, you may not be able to set the value in
    the HTML, as you decided, for some strange reason
    to use javascript to display it and the javascript is
    ignoring this...

    Code:
    
        //background video settings
    	if (matchMedia('(min-width: 640px)').matches) {
    		var videobackground = new $.backgroundVideo($('body'), {
    			"align": "centerXY",
    			"autoplay": 1,
    			"controls": 0,
    			"autohide": 1,
    			"loop": 1,
    			"muted": true,
    			"volume": 0,
    			"width": 1280,
    			"height": 720,
    			"path": "portfolio/videos/",
    			"filename": "namefile",
    			"types": ["mp4"]
    		});		
    	}
    	else
    	{
    		$('body').addClass('no-video');
    	}
    To get round this use this instead...

    Code:
    
        //background video settings
    	if (matchMedia('(min-width: 640px)').matches) {
    		var videobackground = new $.backgroundVideo($('body'), {
    			"align": "centerXY",
    			"autoplay": 1,
    			"controls": 0,
    			"autohide": 1,
    			"loop": 1,
    			"volume": 0,
    			"width": 1280,
    			"height": 720,
    			"path": "portfolio/videos/",
    			"filename": "sofahost2",
    			"types": ["mp4"]
    		});	
                document.getElementById( 'video_background' ).muted = true ;	
    	}
    	else
    	{
    		$('body').addClass('no-video');
    	}

    coothead
    Last edited by coothead; 08-17-2019 at 05:57 PM.
    ~ the original bald headed old fart ~

  3. The Following User Says Thank You to coothead For This Useful Post:

    chechu (08-18-2019)

  4. #3
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    915
    Thanks
    118
    Thanked 2 Times in 2 Posts

  5. #4
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,366
    Thanks
    1
    Thanked 243 Times in 238 Posts

    Default


    No problem, you're very welcome.

    coothead
    ~ the original bald headed old fart ~

Similar Threads

  1. video not working in IE
    By gib65 in forum HTML
    Replies: 2
    Last Post: 03-17-2015, 08:58 PM
  2. Background Image Carousel background-size: cover; is not working
    By kerriluo in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 02-12-2012, 10:38 PM
  3. Replies: 3
    Last Post: 02-11-2011, 01:46 PM
  4. Working with Flash Video
    By btelecky in forum Flash
    Replies: 4
    Last Post: 03-12-2009, 01:56 PM
  5. Replies: 3
    Last Post: 09-24-2006, 07:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •