Syncing Video in Open Space

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

mmancuso
Posts: 19
Joined: 04 Feb 2012, 23:01

Syncing Video in Open Space

Postby mmancuso » 08 Mar 2012, 00:18

I have a movieclip playing on a tile in Open Space, and I'm wondering how I would go about syncing it so that all users that come into the room see the same movie. Do I need to use Redbox or is there a simpler way to achieve this?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Syncing Video in Open Space

Postby rjgtav » 08 Mar 2012, 23:40

Hi.
Well, is this movieclip replaying over and over again? If so, have you considered saving a RoomVariable for that room which stores the frame at which that movieclip is, and then every time an user joins the room, he retrieves that RoomVariable and gotoAndPlays the MovieClip to that frame? Don't forget to never send the room variable update event to the clients every time you update it, as it will be a waste of resources.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
mmancuso
Posts: 19
Joined: 04 Feb 2012, 23:01

Re: Syncing Video in Open Space

Postby mmancuso » 09 Mar 2012, 00:15

Hey, thanks for the reply. The movie clip is just looping. I have considered setting a room variable, but am stuck at two issues:

1. If there are no users in the room, how will the video loop? The OpenSpace room will cease to exist. Maybe when the last user leaves the room, the current frame of the movie should be saved in the room variable, and when someone is the first person to enter the room, it resumes from that frame?

2. What is a possible algorithm for updating the room variable for the current frame of the movie? I feel like I would need an asynchronous method of some sort that would constantly update the room variable with the current frame of the clip. Unless I set the movieclip as a class variable for each user in the room. Maybe this way I could figure out a way for the new user to grab the movieclip from an existing user in the room, and then just call currentFrame() on that movieclip object?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Syncing Video in Open Space

Postby rjgtav » 11 Mar 2012, 00:13

Hey, hang on, you're complicating too much :)
Well, in this case, I suggest you to control the room variables with a server-side extension. Then, I suggest you to use a room property (using the room.setProperty() and room.getProperty() methods on the server-side) called, for example, "movieTime", which stores the current time in milliseconds.
When the extension is created, you set that value to the current getTimer() (note: getTimer() in AS3 is the function that retrieves the current time in milliseconds, in AS or Java extensions it is a little bit different).
When the an user joins the room, you just get the current time in milliseconds and calculate how much time has passed since the last time an user has entered (or the extension has started, in case this is the first user joining), by simply doing getTimer() - room.getProperty("movieTime"). Then, you know that the game runs at around 30 frames per second and that a second has 1000 milliseconds, so you can calculate how many frames have passed, and send that value to the user.

P.S. After writing this, I've realized that you can just send to the users how much time has passed since the server has started, and then, on the client-side, you do all the calculus needed and gotoAndPlay() the movieClip to the correct frame.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
mmancuso
Posts: 19
Joined: 04 Feb 2012, 23:01

Re: Syncing Video in Open Space

Postby mmancuso » 12 Mar 2012, 21:56

Hey thanks for the reply. On my end we've solidified some technology choices, and it turns out we will be using youtube for the time being to stream the videos. So I'm thinking I'll have a Smartfox Room that shows the movie, and has a timer that sets the movie's current time with an SF extension, then whenever a client joins the room, it grabs the value of the current time from the extension.

I guess with OpenSpace, I'll have to set a trigger so that when a user enters a room, the SmartFox room is loaded. Is there a way to launch a SmartFox Room / UI from within OpenSpace? I guess I could use navigateToUrl, mx:swfLoader or use OpenSpace's add child to add a loader object via 'new Loader().load(new URLRequest("test.swf"))'.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Syncing Video in Open Space

Postby Bax » 13 Mar 2012, 14:44

I'm not sure I understand what you mean.

I guess with OpenSpace, I'll have to set a trigger so that when a user enters a room, the SmartFox room is loaded. Is there a way to launch a SmartFox Room / UI from within OpenSpace? I guess I could use navigateToUrl, mx:swfLoader or use OpenSpace's add child to add a loader object via 'new Loader().load(new URLRequest("test.swf"))'.

Mmm... actually you tell OpenSpace to load a SFS Room, and in turn it reads the Room Variables and loads the map associated with that Room. I don't understand the Loader part.
Paolo Bax
The SmartFoxServer Team
mmancuso
Posts: 19
Joined: 04 Feb 2012, 23:01

Re: Syncing Video in Open Space

Postby mmancuso » 14 Mar 2012, 14:12

Oh ok, I see what you are saying. What if I wanted to load a room that isn't part of the open space world? For example, I have a separate SmartFox room, that now streams video, and I want to be able to launch this room and it's corresponding .swf, from OpenSpace. Is that possible via the OpenSpace API or will I have to leverage the SmartFox API to do this?

Thanks
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Syncing Video in Open Space

Postby Bax » 15 Mar 2012, 08:41

Use the SmartFox API directly.
Paolo Bax
The SmartFoxServer Team
mmancuso
Posts: 19
Joined: 04 Feb 2012, 23:01

Re: Syncing Video in Open Space

Postby mmancuso » 19 Mar 2012, 17:26

K thanks, I'll look in to that.

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 7 guests