Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Problema con slideshow

  1. #1

    Problema con slideshow

    Ciao a tutti..
    ho una webcam e faccio creare giornalmente un video tramite uno slideshow in javascript.
    Questo è il codice:

    <form name="PlayForm">
    <table>
    <tr>
    <td><input type="button" onclick="animImageDec();setCurrImage()" value="<<">
    <td><input type="button" onclick="startPlay()" value="Play >>">
    <td><input type="button" onclick="clearLastUpdate()" value="Stop">
    <td><input type="button" onclick="animImageInc();setCurrImage()" value=">>">

    </table>


    <body>


    [img]00.00.jpg[/img]
    <script language="javascript">
    img1= new Image();
    img1.src="00.00.jpg";
    img2= new Image();
    img2.src="00.05.jpg";
    img3= new Image();
    img3.src="00.10.jpg";
    img4= new Image();
    img4.src="00.15.jpg";
    img5= new Image();
    img5.src="00.20.jpg";
    img6= new Image();
    img6.src="00.25.jpg";
    img7= new Image();
    img7.src="00.30.jpg";
    img8= new Image();
    img8.src="00.35.jpg";
    img9= new Image();
    img9.src="00.40.jpg";
    img10= new Image();
    img10.src="00.45.jpg";
    img11= new Image();
    img11.src="00.50.jpg";
    img12= new Image();
    img12.src="00.55.jpg";
    img13= new Image();
    img13.src="01.00.jpg";
    ecc (fino alle 23.55)

    imgarray = new Array(540);
    imgarray[1] = new Image();
    imgarray[1].src = "00.00.jpg";
    imgarray[2] = new Image();
    imgarray[2].src = "00.05.jpg";
    imgarray[3] = new Image();
    imgarray[3].src = "00.10.jpg";
    imgarray[4] = new Image();
    imgarray[4].src = "00.15.jpg";
    imgarray[5] = new Image();
    imgarray[5].src = "00.20.jpg";
    imgarray[6] = new Image();
    imgarray[6].src = "00.25.jpg";
    imgarray[7] = new Image();
    imgarray[7].src = "00.30.jpg";
    imgarray[8] = new Image();
    imgarray[8].src = "00.35.jpg";
    imgarray[9] = new Image();
    imgarray[9].src = "00.40.jpg";
    imgarray[10] = new Image();
    imgarray[10].src = "00.45.jpg";
    imgarray[11] = new Image();
    imgarray[11].src = "00.50.jpg";
    imgarray[12] = new Image();
    imgarray[12].src = "00.55.jpg";
    imgarray[13] = new Image();
    imgarray[13].src = "01.00.jpg";
    ecc (fino alle 23.55)

    var timeoutValue = 300;
    var animDelay = 1000;
    var numOfImages = 540;

    </script>


    <script language="javascript">
    document.PlayForm.IntervalValue.value = timeoutValue;
    </script>


    <script language="javascript">
    var imageIndex = 0;
    var timeoutID = 0;
    var playMode = 0;


    function animImageInc()
    {
    if (imageIndex < numOfImages)
    imageIndex++
    else
    imageIndex = 1;
    }

    function animImageDec()
    {
    if (imageIndex > 1)
    imageIndex--;
    else
    imageIndex = numOfImages;
    }

    function setCurrImage()
    {
    document.MainImage.src = imgarray[imageIndex].src;
    }

    function updateAnim()
    {
    var currTimeoutValue;

    currTimeoutValue = timeoutValue;

    if (playMode == 1)
    {
    animImageInc();
    if (imageIndex == numOfImages)
    currTimeoutValue += animDelay;
    }
    else
    {
    clearLastUpdate();
    if (imageIndex == 1)
    currTimeoutValue += animDelay;
    }
    setCurrImage();
    timeoutID = setTimeout("updateAnim()", currTimeoutValue);
    }

    function clearLastUpdate()
    {
    clearTimeout(timeoutID);
    timeoutID = 0;
    }

    function startPlay()
    {
    clearLastUpdate();
    playMode = 1;
    updateAnim();
    }

    function startPlayReverse()
    {
    clearLastUpdate();
    playMode = 2;
    updateAnim();
    }


    updateAnim();

    </script>


    (La pagina internet è questa: http://webcamvenosa.altervista.org/archivio/oggi.html)

    Capita però che alcune immagini della cam non vengano caricate (per esempio capita che non vengono caricate le immagini 00.40.jpg e 00.45.jpg) e perciò la sequenza di immagini non è continua e ci sono momenti in cui non si vede l'immagine (appunto quando manca).
    Come si può ovviare a questo problema?
    Avevo pensato a degli IF: se manca l'immagine 00.40.jpg passa subito alla 00.45.jpg. Se manca la 00.45.jpg passa alla 00.50.jpg e così via.
    E' possibile fare una cosa del genere?
    Chi potrebbe aiutarmi? Non sono esperto in javascript..

    Grazie mille,

  2. #2
    Qualcuno potrebbe aiutarmi?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.