0

To start, i don't know if this is the right category for it. If not please tell me.

I'm making a website that is basically a big automatic powerpoint presentation.

I load in all the images and videos, and show them 1 by 1.

However i have a problem...

It was al working well in the beginning. But now i'm about 60% done of filling in all the photos and videos. And now my videos wont load in to the website anymore.

I went on and checked the Network traffic, and saw the following:

Network Traffic

As you can see, it loads all of the images (Wich is true because that is the only thing is see). And it cancels all the Media (Wich is also true because i only get a black screen then).

Is there a way to add a delay to what the browser gets?

For example one Slide is minimal 6 seconds long. And in those 6 seconds i only show 1 image. but the website asks for all of them to load.

If you want to see the code, below here is an short version. However you might not need that.

The code i have for the slideshow (A short version)

<!DOCTYPE html>
<html>
    <head>
        <title>VASIG | Innotrans 2016</title>
        <link rel="stylesheet" href="Css/style.css">
        <script src="scripts/jquery-3.1.1.min.js"></script>
    </head>
    <body>
        <div id="wrapper">
            <div id="background">
<!--
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@ High Speed @@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-->
        <!--
        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        @@@@@@ Asset Optimization @@@@@@
        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        -->
                <div class="slide" data-timing=12 data-fadein=0.5 data-fadeout=0.5>
                    <div id="begin">
                        Asset Optimization<br />
                        <b>Condition Based Wheelset Maintenance Planning</b>
                    </div>
                </div>
                <div class="slide" data-timing=16 data-fadein=0.5 data-fadeout=1 data-videopause=false>
                    <header>Asset Optimization - Condition Based Wheelset Maintenance Planning</header>
                    <video autoplay>
                        <source src="media/I_High_Speed/I_3/I-3_HighSpeed_01.mp4" type="video/mp4">
                    </video>
                </div>
                <div class="slide" data-timing=6 data-fadein=0.5 data-fadeout=0.5>
                    <header>Asset Optimization - Condition Based Wheelset Maintenance Planning</header>
                    <img src="media/I_High_Speed/I_3/HighSpeed-I-3-1_Wheelset-maint_set-summary.png" />
                </div>
                <div class="slide" data-timing=6 data-fadein=0.5 data-fadeout=0.5>
                    <header>Asset Optimization - Condition Based Wheelset Maintenance Planning</header>
                    <img src="media/I_High_Speed/I_3/HighSpeed-I-3-2_Wheelset-maint_set-configuration.png" />
                </div>
                <div class="slide" data-timing=21 data-fadein=0.5 data-fadeout=0.5 data-videopause=true>
                    <header>Asset Optimization - Condition Based Wheelset Maintenance Planning</header>
                    <video autoplay>
                        <source src="media/I_High_Speed/I_3/I-3_HighSpeed_03.mp4" type="video/mp4">
                    </video>
                </div>
                <div class="slide" data-timing=6 data-fadein=0.5 data-fadeout=0.5>
                    <header>Asset Optimization - Condition Based Wheelset Maintenance Planning</header>
                    <img src="media/I_High_Speed/I_3/HighSpeed-I-3-3_Wheelset-details.png" />
                </div>
                <div class="slide" data-timing=6 data-fadein=0.5 data-fadeout=0.5>
                    <header>Asset Optimization - Condition Based Wheelset Maintenance Planning</header>
                    <img src="media/I_High_Speed/I_3/HighSpeed-I-3-4_Maintain-axles.png" />
                </div>
                <div class="slide" data-timing=19 data-fadein=0.5 data-fadeout=0.5 data-videopause=true>
                    <header>Asset Optimization - Condition Based Wheelset Maintenance Planning</header>
                    <video autoplay>
                        <source src="media/I_High_Speed/I_3/I-3_HighSpeed_02.mp4" type="video/mp4">
                    </video>
                </div>
                <div class="slide" data-timing=6 data-fadein=0.5 data-fadeout=0.5>
                    <header>Asset Optimization - Condition Based Wheelset Maintenance Planning</header>
                    <img src="media/I_High_Speed/I_3/HighSpeed-I-3-5_Wheelset-detail-after-turn-of-axle.png" />
                </div>
                <div class="slide" data-timing=6 data-fadein=0.5 data-fadeout=0.5>
                    <header>Asset Optimization - Condition Based Wheelset Maintenance Planning</header>
                    <img src="media/I_High_Speed/I_3/I_3-Conclusion.png" />
                </div>
           </div><!--Background-->
      </div><!--wrapper-->

