• User Attivo

    modifica tema

    salve a tutti, sto disperatamente cercando di modificare un tema wordpress per aggiungere dei controlli ad un player radio attraverso il menu .
    mi spiego, nel tema c'è un player che va in riproduzione continua mentre si naviga, io dovrei fare in modo che entrando in due pagine specifiche il player vada in pausa per poi tornare in play quando se ne esce.
    pensavo di aver trovato la soluzione. ho aggiunto una parte di javascript che controlla l'evento .onclcik del menu, ma funzionava solo la prima volta che ci si cliccava. poi mi sono resa conto che il php usava gli switch /case, per cui il controllo delle variabili veniva effettuato solo una volta. allora, grazie a un prezioso aiuto ricevuto qui nel forum, ho provato a convertire gli switch in if... ma così non m carica più nè la grafica nè tantomeno il player... il codice originale ( che viene richiamato dal footer e gestisce il player) è:

    <?php
    $type = of_get_option('type_background');
    $image = of_get_option('background_upload');
    $radio_ip = of_get_option('radio_ip');
    $radioplay = of_get_option('radio_autoplay');
    $radioopened = of_get_option('radio_opened');
    $playerar = of_get_option('player_audio_radio');
    $speedslideshow = of_get_option('slider_speed_slideshow');
    $speedanimation = of_get_option('slider_speed_animation');
     
    echo'
    <script type="text/javascript">
    jQuery(document).ready(function($){';
    
    
    switch ($type) {
             case "image": 
             echo '
    $.backstretch("'.$image.'");';
    break;
    }
    
    
    switch ($playerar) {
    case "player_radio":
    echo'
    $("#jquery_jplayer_1").jPlayer({
        ready: function () {
            $(this).jPlayer("setMedia", {
                mp3: "link"
            })';
            
            switch ($radioplay) {
            case "radio_autoplay_on":
            echo '.jPlayer("play")';
            break;
            }
    echo';    
            debug($(this));
        },
        swfPath: "'.get_template_directory_uri().'/swf/",
        supplied: "mp3",
        volume: 1
    });';
    
    
    switch ($radioopened) {
    case "radio_opened_visible":  
      echo '
      $(".radio-wz-open-hidden").click(function () {
        $("#radio-wz #radio-wz-col").slideToggle({
          direction: "up"
        }, 100);
        $(this).toggleClass("clientsClose");
      });
       $("#radio-wz-col").show();
       
       function mouseHandler(e){
      if ($(this).hasClass("radio-wz-hidden-open")) {
        $(this).removeClass("radio-wz-hidden-open");
      } else {
        $(".radio-wz-hidden-open").removeClass("radio-wz-hidden-open");
        $(this).addClass("radio-wz-hidden-open");
      } 
    }
    function start(){
      $(".radio-wz-open-hidden").bind("click", mouseHandler);
    }
    $(document).ready(start);
       ';
    break;
    case "radio_opened_hidden": 
    echo '
      $(".radio-wz-open").click(function () {
        $("#radio-wz").slideToggle({
          direction: "up"
        }, 100);
        $(this).toggleClass("clientsClose");
      });
      function mouseHandler(e){
     if ($(this).hasClass("radio-wz-open-hidden")) {
       $(this).removeClass("radio-wz-open-hidden");
      } else {
       $(".radio-wz-open-hidden").removeClass("radio-wz-open-hidden");
       $(this).addClass("radio-wz-open-hidden");
      } 
    }
    function start(){
       $(".radio-wz-open").bind("click", mouseHandler);
    }
    $(document).ready(start);
      ';
    break;
    }  
    break;
    } 
    
    
    if (of_get_option('slider_active', '1') == '1') {
        if (is_front_page()){ 
    echo'
            if ( jQuery(".flexslider").length && jQuery() ) {
            jQuery(".flexslider").flexslider({
                controlNav: true,
                animationLoop: true,  
                controlsContainer:"",
                pauseOnAction: false,
                pauseOnHover: true,
                smoothHeight: true,
                nextText:"&rsaquo;",
                prevText:"&lsaquo;",
                keyboardNav: false,         
                slideshowSpeed: '.$speedslideshow.',
                animationSpeed: '.$speedanimation.',
                start: function(slider) {
                slider.removeClass("loading");
                }
            });            
            }';
        } 
    }
    echo'
    });
     </script>';
     
    ?>
    

    quello modificato ( che non va)

    <?php
    $type = of_get_option('image');
    $image = of_get_option('background_upload');
    $radio_ip = of_get_option('radio_ip');
    $radioplay = of_get_option('radio_autoplay_on');
    $radioopened = of_get_option('radio_opened');
    $playerar = of_get_option('player_radio');
    $speedslideshow = of_get_option('slider_speed_slideshow');
    $speedanimation = of_get_option('slider_speed_animation');
     
    echo'<script type="text/javascript">
      jQuery(document).ready(function ($){
         $("#menu-item-3354,#menu-item-3419").on("click",function(){
            $("#jquery_jplayer_1").jPlayer("pause");
          });
              $("#menu-item-3367,#menu-item-123,#menu-item-304,#menu-item-1048,#menu-item-2788,#menu-item-1046,#menu-item-3753,#menu-item-1045,#menu-item-1044,#menu-item-3719,#menu-item-3754,#menu-item-3755,#menu-item-3751,#menu-item-41,#menu-item-3418,#menu-item-68,#menu-item-123,#menu-item-2788").on("click",function(){
                  $("#jquery_jplayer_1").jPlayer("play");
                });';
    
    
    // switch($type)
    if ($type=="image") {
            
             echo '$.backstretch("'.$image.'");';
    }
    
    
    
    
    //switch ($playerar)
    if ($playerar=="player_radio") {
      echo'$("#jquery_jplayer_1").jPlayer({
        ready: function () {
            $(this).jPlayer("setMedia", {
               mp3: "link"
            })';
    
    
    
    
            //switch(radioplay)
            if($radioplay == "radio_autoplay_on"){
              echo '.jPlayer("play")';
            } 
    echo';    
            debug($(this));
        },
        swfPath: "'.get_template_directory_uri().'/swf/",
        supplied: "mp3",
        volume: 1
    });';
           
          //switch($radioopened)
          if ($radioopened=="radio_opened_visible") {
     
              echo '
                $(".radio-wz-open-hidden").click(function () {
                  $("#radio-wz").slideToggle({
                    direction: "up"
                  }, 100);
                  $(this).toggleClass("clientsClose");
                });
                 $("#radio-wz-col").show();
                 
                 function mouseHandler(e){
                if ($(this).hasClass("radio-wz-hidden-open")) {
                  $(this).removeClass("radio-wz-hidden-open");
                } else {
                  $(".radio-wz-hidden-open").removeClass("radio-wz-hidden-open");
                  $(this).addClass("radio-wz-hidden-open");
                } 
              }
              function start(){
                $(".radio-wz-open-hidden").bind("click", mouseHandler);
              }
              $(document).ready(start);
                 ';
    
    
    
    
              }elseif( $radioopened=="radio_opened_hidden") {
                echo '
                  $(".radio-wz-open").click(function () {
                    $("#radio-wz").slideToggle({
                      direction: "up"
                    }, 100);
                    $(this).toggleClass("clientsClose");
                  });
                  function mouseHandler(e){
                 if ($(this).hasClass("radio-wz-open-hidden")) {
                   $(this).removeClass("radio-wz-open-hidden");
                  } else {
                   $(".radio-wz-open-hidden").removeClass("radio-wz-open-hidden");
                   $(this).addClass("radio-wz-open-hidden");
                  } 
                }
                function start(){
                   $(".radio-wz-open").bind("click", mouseHandler);
                }
                $(document).ready(start);
                  ';
                }
        }      
    
    
    if (of_get_option('slider_active', '1') == '1') {
        if (is_front_page()){ 
    echo'
            if ( jQuery(".flexslider").length && jQuery() ) {
            jQuery(".flexslider").flexslider({
                controlNav: true,
                animationLoop: true,  
                controlsContainer:"",
                pauseOnAction: false,
                pauseOnHover: true,
                smoothHeight: true,
                nextText:"&rsaquo;",
                prevText:"&lsaquo;",
                keyboardNav: false,         
                slideshowSpeed: '.$speedslideshow.',
                animationSpeed: '.$speedanimation.',
                start: function(slider) {
                slider.removeClass("loading");
                }
            });            
            }';
        } 
    }
    echo'
    });
     </script>';
    ?>
    

    ora mi chiedevo se qualcuno ha unìidea per poter controllare il player al di fuori di questa pagina visto che qui sembra impossibile, o in ogni caso se qualcuno mi può suggerire qualche tentativo sensato, perchè oramai io sono davvero a corto di idee...


  • User Attivo

    correggendo leggermente il js del secondo file , si carica tutto, ma il controllo lo fa comunque solo una volta, la prima volta che clicco sulla pagina della pausa ci va, ma poi non torna in play nemmeno sotto minaccia 😞

    
    <?php
    $type = of_get_option('type_background');
    $image = of_get_option('background_upload');
    $radio_ip = of_get_option('radio_ip');
    $radioplay = of_get_option('radio_autoplay');
    $radioopened = of_get_option('radio_opened');
    $playerar = of_get_option('player_audio_radio');
    $speedslideshow = of_get_option('slider_speed_slideshow');
    $speedanimation = of_get_option('slider_speed_animation');
     
    echo'
    <script type="text/javascript">
    jQuery(document).ready(function($){$("#menu-item-3354,#menu-item-3419").on("click",function(){
            $("#jquery_jplayer_1").jPlayer("pause");
          });
              $("#menu-item-3367,#menu-item-123,#menu-item-304,#menu-item-1048,#menu-item-2788,#menu-item-1046,#menu-item-3753,#menu-item-1045,#menu-item-1044,#menu-item-3719,#menu-item-3754,#menu-item-3755,#menu-item-3751,#menu-item-41,#menu-item-3418,#menu-item-68,#menu-item-123,#menu-item-2788").on("click",function(){
                  $("#jquery_jplayer_1").jPlayer("play");
                });';
    
    
    // switch($type)
    if ($type=="image") {
            
             echo '$.backstretch("'.$image.'");';
    }
    
    
    
    
    //switch ($playerar)
    if ($playerar=="player_radio") {
      echo'$("#jquery_jplayer_1").jPlayer({
        ready: function () {
            $(this).jPlayer("setMedia", {
               mp3: "link"
            })';
    
    
    
    
            //switch(radioplay)
            if($radioplay == "radio_autoplay_on"){
              echo '.jPlayer("play")';
            } 
    echo';	
    		debug($(this));
        },
    	swfPath: "'.get_template_directory_uri().'/swf/",
        supplied: "mp3",
    	volume: 1
    });';
           
          //switch($radioopened)
          if ($radioopened=="radio_opened_visible") {
     
              echo '
                $(".radio-wz-open-hidden").click(function () {
                  $("#radio-wz #radio-wz-col").slideToggle({
                    direction: "up"
                  }, 100);
                  $(this).toggleClass("clientsClose");
                });
                 $("#radio-wz-col").show();
                 
                 function mouseHandler(e){
                if ($(this).hasClass("radio-wz-hidden-open")) {
                  $(this).removeClass("radio-wz-hidden-open");
                } else {
                  $(".radio-wz-hidden-open").removeClass("radio-wz-hidden-open");
                  $(this).addClass("radio-wz-hidden-open");
                } 
              }
              function start(){
                $(".radio-wz-open-hidden").bind("click", mouseHandler);
              }
              $(document).ready(start);
                 ';
    
    
    
    
              }elseif( $radioopened=="radio_opened_hidden") {
                echo '
                  $(".radio-wz-open").click(function () {
                    $("#radio-wz").slideToggle({
                      direction: "up"
                    }, 100);
                    $(this).toggleClass("clientsClose");
                  });
                  function mouseHandler(e){
                 if ($(this).hasClass("radio-wz-open-hidden")) {
                   $(this).removeClass("radio-wz-open-hidden");
                  } else {
                   $(".radio-wz-open-hidden").removeClass("radio-wz-open-hidden");
                   $(this).addClass("radio-wz-open-hidden");
                  } 
                }
                function start(){
                   $(".radio-wz-open").bind("click", mouseHandler);
                }
                $(document).ready(start);
                  ';
                }
        }      
    
    
    if (of_get_option('slider_active', '1') == '1') {
        if (is_front_page()){ 
    echo'
            if ( jQuery(".flexslider").length && jQuery() ) {
            jQuery(".flexslider").flexslider({
                controlNav: true,
                animationLoop: true,  
                controlsContainer:"",
                pauseOnAction: false,
                pauseOnHover: true,
                smoothHeight: true,
                nextText:"&rsaquo;",
                prevText:"&lsaquo;",
                keyboardNav: false,         
                slideshowSpeed: '.$speedslideshow.',
                animationSpeed: '.$speedanimation.',
                start: function(slider) {
                slider.removeClass("loading");
                }
            });            
            }';
        } 
    }
    echo'
    });
     </script>';
     
    ?>