views:

817

answers:

1

Hello Masters Of Web Development again. Today my question is flash based. I have no experience in actionscript but due some conditions, I need to work a little with it. I've found only one flash player, that plays my Shoutcast stream directly to my site. I've designed it the way I like, put my shoutcast url in it and everything I wanted. The only one problem I couldn't decide is that I can't "tell" the player not to autostart with page load. I tried with "autoplay="false" when I embed the player in site, but nothing happens. I suppose that I need to put something in my actioscript. That's why I'm pasting my actionscript code... It's a but long, and I don't know is it a good idea to paste it here, but I have no option to attach a file... If anyone tells me suggestions on how to attach a file, I will edit my post.

function MD5(string)
{
    function RotateLeft(lValue, iShiftBits)
    {
        return(lValue << iShiftBits | lValue >>> 32 - iShiftBits);
    } // end function
    function AddUnsigned(lX, lY)
    {
        var _l5;
        var _l4;
        var _l3;
        var _l2;
        var _l1;
        _l3 = lX & 2147483648.000000;
        _l2 = lY & 2147483648.000000;
        _l5 = lX & 1073741824;
        _l4 = lY & 1073741824;
        _l1 = (lX & 1073741823) + (lY & 1073741823);
        if (_l5 & _l4)
        {
            return(_l1 ^ 2147483648.000000 ^ _l3 ^ _l2);
        } // end if
        if (_l5 | _l4)
        {
            if (_l1 & 1073741824)
            {
                return(_l1 ^ 3221225472.000000 ^ _l3 ^ _l2);
            }
            else
            {
                return(_l1 ^ 1073741824 ^ _l3 ^ _l2);
            } // end if
        }
        else
        {
            return(_l1 ^ _l3 ^ _l2);
        } // end if
    } 
    function F(x, y, z)
    {
        return(x & y | (x ^ 4294967295.000000) & z);
    } // end
    function G(x, y, z)
    {
        return(x & z | y & (z ^ 4294967295.000000));
    } 
    function H(x, y, z)
    {
        return(x ^ y ^ z);
    } 
    function I(x, y, z)
    {
        return(y ^ (x | z ^ 4294967295.000000));
    } 
    function FF(a, b, c, d, x, s, ac)
    {
        var _l1 = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
        return(AddUnsigned(RotateLeft(_l1, s), b));
    } 
    function GG(a, b, c, d, x, s, ac)
    {
        var _l1 = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
        return(AddUnsigned(RotateLeft(_l1, s), b));
    } 
    function HH(a, b, c, d, x, s, ac)
    {
        var _l1 = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
        return(AddUnsigned(RotateLeft(_l1, s), b));
    } 
    function II(a, b, c, d, x, s, ac)
    {
        var _l1 = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
        return(AddUnsigned(RotateLeft(_l1, s), b));
    } 
    function ConvertToWordArray(string)
    {
        var _l2;
        var _l5 = string.length;
        var _l8 = _l5 + 8;
        var _l9 = (_l8 - _l8 % 64) / 64;
        var _l7 = (_l9 + 1) * 16;
        var _l3 = Array(_l7 - 1);
        var _l4 = 0;
        var _l1 = 0;
        while (_l1 < _l5)
        {
            _l2 = (_l1 - _l1 % 4) / 4;
            _l4 = _l1 % 4 * 8;
            _l3[_l2] = _l3[_l2] | string.charCodeAt(_l1) << _l4;
            _l1++;
        } 
        _l2 = (_l1 - _l1 % 4) / 4;
        _l4 = _l1 % 4 * 8;
        _l3[_l2] = _l3[_l2] | 128 << _l4;
        _l3[_l7 - 2] = _l5 << 3;
        _l3[_l7 - 1] = _l5 >>> 29;
        return(_l3);
    } 
    function WordToHex(lValue)
    {
        var _l3 = "";
        var _l2 = "";
        var _l4;
        var _l1;
        _l1 = 0;
        while (_l1 <= 3)
        {
            _l4 = lValue >>> _l1 * 8 & 255;
            _l2 = "0" + _l4.toString(16);
            _l3 = _l3 + _l2.substr(_l2.length - 2, 2);
            _l1++;
        } 
        return(_l3);
    } 
    function Utf8Encode(string)
    {
        var _l2 = "";
        var _l3 = 0;
        while (_l3 < string.length)
        {
            var _l1 = string.charCodeAt(_l3);
            if (_l1 < 128)
            {
                _l2 = _l2 + String.fromCharCode(_l1);
            }
            else if (_l1 > 127 && _l1 < 2048)
            {
                _l2 = _l2 + String.fromCharCode(_l1 >> 6 | 192);
                _l2 = _l2 + String.fromCharCode(_l1 & 63 | 128);
            }
            else
            {
                _l2 = _l2 + String.fromCharCode(_l1 >> 12 | 224);
                _l2 = _l2 + String.fromCharCode(_l1 >> 6 & 63 | 128);
                _l2 = _l2 + String.fromCharCode(_l1 & 63 | 128);
            } 
            _l3++;
        } 
        return(_l2);
    } 
    var _l6 = Array();
    var _l5;
    var _l35;
    var _l36;
    var _l37;
    var _l34;
    var _l4;
    var _l21 = 7;
    var _l19 = 12;
    var _l16 = 17;
    var _l13 = 22;
    var _l20 = 5;
    var _l17 = 9;
    var _l14 = 14;
    var _l11 = 20;
    var _l18 = 4;
    var _l15 = 11;
    var _l12 = 16;
    var _l10 = 23;
    var _l25 = 6;
    var _l24 = 10;
    var _l23 = 15;
    var _l22 = 21;
    var _l27 = Utf8Encode(string);
    _l6 = ConvertToWordArray(_l27);
    _l4 = 1732584193;
    _l3 = 4023233417.000000;
    _l2 = 2562383102.000000;
    _l1 = 271733878;
    _l5 = 0;
    while (_l5 < _l6.length)
    {
        _l35 = _l4;
        _l36 = _l3;
        _l37 = _l2;
        _l34 = _l1;
        _l4 = FF(_l4, _l3, _l2, _l1, _l6[_l5 + 0], _l21, 3614090360.000000);
        _l1 = FF(_l1, _l4, _l3, _l2, _l6[_l5 + 1], _l19, 3905402710.000000);
        _l2 = FF(_l2, _l1, _l4, _l3, _l6[_l5 + 2], _l16, 606105819);
        _l3 = FF(_l3, _l2, _l1, _l4, _l6[_l5 + 3], _l13, 3250441966.000000);
        _l4 = FF(_l4, _l3, _l2, _l1, _l6[_l5 + 4], _l21, 4118548399.000000);
        _l1 = FF(_l1, _l4, _l3, _l2, _l6[_l5 + 5], _l19, 1200080426);
        _l2 = FF(_l2, _l1, _l4, _l3, _l6[_l5 + 6], _l16, 2821735955.000000);
        _l3 = FF(_l3, _l2, _l1, _l4, _l6[_l5 + 7], _l13, 4249261313.000000);
        _l4 = FF(_l4, _l3, _l2, _l1, _l6[_l5 + 8], _l21, 1770035416);
        _l1 = FF(_l1, _l4, _l3, _l2, _l6[_l5 + 9], _l19, 2336552879.000000);
        _l2 = FF(_l2, _l1, _l4, _l3, _l6[_l5 + 10], _l16, 4294925233.000000);
        _l3 = FF(_l3, _l2, _l1, _l4, _l6[_l5 + 11], _l13, 2304563134.000000);
        _l4 = FF(_l4, _l3, _l2, _l1, _l6[_l5 + 12], _l21, 1804603682);
        _l1 = FF(_l1, _l4, _l3, _l2, _l6[_l5 + 13], _l19, 4254626195.000000);
        _l2 = FF(_l2, _l1, _l4, _l3, _l6[_l5 + 14], _l16, 2792965006.000000);
        _l3 = FF(_l3, _l2, _l1, _l4, _l6[_l5 + 15], _l13, 1236535329);
        _l4 = GG(_l4, _l3, _l2, _l1, _l6[_l5 + 1], _l20, 4129170786.000000);
        _l1 = GG(_l1, _l4, _l3, _l2, _l6[_l5 + 6], _l17, 3225465664.000000);
        _l2 = GG(_l2, _l1, _l4, _l3, _l6[_l5 + 11], _l14, 643717713);
        _l3 = GG(_l3, _l2, _l1, _l4, _l6[_l5 + 0], _l11, 3921069994.000000);
        _l4 = GG(_l4, _l3, _l2, _l1, _l6[_l5 + 5], _l20, 3593408605.000000);
        _l1 = GG(_l1, _l4, _l3, _l2, _l6[_l5 + 10], _l17, 38016083);
        _l2 = GG(_l2, _l1, _l4, _l3, _l6[_l5 + 15], _l14, 3634488961.000000);
        _l3 = GG(_l3, _l2, _l1, _l4, _l6[_l5 + 4], _l11, 3889429448.000000);
        _l4 = GG(_l4, _l3, _l2, _l1, _l6[_l5 + 9], _l20, 568446438);
        _l1 = GG(_l1, _l4, _l3, _l2, _l6[_l5 + 14], _l17, 3275163606.000000);
        _l2 = GG(_l2, _l1, _l4, _l3, _l6[_l5 + 3], _l14, 4107603335.000000);
        _l3 = GG(_l3, _l2, _l1, _l4, _l6[_l5 + 8], _l11, 1163531501);
        _l4 = GG(_l4, _l3, _l2, _l1, _l6[_l5 + 13], _l20, 2850285829.000000);
        _l1 = GG(_l1, _l4, _l3, _l2, _l6[_l5 + 2], _l17, 4243563512.000000);
        _l2 = GG(_l2, _l1, _l4, _l3, _l6[_l5 + 7], _l14, 1735328473);
        _l3 = GG(_l3, _l2, _l1, _l4, _l6[_l5 + 12], _l11, 2368359562.000000);
        _l4 = HH(_l4, _l3, _l2, _l1, _l6[_l5 + 5], _l18, 4294588738.000000);
        _l1 = HH(_l1, _l4, _l3, _l2, _l6[_l5 + 8], _l15, 2272392833.000000);
        _l2 = HH(_l2, _l1, _l4, _l3, _l6[_l5 + 11], _l12, 1839030562);
        _l3 = HH(_l3, _l2, _l1, _l4, _l6[_l5 + 14], _l10, 4259657740.000000);
        _l4 = HH(_l4, _l3, _l2, _l1, _l6[_l5 + 1], _l18, 2763975236.000000);
        _l1 = HH(_l1, _l4, _l3, _l2, _l6[_l5 + 4], _l15, 1272893353);
        _l2 = HH(_l2, _l1, _l4, _l3, _l6[_l5 + 7], _l12, 4139469664.000000);
        _l3 = HH(_l3, _l2, _l1, _l4, _l6[_l5 + 10], _l10, 3200236656.000000);
        _l4 = HH(_l4, _l3, _l2, _l1, _l6[_l5 + 13], _l18, 681279174);
        _l1 = HH(_l1, _l4, _l3, _l2, _l6[_l5 + 0], _l15, 3936430074.000000);
        _l2 = HH(_l2, _l1, _l4, _l3, _l6[_l5 + 3], _l12, 3572445317.000000);
        _l3 = HH(_l3, _l2, _l1, _l4, _l6[_l5 + 6], _l10, 76029189);
        _l4 = HH(_l4, _l3, _l2, _l1, _l6[_l5 + 9], _l18, 3654602809.000000);
        _l1 = HH(_l1, _l4, _l3, _l2, _l6[_l5 + 12], _l15, 3873151461.000000);
        _l2 = HH(_l2, _l1, _l4, _l3, _l6[_l5 + 15], _l12, 530742520);
        _l3 = HH(_l3, _l2, _l1, _l4, _l6[_l5 + 2], _l10, 3299628645.000000);
        _l4 = II(_l4, _l3, _l2, _l1, _l6[_l5 + 0], _l25, 4096336452.000000);
        _l1 = II(_l1, _l4, _l3, _l2, _l6[_l5 + 7], _l24, 1126891415);
        _l2 = II(_l2, _l1, _l4, _l3, _l6[_l5 + 14], _l23, 2878612391.000000);
        _l3 = II(_l3, _l2, _l1, _l4, _l6[_l5 + 5], _l22, 4237533241.000000);
        _l4 = II(_l4, _l3, _l2, _l1, _l6[_l5 + 12], _l25, 1700485571);
        _l1 = II(_l1, _l4, _l3, _l2, _l6[_l5 + 3], _l24, 2399980690.000000);
        _l2 = II(_l2, _l1, _l4, _l3, _l6[_l5 + 10], _l23, 4293915773.000000);
        _l3 = II(_l3, _l2, _l1, _l4, _l6[_l5 + 1], _l22, 2240044497.000000);
        _l4 = II(_l4, _l3, _l2, _l1, _l6[_l5 + 8], _l25, 1873313359);
        _l1 = II(_l1, _l4, _l3, _l2, _l6[_l5 + 15], _l24, 4264355552.000000);
        _l2 = II(_l2, _l1, _l4, _l3, _l6[_l5 + 6], _l23, 2734768916.000000);
        _l3 = II(_l3, _l2, _l1, _l4, _l6[_l5 + 13], _l22, 1309151649);
        _l4 = II(_l4, _l3, _l2, _l1, _l6[_l5 + 4], _l25, 4149444226.000000);
        _l1 = II(_l1, _l4, _l3, _l2, _l6[_l5 + 11], _l24, 3174756917.000000);
        _l2 = II(_l2, _l1, _l4, _l3, _l6[_l5 + 2], _l23, 718787259);
        _l3 = II(_l3, _l2, _l1, _l4, _l6[_l5 + 9], _l22, 3951481745.000000);
        _l4 = AddUnsigned(_l4, _l35);
        _l3 = AddUnsigned(_l3, _l36);
        _l2 = AddUnsigned(_l2, _l37);
        _l1 = AddUnsigned(_l1, _l34);
        _l5 = _l5 + 16;
    } // end while
    var _l46 = WordToHex(_l4) + WordToHex(_l3) + WordToHex(_l2) + WordToHex(_l1);
    return(_l46.toLowerCase());
} // end function

function searchAndReplace(holder, searchfor, replacement)
{
    temparray = holder.split(searchfor);
    var _l1 = temparray.join(replacement);
    return(_l1);
} // radio
function startStream(channel, bitrate, country, force)
{
    if (_root.music == "on" && channel != _root.musicChannel && _root.changelock != "on" || _root.music == "on" && _root.serverCountry != country && _root.changelock != "on" || force == "true" && _root.changelock != "on")
    {
        setSoundQualitybtn();
        setChannelbtn(channel);
        snd2 = _root.cVol;
        _root.changelock = "on";
        _root.serverCountry = country;
        stopstartSnd = setInterval(stopstartSound, 5, channel, bitrate, country);
    }
    else if ((_root.music == "off" || channel != _root.musicChannel) && _root.changelock != "on")
    {
        if (channel == "tc")
        {
            channelName_txt.text = "rap radio";
            currentartist_txt.text = "loading ...";
            currenttitle_txt.text = "";
            _root.serverCountry = country;
            if (_root.serverCountry == "rap")
            {
                if (_root.soundQuality == "low")
                {
                    server = "xx.xx.xxx.xxx:xxxx";
                }
                else
                {
                    server = "xx.xx.xxx.xxx:xxxx";
                } // server i porta s vazmojnosti za smqna na stantsiata
            }
            else if (_root.soundQuality == "low")
            {
                server = "xx.xx.xxx.xxx:xxxx";
            }
            else
            {
                server = "xx.xx.xxx.xxx:xxxx";
            } // end if
        }
        else
        {
            channelName_txt.text = "other channel";
            currentartist_txt.text = "title...";
            currenttitle_txt.text = "";
            if (_root.serverCountry == "rap")
            {
                if (_root.soundQuality == "low")
                {
                    server = "xx.xxx.xxx.xxx:xxxx";
                }
                else
                {
                    server = "xxx.xxx.xxx.xxx:xxxx";
                } // raznite mu ip-ta
            }
            else if (_root.soundQuality == "low")
            {
                server = "xxx.xxx.xx.xx:xxxx";
            }
            else
            {
                server = "xxx.xx.xxx.xxx:xxxx";
            } 
        } // 
        setSoundQualitybtn();
        setChannelbtn(channel);
        _root.music = "on";
        _root.musicChannel = channel;
        _root.musicPlayer.gotoAndStop("Start");
        _root.geluid = new Sound();
        _root.geluid.loadSound("http://" + server + "/;listen.pls", true);
        _root.geluid.setVolume(0);
        _root.geluid.onSoundComplete = function ()
        {
            _root.geluid.start();
        };
        buff = 0;
        vumeter_mv._visible = false;
        connecting_mc._visible = true;
        bufferSnd = setInterval(bufferSound, 30);
    } 
} // end funciata
function setSoundQualitybtn()
{
    if (_root.soundQuality == "low")
    {
        soundQuality_btn_high_on._visible = false;
        soundQuality_btn_low_on._visible = true;
    }
    else
    {
        soundQuality_btn_high_on._visible = true;
        soundQuality_btn_low_on._visible = false;
    } 
} 
function setChannelbtn(channel)
{
    if (channel == "dj")
    {
        dj_Channel_btn_high_on._visible = true;
        tc_Channel_btn_high_on._visible = false;
    }
    else
    {
        dj_Channel_btn_high_on._visible = false;
        tc_Channel_btn_high_on._visible = true;
    } // 
}
function stopStream()
{
    if (_root.changelock != "on")
    {
        if (_root.music == "on")
        {
            snd = _root.cVol;
            _root.changelock = "on";
            stopSnd = setInterval(stopSound, 10);
        } 
    } 
} // end func
function stopSound()
{
    _root.geluid.setVolume(snd);
    snd--;
    if (snd < 0)
    {
        clearInterval(stopSnd);
        vumeter_mv._visible = false;
        snd = 0;
        _root.cVol = 0;
        _root.music = "off";
        _root.musicPlayer.gotoAndStop("Stop");
        delete _root["geluid"];
        _root.changelock = "off";
        dj_Channel_btn_high_on._visible = false;
        tc_Channel_btn_high_on._visible = false;
    } // end
} 
function stopstartSound(channel, bitrate, country)
{
    _root.geluid.setVolume(snd2);
    snd2--;
    _root.changelock = "on";
    _root.cVol = snd2;
    if (snd2 < 0)
    {
        clearInterval(songinfo);
        clearInterval(stopstartSnd);
        snd = 0;
        snd2 = 0;
        _root.cVol = 0;
        _root.music = "off";
        _root.musicPlayer.gotoAndStop("Stop");
        delete _root["geluid"];
        _root.changelock = "off";
        startStream(channel, bitrate, country, "");
    }
} 
function bufferSound()
{
    _root.geluid.setVolume(0);
    _root.changelock = "on";
    buff++;
    if (buff > 50)
    {
        clearInterval(bufferSnd);
        snd = 0;
        _root.cVol = 0;
        connecting_mc._visible = false;
        vumeter_mv._visible = true;
        startSnd = setInterval(startSound, 5);
    } 
} 
function startSound()
{
    _root.geluid.setVolume(snd);
    snd++;
    if (snd > _root.origVol)
    {
        clearInterval(startSnd);
        snd = _root.origVol;
        _root.cVol = _root.origVol;
        _root.changelock = "off";
        getSongInfo();
        songinfo = setInterval(getSongInfo, 10000);
    } 
} 
_soundbuftime = 0;
vumeter_mv._visible = false;
connecting_mc._visible = false;
currentartist_tc_txt._visible = false;
currentartist_dj_txt._visible = false;
currenttitle_tc_txt._visible = false;
currenttitle_dj_txt._visible = false;
var currentSongName;
getSongInfo = function ()
{
    var _l3 = new LoadVars();
    _l3._parent = this;
    _l3.onLoad = function (success)
    {
        if (success)
        {
            this._parent.myField_txt.text = this.myText;
        } // end if
    };
    if (success.musicChannel == "dj")
    {
        _l3.load("" + random(240000));
    }
    else
    {
        _l3.load("" + random(240000));
    } 
    _l3.onLoad = function (bSuccess)
    {
        if (bSuccess)
        {
            content = unescape(this);
            var _l8 = new Array();
            var _l9 = new Array();
            var _l2 = content.split("|");
            var _l3 = _l2[1].split(" - ");
            var _l10 = 0;
            var _l6 = "";
            var _l7 = 0;
            var _l5 = searchAndReplace(_l2[1], "\'", "\\\'");
            currentSongName = searchAndReplace(_l2[1], "\'", "\\\'");
            var _l4 = MD5(_l5);
            _l4 = _l4.substr(0, 20);
            currentartist_txt.text = _l3[0];
            currenttitle_txt.text = _l3[1];
            rr.text = random(12115);
        } 
    };
};
getSongInfo();
if (bps == "low")
{
    _root.soundQuality = "low";
}
else
{
    _root.soundQuality = "high";
} 
if (srv == "eur")
{
    var_country = "eur";
}
else
{
    var_country = "usa";
} // end if
if (channel == 2)
{
    var_channel = "dj";
}
else
{
    var_channel = "tc";
} 
if (autostart != "false")
{
    startStream(var_channel, "", var_country, "");
}
+1  A: 

Are you passing autostart via flashvars to Actionscript code if yes then then you need to write
(_root.autostart != "false")
instead of
(autostart != "flase").
all variable passed to swf files are accessible via _root reference.

-bhups

bhups
@bhups: Thanks for the reply. I pasted my actionscript code above. I didn't wrote this, It was given to me. And I really don't know where to put the code that you give me in your answer.... :(((Can you help me a little bit more, please?And tell me your paypal's email, to send you some funds for the help :)))
Spoonk
@spoonk: where are you embedding your final swf file in the html? Probably it'll be like <embed id="something" src="yourfile.swf" fullscreen="false" ... flashvars="a=12;b=23"/> If flashvars is present in the embed tag then add autplay=false in it like flashvars="a=12;b=23;autoplay=false" and if it is not present then add flashvars property into the tag like flashvars="autoplay=false". Hope it helps.-bhups
bhups
Typo. inside flashvars key=value pair will be ampersand ().
bhups
@-bhups: this is the embedding code: " <div id="radio_player"><object type="application/x-shockwave-flash"data="includes/radio/spoonk.swf"width="210" height="20"><param name="movie" value="includes/radio/spoonk.swf" /><param name="quality" value="high"/><param name="autoplay" value="false" /></object> </div>"I haven't any "flashvars" in it...
Spoonk
@Spoonk: change it to: <div id="radio_player"> <object type="application/x-shockwave-flash" data="includes/radio/spoonk.swf" width="210" height="20"> <param name="movie" value="includes/radio/spoonk.swf?autostart=false" /> <param name="quality" value="high"/> </object> </div> and change "if (autostart != "false"){ startStream(var_channel, "", var_country, "");}" to "if (_root.autostart != "false"){ startStream(var_channel, "", var_country, "");}". If still things don't work then can you send me your flash source files.
bhups
Jesus!!! It Worked. And even I try a few things, and i saw that it works, without rewrite the "autostart !="false" variable :)))I just added "?autostart=false" in "data" row, after "spoonk.swf" in my embedding code, and it stops autoplaying :))) Thanks a lot @-bhups, you gave me a huge help. Now you are my friend for life :))And you had forgoten to wright me your paypal email :)))
Spoonk