Viewing 2 replies - 1 through 2 (of 2 total)
  • If I understand this correctly you just want to emit code for the HTML5 audio player instead of the Flash audio player. I think a simple change to function get_audio() in file mf_front_end.php will do this.

    function alt_get_audio( $field_name, $group_index=1, $field_index=1, $post_id=NULL ){
      global $post;
    
      if(!$post_id){ $post_id = $post->ID; }
      $audio = get($field_name,$group_index,$field_index,$post_id);
    
      if( empty($audio) ) return FALSE;
    
      $mime_type = [
        'mp3' => 'audio/mpeg',
        'wav' => 'audio/wav',
        'ogg' => 'audio/ogg',
      ];
    
      $extension = strtolower( pathinfo( $audio,  PATHINFO_EXTENSION ) );
    
      #error_log( 'alt_get_audio():$_SERVER[\'HTTP_USER_AGENT\']=' . print_r( $_SERVER['HTTP_USER_AGENT'], true ) );
      #error_log( 'alt_get_audio():$extension=' . print_r( $extension, true ) );
    
      # the condition in the following if statement may need adjustment
      if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'iPad;' ) ) {
      #if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Windows ' ) ) { # for testing against Windows
        if ( array_key_exists( $extension, $mime_type ) ) {
          $player = '<audio controls><source src="' . $audio . '" type="' . $mime_type[$extension] .'"></audio>';
        } else {
          'Your browser cannot play ' . $extension . ' audio files.';
        }
      } else {
        $player = stripslashes(trim("\<div style=\'padding-top:3px;\'\>\<object classid=\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\' codebase='\https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\' width=\'95%\' height=\'20\' wmode=\'transparent\' \>\<param name=\'movie\' value=\'".MF_URL."js/singlemp3player.swf?file=".urlencode($audio)."\' wmode=\'transparent\' /\>\<param name=\'quality\' value=\'high\' wmode=\'transparent\' /\>\<embed src=\'".MF_URL."js/singlemp3player.swf?file=".urlencode($audio)."' width=\'50\%\' height=\'20\' quality=\'high\' pluginspage=\'https://www.macromedia.com/go/getflashplayer\' type=\'application/x-shockwave-flash\' wmode=\'transparent\' \>\</embed\>\</object\>\</div\>"));
      }
    
      #error_log( 'alt_get_audio():$player=' . print_r( $player, true ) );
    
      return $player;
    }

    Alternatively, you can include alt_get_audio() in your functions.php and call it in place of get_audio(). N.B. I was not able to test this on an iPad as I don’t own one. In particular I am not sure what USER-AGENT string it sends.

    Thread Starter jeanto

    (@jeanto)

    working perfect!!!
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘html5 audio player?’ is closed to new replies.