Jump to content

Help needed to modify a PHP Script


Lux05

Recommended Posts

HI :)

 

With my limited PHP knowledges i tried to modify a PHP script to replace the simple MP3 player with the JW Player and luckily i managed to do this but the last task i wanted to do im stuck.

The last task i wanted to do was if an Audio file was detected it would use the Audio script for the JW Player to play the file. But i had no luck on doing this so i hop someone with more PHP knowledges can help out here.

 

 

Working Script Code for all files:

    // mp3 player
    if ($file->extern_file){
      $extern_mp3 = true;
      $filetype = strtolower(substr(strrchr($file->extern_file, '.'), 1));
    } else {
      $filetype = strtolower(substr(strrchr($file->url_download, '.'), 1));
      $extern_mp3 = false;
    }
    if ($filetype == 'mp4' || $filetype == 'mov' || $filetype == 'flv' || $filetype == '3gp' ||  $filetype == '3g2' || $filetype == 'aac' || $filetype == 'm4a' || $filetype == 'mp3'){
        if ($extern_mp3){
            $mp3_path = $file->extern_file;
        } else {
            $mp3_path = JURI::base().$jlistConfig['files.uploaddir'].'/'.$cat->cat_dir.'/'.$file->url_download;
        }
                $mp3_player = 
                '<script type="text/javascript"  src="/components/com_jdownloads/jwplayer/jwplayer.js"></script>
                <div id="container">Loading the media player ...</div>
                <script type="text/javascript">
                    jwplayer("container").setup({
                        flashplayer: "/components/com_jdownloads/jwplayer/player.swf",
                        backcolor: "333333",
                        frontcolor: "FFFFFF",
                        lightcolor: "FF0000",
                        screencolor: "000000",
                        controlbar: "bottom",
                        file: "'.$mp3_path.'",
                        volume: 50,
                        height: 384,
                        width: 480,
                        plugins: "timeslidertooltipplugin-1"
                    });
                </script>';
        if ($extern_mp3){
                $mp3_path_abs = JPATH_BASE.DS.$jlistConfig['files.uploaddir'].DS.$cat->cat_dir.DS.$file->url_download;
                }
                $html_file = str_replace('{mp3_player}', $mp3_player, $html_file);
            } else {
                $html_file = str_replace('{mp3_player}', '', $html_file);
    }

 

JW Player code that should be used for the Audio files:

                <script type="text/javascript"  src="/components/com_jdownloads/jwplayer/jwplayer.js"></script>
                <div id="container">Loading the media player ...</div>
                <script type="text/javascript">
                    jwplayer("container").setup({
                        flashplayer: "/components/com_jdownloads/jwplayer/player.swf",
                        backcolor: "333333",
                        frontcolor: "FFFFFF",
                        lightcolor: "FF0000",
                        screencolor: "000000",
                        controlbar: "bottom",
                        file: "'.$mp3_path.'",
                        volume: 50,
                        height: 24,
                        width: 480,
                        plugins: "timeslidertooltipplugin-1"
                    });
                </script>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.