News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Run background music in smf

Started by tootcsen, June 27, 2006, 07:56:10 AM

Previous topic - Next topic

tootcsen

I want to play backgroup music in smf, I have added the code in index.template.php, it works fine but every time I click on the buttons (like search and login), the music will be re-played again. My question is where should I put the code so that it won't not re-play and stop as the user clicks on the button.

Besides, if I want to play the background music as the user opens the web, and it won't be re-played or stopped even through the user clicks on other page. Where should I put the code? How am I going to modify it?


[font=Verdana]// The main sub template above the content.
function template_main_above()
{
        global $context, $settings, $options, $scripturl, $txt, $modSettings;

if (isset($options['theme_color']))
   $mycolor = $options['theme_color'];
else{
   // Defaults.
   $options['theme_color'] = isset($settings['default_theme_color']) ? $settings['default_theme_color'] : 'brown';
   $mycolor=$options['theme_color'];
}

if(isset($settings['color_change_off']) && $settings['color_change_off']==1)
  $options['theme_color'] = isset($settings['default_theme_color']) ? $settings['default_theme_color'] : 'brown';

        // Show right to left and the character set for ease of translating.
        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html', $context['right_to_left'] ? ' dir="rtl"' : '', '><head>
        <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
        <meta name="description" content="', $context['page_title'], '" />
        <meta name="keywords" content="bulletin, board, free, forum, airtrek, airtreker" />
        <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/script.js"></script>
        <script language="JavaScript" type="text/javascript"><!--
                var smf_theme_url = "', $settings['theme_url'], '";
                var smf_images_url = "', $settings['images_url'], '";
        // --></script>
        <title>', $context['page_title'], '</title>

<!----------------------modification start here--------------------------------------------------------->

<!--This code for IE-->
<!--EMBED SRC="http:\\localhost\smf\music\Westlife - World Of Our Own.mp3" HIDDEN="false" AUTOSTART="true" loop="true"-->
<!--bgsound src="http:\\localhost\smf\music\Westlife - World Of Our Own.mid" loop="infinite" /-->
<OBJECT ID="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab# Version=5,1,52,701" STANDBY="Loading Microsoft Windows® Media Player components..." TYPE="application/x-oleobject" width="280" height="46">
<param name="fileName" value="http:\\localhost\smf\music\Westlife - World Of Our Own.mp3">
<param name="animationatStart" value="true">
<param name="transparentatStart" value="true">
<param name="autoStart" value="true">
<param name="showControls" value="true">
<param name="loop" value="true">
<param name="Volume" value="-300">
<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="http:\\localhost\smf\music\Westlife - World Of Our Own.mp3" name="MediaPlayer1" width=280 height=46 autostart=1 showcontrols=1 volume=-300>
</OBJECT>

<!--This code for Netscape-->
<OBJECT ID="MediaPlayer"
classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"
standby="Loading Microsoft Windows Media Player components..."
TYPE="application/x-oleobject">

<PARAM NAME="FileName" VALUE="http://server/path/your-file.asx">
<PARAM NAME="AnimationatStart" VALUE="false">
<PARAM NAME="TransparentatStart" VALUE="true">
<PARAM NAME="AutoStart" VALUE="true">
<PARAM NAME="ShowControls" VALUE="0">

<Embed TYPE="application/x-mplayer2"
pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&"
SRC="http:\\localhost\smf\music\Westlife - World Of Our Own.mp3"
Name=MediaPlayer
ShowControls=0
Width=2
Height=2
</embed>
</OBJECT>

  <!----------------------modification start here--------------------------------------------------------->';

        // This is here because Gecko browsers properly support white-space....
        if ($context['browser']['is_gecko'])
                echo '
        <style type="text/css"><!--
                .code
                {
                        white-space: pre;
                }
        --></style>';

        // The ?rc1 part of this link is just here to make sure browsers don't cache it wrongly.
        echo '
        <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style.css?rc1" />';

        /* Internet Explorer 4/5 and Opera 6 just don't do font sizes properly. (they are big...)
                Thus, in Internet Explorer 4, 5, and Opera 6 this will show fonts one size smaller than usual.
                Note that this is affected by whether IE 6 is in standards compliance mode.. if not, it will also be big.
                Standards compliance mode happens when you use xhtml... */
        if ($context['browser']['needs_size_fix'])
                echo '
        <link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/fonts-compat.css" />';

        // Show all the relative links, such as help, search, contents, and the like.
        echo '
        <link rel="help" href="', $scripturl, '?action=help" target="_blank" />
        <link rel="search" href="' . $scripturl . '?action=search" />
        <link rel="contents" href="', $scripturl, '" />';

        // If we're viewing a topic, these should be the previous and next topics, respectively.
        if (!empty($context['current_topic']))
                echo '
        <link rel="prev" href="' . $scripturl . '?action=;topic=' . $context['current_topic'] . '.0;prev_next=prev" />
        <link rel="next" href="' . $scripturl . '?action=;topic=' . $context['current_topic'] . '.0;prev_next=next" />';

        // If we're in a board, or a topic for that matter, the index will be the board's index.
        if (!empty($context['current_board']))
                echo '
        <link rel="index" href="' . $scripturl . '?board=' . $context['current_board'] . '.0" />';

        // We'll have to use the cookie to remember the header...
        if ($context['user']['is_guest'])
                $options['collapse_header'] = !empty($_COOKIE['upshrink']);

        // Output any remaining HTML headers. (from mods, maybe?)
        echo $context['html_headers'], '

        <script language="JavaScript" type="text/javascript"><!--
                var current_header = ', empty($options['collapse_header']) ? 'false' : 'true', ';

                function shrinkHeader(mode)
                {';

        // Guests don't have theme options!!
        if ($context['user']['is_guest'])
                echo '
                        document.cookie = "upshrink=" + (mode ? 1 : 0);';
        else
                echo '
                        document.getElementById("upshrinkTemp").src = "', $scripturl, '?action=jsoption;var=collapse_header;val=" + (mode ? 1 : 0) + ";sesc=', $context['session_id'], ';" + (new Date().getTime());';

        echo '
                        document.getElementById("upshrink").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif");

                        document.getElementById("upshrinkHeader").style.display = mode ? "none" : "";

                        current_header = mode;
                }
        // --></script>
</head>[/font]

tootcsen

Sorry, I think I should post my question in a previous topic but I can do nothing now, sorry.

Advertisement: