[Xerte] Re: Problem looping sound controlled by script - Xerte 2 desktop

Mary Ann Ahearn maryann at moberg.com
Sat Feb 5 00:45:03 GMT 2011


Julian, I couldn't get the rlo you sent to work.  The event never fired.

Instead I got what I needed working as a flash component.  Very simple.

Thanks to Julian and Dave for all your help.

Here's the code in case anyone needs something similar in the future.  Works
from a browser.   The swf file is 1K in size!  I love it.  No need for a
sound icon.  Just the flash component (I called it soundPlayer) and these
calls in respective button scripts:

soundPlayer.playLoopedSound(FileLocation + 'media/mySound.mp3');

soundPlayer.stopLoopedSound();


function init(initObject) {
//debug('init received');
}
var my_sound:Sound = new Sound();

// if the sound loads, play it;
my_sound.onLoad = function(success:Boolean) {
if (success) {
    my_sound.start(0,1000);
}
};

function playLoopedSound(soundFileName) {
    //this can be directly called from Xerte script icons by
IconID.myFunction(a,b,c);
    my_sound.stop();
    my_sound.loadSound(soundFileName, false);
}
function stopLoopedSound() {
    //this can be directly called from Xerte script icons by
IconID.myFunction(a,b,c);
    my_sound.stop();
}


On Fri, Feb 4, 2011 at 1:58 PM, Mary Ann Ahearn <maryann at moberg.com> wrote:

> Nope, just play/stop looped sounds on button press.  Sound files will be
> determined by code.
>
>
> On Fri, Feb 4, 2011 at 1:43 PM, Dave Burnett <d_b_burnett at hotmail.com>wrote:
>
>>  fast forward/back and scrub bar?
>>
>>
>> ------------------------------
>> From: maryann at moberg.com
>> Date: Fri, 4 Feb 2011 13:39:49 -0500
>>
>> To: xerte at lists.nottingham.ac.uk
>> Subject: [Xerte] Re: Problem looping sound controlled by script - Xerte 2
>> desktop
>>
>> The calls are very simple and I'm working on a flash component to handle
>> it.
>>
>> On Fri, Feb 4, 2011 at 12:46 PM, Dave Burnett <d_b_burnett at hotmail.com>wrote:
>>
>>  I'm looking in the engine .fla trying to deconstruct the sound thingy.
>>
>>
>> ------------------------------
>> From: maryann at moberg.com
>> Date: Fri, 4 Feb 2011 12:28:31 -0500
>>
>> To: xerte at lists.nottingham.ac.uk
>> Subject: [Xerte] Re: Problem looping sound controlled by script - Xerte 2
>> desktop
>>
>> That gave me an idea - what about creating a little flash component that
>> handles playing these troublesome sounds?  It could have play and stop
>> functions that get called on by a xerte button.  The play function would
>> load the mp3, and then handle onLoad as described in the documentation.
>> Xerte wouldn't have to bother about anything except making the call.
>>
>> This seems like a tidy solution to me.  Is there anything I'm overlooking?
>>
>> On Fri, Feb 4, 2011 at 12:02 PM, Dave Burnett <d_b_burnett at hotmail.com>wrote:
>>
>>  I've gotten into the habit of fully qualified paths.
>>
>> _level0.engine.fcommonPagesetup(arg);
>>
>> If you have multiple functions and/or are using asfunctions as well, funny
>> things happen, especially to the args[]
>>
>>
>>
>>
>>
>> ------------------------------
>> From: maryann at moberg.com
>> Date: Fri, 4 Feb 2011 11:56:31 -0500
>>
>> To: xerte at lists.nottingham.ac.uk
>> Subject: [Xerte] Re: Problem looping sound controlled by script - Xerte 2
>> desktop
>>
>> Thanks for suggestion, Dave.  We run all of our xerte rlo files from a
>> flash application that plays in the browser.  I've found that inFunc scripts
>> work in preview, but don't when played in our flash wrapper.  Didn't
>> investigate because it was easier just to duplicate the code. Another layer
>> of Flash sitting under the xerte engine confusing things?  Now that I have a
>> real reason, I think I'll put some time into figuring it out.
>>
>> Tried to use the onLoad event on the sound icon but it never fired.
>>
>> Tried putting the load call in one script and the play call in a separate
>> script but that magic didn't work.
>>
>> Tried setting the isStreaming arg of the loadSound call to true and that
>> actually worked but then I lost looping which was the whole reason I started
>> down this path.
>>
>> hmmmm... I'll play around with this.
>> Thanks
>>
>> On Fri, Feb 4, 2011 at 11:14 AM, Dave Burnett <d_b_burnett at hotmail.com>wrote:
>>
>>  <SCR isFunc="1" name="fdoSound">
>>
>> onLoad event
>> <SCR>fdoSound(myargs);
>>
>> ??
>>
>> ------------------------------
>> From: maryann at moberg.com
>> Date: Fri, 4 Feb 2011 11:01:40 -0500
>> To: xerte at lists.nottingham.ac.uk
>>
>> Subject: [Xerte] Re: Problem looping sound controlled by script - Xerte 2
>> desktop
>>
>> Thanks, Julian, you're absolutely right.
>>
>> But now I'm trying to figure out how to implement this without a button
>> for each task.  When I read the flash documentation it's all about defining
>> a named or anonymous function that is invoked onLoad, which we can't do in
>> xerte, right?
>>
>>
>> On Fri, Feb 4, 2011 at 4:26 AM, Julian Tenney <
>> Julian.Tenney at nottingham.ac.uk> wrote:
>>
>> Is the sound loaded before you call start()? It might need to load before
>> the method works. Try mocking up an interaction with a button to load the
>> sound, a button to make it play, see if that works. In the engine I handle
>> onLoad to control the autoPlay setting, so I think that’s the right
>> approach.
>>
>>
>> *From:* xerte-bounces at lists.nottingham.ac.uk [mailto:
>> xerte-bounces at lists.nottingham.ac.uk] *On Behalf Of *Mary Ann Ahearn
>> *Sent:* 04 February 2011 07:03
>> *To:* Xerte discussion list
>> *Subject:* [Xerte] Re: Problem looping sound controlled by script - Xerte
>> 2 desktop
>>
>>
>>
>> Hi Julian,
>>
>> Things just got weird using this technique to control sound.  Haven't  had
>> time to investigate yet, but thought I'd ask in case the answer is as easy
>> for you as the last one was.
>>
>> soundIcon.sound.stop();
>> soundIcon.loadSound(FileLocation + 'mySoundFile.mp3');
>>
>> soundIcon.sound.start(0,100);
>>
>>
>>
>>
>> Accessing the flash sound object with these calls works fine when I play
>> the rlo file in preview mode. iI also works when I play it from a flash swf
>> file that loads it with this:
>>      attachMovie('Xerte', 'myRLO', 0);
>>
>> But if I publish the rlo and try to play it in a browser, or if I play my
>> flash "wrapper" in a browser I don't hear these sound files.  I do hear the
>> other sounds in my rlo that I'm playing in the standard way.
>>
>> Any ideas as to what's going on?
>>
>> Thanks a million!
>> ma
>>
>> On Tue, Feb 1, 2011 at 11:20 AM, Mary Ann Ahearn <maryann at moberg.com>
>> wrote:
>>
>> Indeed it is!
>> Thanks
>> ma
>>
>> On Tue, Feb 1, 2011 at 10:56 AM, Julian Tenney <
>> Julian.Tenney at nottingham.ac.uk> wrote:
>>
>> Easy.
>>
>>
>>
>> Access the underlying sound object, mySoundIcon.sound and control it
>> directly with the Sound object’s methods
>>
>>
>>
>> myIcon.sound.start(offset, loopCount);
>>
>>
>>
>> *From:* xerte-bounces at lists.nottingham.ac.uk [mailto:
>> xerte-bounces at lists.nottingham.ac.uk] *On Behalf Of *Mary Ann Ahearn
>> *Sent:* 01 February 2011 15:53
>> *To:* Xerte discussion list
>> *Subject:* [Xerte] Problem looping sound controlled by script - Xerte 2
>> desktop
>>
>>
>>
>> I was feeling smug enough about controlling sound via script yesterday to
>> dare to post an answer to someone's question!!  Ha!  The gods don't like
>> hubris.
>>
>> Today everything is different.
>>
>> I've got a button that plays a sound when clicked. I'd like the sound to
>> loop and the button to toggle it on and off
>>
>> It seems to forget its loop value when I start controlling it via script.
>>
>> mySoundIcon.play();
>>
>> However if I just put the sound icon under a button icon and set it to
>> play =1 and loop = 5, then the looping works and all is fine.  I can even
>> stop it and reset it without any problems.  Just can't manage to play it
>> from script more than one time.
>>
>> Tried putting an onSoundComplete event to reset it and play it but it just
>> went mad and looped very bizarrely without ever waiting to finish.
>>
>> Then I tried the getSound route but can't seem to get the timing right so
>> this always returns undefined.
>>
>> Any ideas?  I think I must be missing something very simple.
>>
>> Thanks!
>> ma
>>
>>
>>
>> This message and any attachment are intended solely for the addressee and
>> may contain confidential information. If you have received this message in
>> error, please send it back to me, and immediately delete it. Please do not
>> use, copy or disclose the information contained in this message or in any
>> attachment. Any views or opinions expressed by the author of this email do
>> not necessarily reflect the views of the University of Nottingham.
>>
>> This message has been checked for viruses but the contents of an
>> attachment may still contain software viruses which could damage your
>> computer system: you are advised to perform your own checks. Email
>> communications with the University of Nottingham may be monitored as
>> permitted by UK legislation.
>>
>>
>>
>> _______________________________________________
>> Xerte mailing list
>> Xerte at lists.nottingham.ac.uk
>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte
>>
>>
>>
>> This message and any attachment are intended solely for the addressee and
>> may contain confidential information. If you have received this message in
>> error, please send it back to me, and immediately delete it.   Please do not
>> use, copy or disclose the information contained in this message or in any
>> attachment.  Any views or opinions expressed by the author of this email do
>> not necessarily reflect the views of the University of Nottingham.
>>
>> This message has been checked for viruses but the contents of an
>> attachment
>> may still contain software viruses which could damage your computer
>> system:
>> you are advised to perform your own checks. Email communications with the
>> University of Nottingham may be monitored as permitted by UK legislation.
>>
>>
>>
>>
>>
>> _______________________________________________
>> Xerte mailing list
>> Xerte at lists.nottingham.ac.uk
>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte
>>
>> This message and any attachment are intended solely for the addressee and
>> may contain confidential information. If you have received this message in
>> error, please send it back to me, and immediately delete it.   Please do not
>> use, copy or disclose the information contained in this message or in any
>> attachment.  Any views or opinions expressed by the author of this email do
>> not necessarily reflect the views of the University of Nottingham.
>>
>> This message has been checked for viruses but the contents of an
>> attachment
>> may still contain software viruses which could damage your computer
>> system:
>> you are advised to perform your own checks. Email communications with the
>> University of Nottingham may be monitored as permitted by UK legislation.
>>
>>
>>
>>
>> _______________________________________________ Xerte mailing list
>> Xerte at lists.nottingham.ac.uk
>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte This message and any
>> attachment are intended solely for the addressee and may contain
>> confidential information. If you have received this message in error, please
>> send it back to me, and immediately delete it. Please do not use, copy or
>> disclose the information contained in this message or in any attachment. Any
>> views or opinions expressed by the author of this email do not necessarily
>> reflect the views of the University of Nottingham. This message has been
>> checked for viruses but the contents of an attachment may still contain
>> software viruses which could damage your computer system: you are advised to
>> perform your own checks. Email communications with the University of
>> Nottingham may be monitored as permitted by UK legislation.
>>
>> _______________________________________________
>> Xerte mailing list
>> Xerte at lists.nottingham.ac.uk
>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte
>>
>> This message and any attachment are intended solely for the addressee and
>> may contain confidential information. If you have received this message in
>> error, please send it back to me, and immediately delete it.   Please do not
>> use, copy or disclose the information contained in this message or in any
>> attachment.  Any views or opinions expressed by the author of this email do
>> not necessarily reflect the views of the University of Nottingham.
>>
>> This message has been checked for viruses but the contents of an
>> attachment
>> may still contain software viruses which could damage your computer
>> system:
>> you are advised to perform your own checks. Email communications with the
>> University of Nottingham may be monitored as permitted by UK legislation.
>>
>>
>>
>>
>> _______________________________________________ Xerte mailing list
>> Xerte at lists.nottingham.ac.uk
>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte This message and any
>> attachment are intended solely for the addressee and may contain
>> confidential information. If you have received this message in error, please
>> send it back to me, and immediately delete it. Please do not use, copy or
>> disclose the information contained in this message or in any attachment. Any
>> views or opinions expressed by the author of this email do not necessarily
>> reflect the views of the University of Nottingham. This message has been
>> checked for viruses but the contents of an attachment may still contain
>> software viruses which could damage your computer system: you are advised to
>> perform your own checks. Email communications with the University of
>> Nottingham may be monitored as permitted by UK legislation.
>>
>> _______________________________________________
>> Xerte mailing list
>> Xerte at lists.nottingham.ac.uk
>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte
>>
>> This message and any attachment are intended solely for the addressee and
>> may contain confidential information. If you have received this message in
>> error, please send it back to me, and immediately delete it.   Please do not
>> use, copy or disclose the information contained in this message or in any
>> attachment.  Any views or opinions expressed by the author of this email do
>> not necessarily reflect the views of the University of Nottingham.
>>
>> This message has been checked for viruses but the contents of an
>> attachment
>> may still contain software viruses which could damage your computer
>> system:
>> you are advised to perform your own checks. Email communications with the
>> University of Nottingham may be monitored as permitted by UK legislation.
>>
>>
>>
>>
>> _______________________________________________ Xerte mailing list
>> Xerte at lists.nottingham.ac.uk
>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte This message and any
>> attachment are intended solely for the addressee and may contain
>> confidential information. If you have received this message in error, please
>> send it back to me, and immediately delete it. Please do not use, copy or
>> disclose the information contained in this message or in any attachment. Any
>> views or opinions expressed by the author of this email do not necessarily
>> reflect the views of the University of Nottingham. This message has been
>> checked for viruses but the contents of an attachment may still contain
>> software viruses which could damage your computer system: you are advised to
>> perform your own checks. Email communications with the University of
>> Nottingham may be monitored as permitted by UK legislation.
>>
>> _______________________________________________
>> Xerte mailing list
>> Xerte at lists.nottingham.ac.uk
>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte
>>
>> This message and any attachment are intended solely for the addressee and
>> may contain confidential information. If you have received this message in
>> error, please send it back to me, and immediately delete it.   Please do not
>> use, copy or disclose the information contained in this message or in any
>> attachment.  Any views or opinions expressed by the author of this email do
>> not necessarily reflect the views of the University of Nottingham.
>>
>> This message has been checked for viruses but the contents of an
>> attachment
>> may still contain software viruses which could damage your computer
>> system:
>> you are advised to perform your own checks. Email communications with the
>> University of Nottingham may be monitored as permitted by UK legislation.
>>
>>
>>
>>
>> _______________________________________________ Xerte mailing list
>> Xerte at lists.nottingham.ac.uk
>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte This message and any
>> attachment are intended solely for the addressee and may contain
>> confidential information. If you have received this message in error, please
>> send it back to me, and immediately delete it. Please do not use, copy or
>> disclose the information contained in this message or in any attachment. Any
>> views or opinions expressed by the author of this email do not necessarily
>> reflect the views of the University of Nottingham. This message has been
>> checked for viruses but the contents of an attachment may still contain
>> software viruses which could damage your computer system: you are advised to
>> perform your own checks. Email communications with the University of
>> Nottingham may be monitored as permitted by UK legislation.
>>
>> _______________________________________________
>> Xerte mailing list
>> Xerte at lists.nottingham.ac.uk
>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte
>>
>> This message and any attachment are intended solely for the addressee and
>> may contain confidential information. If you have received this message in
>> error, please send it back to me, and immediately delete it.   Please do not
>> use, copy or disclose the information contained in this message or in any
>> attachment.  Any views or opinions expressed by the author of this email do
>> not necessarily reflect the views of the University of Nottingham.
>>
>> This message has been checked for viruses but the contents of an
>> attachment
>> may still contain software viruses which could damage your computer
>> system:
>> you are advised to perform your own checks. Email communications with the
>> University of Nottingham may be monitored as permitted by UK legislation.
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20110204/214a2a2a/attachment-0001.html>


More information about the Xerte mailing list