- Converting Mobile Bristol mediascapes
Converting Mobile Bristol mediascapes
As mediascapes are a relatively new medium Hewlett Packard are continually striving to improve the tools and facilities for creating and playing them. The drawback with this is that as the mscape maker and the mediascapes that it produces become more sophisticated the older mediascapes made with earlier versions of the mscape maker no longer work correctly. If you are a frequent user of computers for other things you may be familiar with this situation with such things as importing word processor documents into newer versions of the word processor. Fortunately, it is possible to convert the older mediascapes so that they become new mediascapes. The new mscape maker has been designed to do as much of the conversion for you, however it cannot do everything and so in some cases there are certain items that will need your input in order to be correctly converted.The conversion process
When you import an older Mobile Bristol Mediascape into the new mscape maker much of the conversion happens automatically. However, not all of it does and there are three areas where you may have to intervene to ensure that the conversion process has been successful.To import a mediascape you do the following
Firstly, the conversion process is as thorough and as fail safe as it can be, but, as with any computer based activity, it is a good idea to make a back up copy before you start doing anything, just in case. From within the mscape maker select File and choose the Convert MB menu option. Choose the mediascape you want to import and convert. A warning message will appear alerting you to the conversion. If you go ahead with it then the conversion is carried out and the new version of the mediascape is created and saved with the extension ‘.msl’. When the conversion is finished a report box will appear indicating the success of the conversion. The mediascape is now converted and is ready for further editing. You may have to make adjustments by hand in the following situations:Rewriting of event scripts
The automatic conversion process does its best to convert the event scripts. This conversion is difficult and thus what takes place is a best guess at conversion. The original script is enclosed in comments along with the best guess conversion and then the user must amend them. Basically in the comments it says; ‘This is what you had originally, and this is roughly what I think it should be now’. For example where an event script in a Mobile Bristol mediascape may have been this:<if cond="inRegion(regions$frog) and variables$frog=0"> <then> <playMedia media="media$frog" volume="100" loop="false" position="0" fade="0" delay="0"/> </then> <else> <DisplayHTMLImage source="'frog.jpg'" tag="'ImageTag'" background="'88aaff'"/> </else> </if>After conversion it will appear as this:
/*
*************************************************************
The handler code in Mobile Bristol format looked like this:
*************************************************************
<if cond="inRegion(regions$frog) and variables$frog=0">
<then>
<playMedia media="media$frog" volume="100" loop="false" position="0" fade="0" delay="0"/>
</then>
<else>
<DisplayHTMLImage source="'frog.jpg'" tag="'ImageTag'" background="'88aaff'"/>
</else>
</if>
*************************************************************
For the current version, try this instead:
*************************************************************
if (frog_reg.IsInside && frog_var.Value == 0)
{
frog_audio.Volume = 100; // May not be needed. Check the values of the properties on this object.
frog_audio.Loop = false; // May not be needed. Check the values of the properties on this object.
frog_audio.FadeDuration = 0; // May not be needed. Check the values of the properties on this object.
frog_audio.Play();
}
else
{
frog_image.Show();
}
*/
Such scripts can either be sorted out ‘by hand’ and re-written using the new style of scripting with reference to the ‘phrase book’ below.
Alternatively, you can remove the entire script and generate the new scripts by doing drag and drop operations within the mscape maker.
What happens during the conversion?
For completeness it may be useful to know some of the steps that take place during the conversion although it is not vital that you understand this in order to carry out conversions. The mscape maker creates a MapLib file for the mediascape and links it into a place object, adding any regions and speakers in the original mediascape. A content folder is created and all the referenced content files are moved there. If required, a web root folder is created and all HTML pages are moved there. The original .mbw, .mbp and .mbs files that made up the mediascape are moved to an Archive sub-folder. Any deprecated objects (such as notifications and functions) are copied to a .del file in the Archive sub-directory.MSL
The Mobile Bristol scripting language was based on something called XML, this meant that all parts of it were enclosed in ‘pointy brackets’, the new scripting language is called MSL, which stands for ‘Mediascape Scripting Language. MSL structures mediascapes into four sections: Sensors, which are used to hold information about sensors used to trigger contextual events, such as GPS. Media, used to hold the audio, images, videos etc, that are used in the mediascape. Tools, to hold useful functions, for example the Playlist and the Logger. State, used to hold variables. MSL is based on a language called C sharp (see below) so there are curly brackets, but a lot less of them than with Mobile Bristol scripts. Here is a snippet of Mobile Bristol script:
<if cond="variabls$count = 1">
<then>
<playMedia media="media$frogs" volume="100"/>
</then>
<else>
</else>
</if>
and here is the same snippet converted to MSL script:
if (count.Value == 1)
{
frogs.Volume = 100;
frogs.Play();
}
MSL and other languages you might be familiar with
C# has strong influences from languages like C++, Java and Delphi, so if you have some familiarity with any of those you may recognise elements in C# and thus the MSL used in mediascapes. The syntax of MSL also has a few similarities with the syntax of Flash ActionScript and Javascript so again some familiarity with these may come as an advantage when dealing with MSL.Things to note with MSL
There are less terms and not every term in the script is enclosed in brackets, so it is a lot easier to write. You don’t have to state where things like media resources are coming from so you can say ‘frogs’ instead of having to say ‘media$frogs’. Actions and attributes of objects like media resources are refereed to in terms of the object that they relate to. So to play ‘frogs’ with a certain volume in Mobile Bristol scripting you used to say:<playMedia media="media$frogs" volume="100"/>In effect; ‘I want to play something, this is what I want to play and this is how loud I want to play it’. With MSL you now say:
frogs.Volume = 100; frogs.Play();Here you are saying; ‘Set the frog’s volume to this’ then ‘Play the frogs’.
MSL 'Phrase book'
If you are used to writing scripts in Mobile Bristol then this section shows the terms you will be used to and how they should be done within MSL. 'Manual page' refers to the Mobile Bristol Manual which you may already be familiar with if you are programming in the Mobile Bristol environment.Using actions
| Name | playMedia |
| Manual page | 71 |
| Example |
<playMedia media="media$harp" volume="100" loop="false" position="0" fade="0" delay="0"/> |
| MSL rewrite |
harp.Volume = 100; harp.Loop = false; harp.FadeDuration = 0; harp.Play(); |
| Comments | Delay and position parameters are not supported |
| Name | stopMedia |
| Manual page | 72 |
| Example |
<stopMedia media="media$harp" fade="0" delay="0"/> |
| MSL rewrite |
harp.FadeDuration = 0; harp.Stop(); |
| Comments | Delay parameters is not supported |
| Name | setMediaVolume |
| Manual page | 72 |
| Example |
<setMediaVolume media="media$harp" volume="50" fade="0" delay="0"/> |
| MSL rewrite |
harp.Volume=50; |
| Comments | fade and delay parameters are not supported for volume changes |
| Name | stopAll |
| Manual page | 72 |
| Example |
<stopAll fade="0" delay="0"/> |
| MSL rewrite |
Audios.StopAll(); |
| Comments | Audios is the container for audio objects in MSL |
| Name | setVolumeAll |
| Manual page | 73 |
| Example |
<setVolumeAll volume="75" fade="0" delay="0"/> |
| MSL rewrite |
n/a |
| Comments | It is not possible to set an overall volume for all audios |
Source actions
Sources in Mobile Bristol map onto Speaker objects in MSL.| Name | playSource |
| Manual page | 74 |
| Example |
<playSource source="sources$source1" volume="100" loop="false" position="0" fade="0" delay="0"/> |
| MSL rewrite |
source1.AutoPlay = true; |
| Comments | MSL speakers do not have play and stop methods but a similar effect can be achieved by toggling the boolean property AutoPlay. All other intended effects, such as setting a volume on a source, must now be applied to the speaker's associated audio object. |
| Name | stopSource |
| Manual page | 74 |
| Example |
<stopSource source="sources$source1" fade="0" delay="0"/> |
| MSL rewrite |
source1.AutoPlay = false; |
| Comments | MSL speakers do not have play and stop methods though a similar effect can be achieved by toggling the boolean property AutoPlay. |
| Name | setSourceVolume |
| Manual page | |
| Example |
<setSourceVolume media="sources$source1" volume="100" fade="0" delay="0"/> |
| MSL rewrite |
n/a |
| Comments | It is not possible to directly set the volume of a speaker, but it can be set for the associated audio object |
Image actions
Image display in Mobile Bristol was rather sparsely supported with a single action. This maps indirectly onto one of the rich new image capabilities in mscape.
| Name | DisplayHTMLImage |
| Manual page | 80 |
| Example |
<DisplayHTMLImage source="'coins.jpg'" tag="'ImageTag'" background="'88aaff'"/> |
| MSL rewrite |
coinsImage.Show(); |
| Comments | It is not possible to display an image directly from file in mscape. Import the image file into an Image object and call its Show method. |
URL actions
URL actions in Mobile Bristol allowed local audio files to be played without needing a corresponding media object. This capability is not supported in mscape.
| Name | playUrl |
| Manual page | 75 |
| Example |
<playUrl url="'files\mySound.mp3'" alias="'mysound'" volume="100" loop="false" position="0" fade="0" delay="0"/> |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape - import audio file into the mediascape as an audio object |
| Name | stopUrl |
| Manual page | 76 |
| Example |
<stopUrl alias="'mysound'" fade="0" delay="0"/> |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape - import audio file into the mediascape as an audio object |
| Name | setUrlVolume |
| Manual page | 77 |
| Example |
<setUrlVolume alias="'mysound'" volume="75" fade="0" delay="0"/> |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape - import audio file into the mediascape as an audio object |
Debug actions
It was possible to trace a text message to file in Mobile Bristol. In mscape this capability is provided by the Logger object.
| Name | trace |
| Manual page | 77 |
| Example |
<trace text="'Hello World'"/> |
| MSL rewrite |
Logger.Log("Hello World");
|
| Comments | Use Logger object |
| Name | setTraceLevel |
| Manual page | 77 |
| Example |
<setTraceLevel level="5"/> |
| MSL rewrite |
n/a |
| Comments | Not supported in mscpae |
Logic actions
Mobile Bristol only supported one form of flow control - conditional expressions using the if-then-else pattern.
| Name | if |
| Manual page | 78 |
| Example |
<if cond="variables$count = 1">
<then>
<playMedia media="media$frogs" volume="100"/>
</then>
<else>
</else>
</if>
|
| MSL rewrite |
if (count.Value == 1)
{
frogs.Play();
}
|
| Comments | Unlike in Mobile Bristol, empty else blocks are not required in mscape |
| Name | set |
| Manual page | 78 |
| Example |
<set var="'variables$var1'" value="123"/> |
| MSL rewrite |
var1.Value = 123; |
| Comments | In mscpae, values are assigned to variables using their Value property. |
Flash actions
| Name | sendFlashMessage |
| Manual page | 79 |
| Example |
sendFlashMessage(‘FUNC’,'updateScore',200 ) |
| MSL rewrite |
flashMovie1.RunActionScriptWithParams("updateScore",200)
|
| Comments | The use of Flash has changed considerably in mscape. See dedicated help pages for detail. |
HTML actions
| Name | NavigateHTMLPage |
| Manual page | 80 |
| Example |
<NavigateHTMLPage source="'files\newpage.html'"/> |
| MSL rewrite |
WebPages.LoadUrl('files\newpage.html');
|
| Comments | Relative URLs in mscape are relative to the content folder, rather than the script folder as in Mobile Bristol. |
Event actions
In Mobile Bristol it was possible to simulate the effect of a change in the user's location. This is no longer possible.
| Name | raise |
| Manual page | |
| Example |
<raise event="events$mbLocationChangedEvent" x="11" y="22"/> |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
Functions
Functions in Mobile Bristol are used to return a value that can then be included in an expression. For example, the function inRegion might be used as follows:
<if cond="inRegion(regions$myRegion)">
<then>
<trace("'In region'")/>
</then>
<else>
</else>
</if>
In mscape, many, though not all, of these functions are now implemented as read-only properties on the appropriate object. So, the previous example might be written:
if (myRegion.IsInside)
{
Logger.Log("In region");
}
Standard translations for the MB functions are listed below:
Region functions
| Name | enteredCount |
| Manual page | 83 |
| Example |
enteredCount(regions$myRegion) |
| MSL rewrite |
myRegion.EnteredCount |
| Comments |
| Name | inRegion |
| Manual page | 83 |
| Example |
inRegion(regions$myRegion) |
| MSL rewrite |
myRegion.IsInside |
| Comments |
Media functions
| Name | getMediaPosition |
| Manual page | 81 |
| Example |
getMediaPosition(media$story) > 2000) |
| MSL rewrite |
story.Played |
| Comments | There are no functions to discover how much of an audio has been played in mscape. Very often, this function was used in Mobile Bristol to restart an audio from the position it was last played to. In mscape, this intention can be achieved directly through the Pause and Play methods on audio objects. |
| Name | getMediaMaxPosition |
| Manual page | 80 |
| Example |
getMediaMaxPosition(media$story) > 2000) |
| MSL rewrite |
n/a |
| Comments | There are no functions to discover how much of a media has been played in mscape |
| Name | isMediaOn |
| Manual page | 81 |
| Example |
isMediaOn(media$story) |
| MSL rewrite |
(story.Playing || story.Paused) |
| Comments | The Mobile Bristol notion of an audio being on is represented by one of two conditions in mscape |
| Name | isMediaPaused |
| Manual page | |
| Example |
isMediaPaused(media$story) |
| MSL rewrite |
story.Paused |
| Comments |
| Name | isMediaPlaying |
| Manual page | 81 |
| Example |
isMediaPlaying(media$story) |
| MSL rewrite |
story.Playing |
| Comments |
| Name | isMediaFading |
| Manual page | 81 |
| Example |
isMediaFading(media$story) |
| MSL rewrite |
story.Fading |
| Comments |
URL functions
Because it is not possible to play audio files directly in mscape, none of the associated URL functions are supported.
| Name | getUrlMaxPosition |
| Manual page | 82 |
| Example |
getUrlMaxPosition(alias) |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
| Name | getUrlPosition |
| Manual page | 82 |
| Example |
getUrlPosition(alias) |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
| Name | isUrlOn |
| Manual page | 82 |
| Example |
isUrlOn(alias) |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
| Name | isUrlPaused |
| Manual page | |
| Example |
isUrlPaused(alias) |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
| Name | isUrlPlaying( |
| Manual page | |
| Example |
isUrlPlaying((alias) |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
| Name | isUrlFading |
| Manual page | |
| Example |
isUrlFading(alias) |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
Source functions
It is not possible in mscape to express functions on a speaker related to its associated audio object. These calls will need to be rewritten as accessing the associated audio object's properties.
| Name | getSourceMaxPosition |
| Manual page | 82 |
| Example |
getSourceMaxPosition(source) |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
| Name | getSourcePosition |
| Manual page | 82 |
| Example |
getSourcePosition(source) |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
| Name | isSourceOn |
| Manual page | 82 |
| Example |
isSourceOn(source) |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
| Name | isSourcePaused |
| Manual page | 82 |
| Example |
isSourcePaused(source) |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
| Name | isSourcePlaying |
| Manual page | 82 |
| Example |
isSourcePlaying(source) |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
| Name | isSourceFading |
| Manual page | 82 |
| Example |
isSourceFading(source) |
| MSL rewrite |
n/a |
| Comments | Not supported in mscape |
Location functions
Mobile Bristol had an implicit model of the user's unique location which could be accessed by the functions below. In mscape, the user's location is only known during a Place object's OnLocationChanged event. If the last location is needed later, the author should save the current location in state variables during the event handler, eg:
myX.Value = x; myY.Value = y;
| Name | getUserLocationX |
| Manual page | 83 |
| Example |
getUserLocationX() |
| MSL rewrite |
n/a |
| Comments | Not supported |
| Name | getUserLocationY |
| Manual page | 83 |
| Example |
getUserLocationY() |
| MSL rewrite |
n/a |
| Comments | Not supported |
Random function
Allows a random number to be generated in the interval from min to max inclusive. In mscape, this capability is provided by the library object Random which must be created before use.
| Name | rand |
| Manual page | 83 |
| Example |
rand(0, 2) |
| MSL rewrite |
(new Random()).Next(0,3) |
| Comments | Note that the number generated by the mscape Random object will be less than the second parameter rather than less-than-or-equal-to as in Mobile Bristol |
Changes if you use Flash movies
If your mediascape includes a Flash movies then you will have to do the following. Make changes to the original Flash file and re-publish as a new Flash movie Include the Flash movie into the new mediascape Rewrite parts of the Flash ActionScript and mediascape scripts if requiredMake changes to the original Flash file and re-publish as a new Flash movie
Copy the mediascape.as file into the same directory as the Flash file. (You can find the ‘mediascape.as’ file in the help file under; ‘User Interfaces - Adobe Flash’. It is linked to under the heading ‘Allowing Communication with the Mediascape’.) Change the include line in the Flash ActionScript from:#include "mb.as"so that it includes this new include file, like this:
#include "mediascape.as"Publish a new Flash movie from this file. If your Flash file has ActionScript that passes data to the mediascape then you will need to change this before publishing the movie. See below for more on this.
Include the Flash movie into the new mediascape
Add the new Flash movie object by right clicking on the media object in the left hand bar of the mscape maker. Then give the file name of the Flash movie when prompted for it.Rewrite parts of your scripts if required
If you use scripting on either the Flash movie side or the mediascape side to communicate then you will need to change this as follows: If you have used ActionScript to send data from the Flash movie to the mediascape then: In the ActionScript you will have statements to send data like this:
sendXML("one", "two");
In order to work in MSL these should be changed to look like this:
fscommand("one", "two");
When you do this from within the ActionScript of your Flash movie you have to have a corresponding bit of script in the mediascape to listen out for the arrival of data being communicated in this way. This too has changed to that the old mediascape script event called:
mbFlashEventshould be replaced by the new event:
OnFsCommandIf you have used scripting in the mediascape to send data from the mediascape to the Flash movie then: In the mediascape script you will have calls like this:
sendFlashMessage("FUNC", "updateGPS", "fixed");
Where FUNC declares that you are calling a function, the ‘updateGPS’ is the name of the function and ‘fixed’ is the parameter that you are passing to this function. In the new MSL script in the mediascape you will need to replace such calls with:
mymovie.RunActionScriptWithParams("updateGPS", "fixed");
Or
mymovie.RunActionScript("updateGPS");
Here ‘mymovie’ is the name of the flash movie object. In order to do this you will need to know the name that you gave to the Flash movie object when you imported it (as above), this is usually the name of the Flash movie file, although you can change what it is called within the mediascape if you want to.
The actual script that forms the function being called (‘updateGPS’ in this case) does not need to be changed at all.