And the script:

       <script type="text/javascript">
            var slides = $(".slide");
            var lastSlideIndex = slides.length-1;
            var currentSlideIndex = 0;
            var defaultTiming = 1000;
            var defaultFadeInTime = 1000;
            var defaultFadeOutTime = 1000;



            // Show slide function
            function showSlide() {

                var thisSlide = slides.eq(currentSlideIndex);

                // Delays
                var timing = parseFloat(thisSlide.attr("data-timing")) * 1000;  // Transform seconds in milliseconds
                if(isNaN(timing)){timing=defaultTiming; console.log("NOTICE: ----------- data-timing is missing, using default.");}
                var fadeInTime = parseFloat(thisSlide.attr("data-fadein")) * 1000;
                if(isNaN(fadeInTime)){fadeInTime=defaultFadeInTime; console.log("NOTICE: ----------- data-fadein is missing, using default.");}
                var fadeOutTime = parseFloat(thisSlide.attr("data-fadeout")) * 1000;
                if(isNaN(fadeOutTime)){fadeOutTime=defaultFadeOutTime; console.log("NOTICE: ----------- data-fadeout is missing, using default.");}

                console.log("Slide: "+currentSlideIndex+":\n Display time: "+timing+" millisec.\n Fadein: "+fadeInTime+" millisec.\n Fadeout: "+fadeOutTime+" millisec.");
                thisSlide.animate({"opacity":1},fadeInTime);

                // If this slide contains a video
                if(slides.eq(currentSlideIndex).find("video").length > 0){

                    // Prevents more than 1 video to play at the same time
                    $("video").each(function(){
                        console.log("All video paused.")
                        $(this)[0].pause();
                    });

                    // Play this video from the start
                    var thisVideo = slides.eq(currentSlideIndex).find("video")[0];
                    thisVideo.currentTime = 0;
                    console.log("Video playing.");
                    thisVideo.play()
                }

                // Prepare for next slide
                currentSlideIndex++;

                // Reset to slide 0 if last was reached
                if(currentSlideIndex>lastSlideIndex){
                    currentSlideIndex=0;
                }

                setTimeout(function(){
                    // Fade out previous slide
                    var previousSlideIndex = currentSlideIndex-1;


                    // If previous was last slide
                    if(previousSlideIndex == -1){
                        previousSlideIndex = lastSlideIndex;
                    }

                    // If previous slide was set to pause
                    if(slides.eq(previousSlideIndex).attr("data-videopause")=="true"){
                        console.log("Video has been paused.");
                        slides.eq(previousSlideIndex).find("video")[0].pause();
                    }

                    slides.eq(previousSlideIndex).animate({"opacity":0},fadeOutTime);
                    showSlide();
                }, timing);
            }

            // Init
            showSlide();
        </script>
Mitch
  • 1,173
  • 1
  • 10
  • 31
  • 2
    You might consider loading the slides with ajax, or using a well established slideshow plugin that handles resources in efficient ways – Wesley Smith Oct 11 '16 at 09:16
  • I checked SlideShow plugins. However they don't give the option to add a different time limit to each slide. I need them to have different times, because sometimes, we show videos, and sometimes photos. Right now we use Jquery in order to slide them in and fade them out. – Mitch Oct 11 '16 at 09:18
  • In that case I would find a good slideshow plugin and download the development copy , not the .min.js and modify it to pass and accept a time for each slide. Most use a json data structure, should be a ton easier than rolling your own slider from scratch and way fewer headaches later, IMHO – Wesley Smith Oct 11 '16 at 09:21
  • But is there not a way to add a delay to a few slides? So that they get loaded in later (becuase i have a lot of time to spare before i need them). – Mitch Oct 11 '16 at 09:24
  • 1
    Looks like your problem might be this Chrome bug: https://bugs.chromium.org/p/chromium/issues/detail?id=593273 – Chris Lear Oct 11 '16 at 09:24
  • You can maybe have a look at http://stackoverflow.com/questions/36803176/how-to-prevent-the-play-request-was-interrupted-by-a-call-to-pause-error to see a similar issue – Chris Lear Oct 11 '16 at 09:25
  • @Mitch Possibly, but you're going to run into other issues an edge cases/ browser differences throughout the life of your project. IMHO, you'd serve yourself better working with a plugin with a solid community behind it. There are just too many great ones out there not to make use of one of them – Wesley Smith Oct 11 '16 at 12:29
  • Thanks, Had a look and found a few. However i found i "fix" for now wich us working good. Right now when the slides are at max, we loop again (start from the beginning). What i did is make a new index2. with a few slides in there. And when the slides are at max. i redirect tot index2. I basically continue doing that. If i found myself getting in trouble again, i will use plugins :) – Mitch Oct 11 '16 at 12:38

0 Answers0