Hi, I'm currently using the OSMF framework with my video player. I have a requirement that the server side NetStream object sends a custom message to the client side NetStream object using NetStream.send(). I'm not quite sure how this would be implemented using the framework. Could someone offer any insights?

I believe you would need to subclass NetLoader, override createNetStream, and gain access to the NetStream there. This would allow you to either call NetStream.send() or add a handler to the NetStream. But this is at a high-level, there may be a better way depending on what you're trying to accomplish with NetStream.send().

I'd like to add this functionality across the entire framework without using a plugin. Is this the correct approach? Should I be creating a plugin just for this functionality? That doesn't seem feasible to me. Here's a summary of what I'm trying to accomplish:

We have a system where an audience member watches a presentation that consists of a video or audio stream along with powerpoint slides that get "flipped" at the discretion of a production team which manages the presentation. When the production team clicks the "Push Slide" button, it triggers the NetStream object on the server to call send("FunctionName") and all subscribing clients should receive the message.

If your approach is the correct approach, how would I ensure that all streaming protocols listen for this message? Plugin?

Whether to create a plugin or not depends on the overall requirements and design of your system. Keep in mind that anything you can do with a plugin, you can also do in a standalone player. For example, your plugin could use a NetLoader subclass to invoke NetStream.send(), or the player app could use the NetLoader subclass directly. The former makes it easier for player integration, the latter would make sense if you're just trying to get it working your own player and don't care about distribution.

As for the slide use case, it depends on what the clients need to do in response to the "flip" message. When the client receives this event, do they need to take some action to fetch the next slide? Or is the event solely informational? Does the problem boil down to "how does my VideoElement subclass gain access to the NetStream so that it can add a handler for the send event"? Is it sufficient for the client to gain access to the NetStream.client object (I don't know if the send event gets invoked on the client or on the NetStream)?

The script.command event needs to be heard in my main controller, so i could probably just add an eventlistener on my MediaElement correct? I'm still trying to wrap my head around the best approach. I feel like it's too minor a change to be creating a plugin. Does this code snip change anything about what you said earlier?

Thanks. I still have one more question. So, in the past I've only worked within a custom plugin, so my custom VideoElement was created and passed into the MediaFactoryItem class in my PluginInfo class. I'm not sure how to go about this outside of a plugin.. Could you point me in the right direction.

You can create a MediaFactoryItem and add it to MediaFactory (via addItem). Keep in mind that if you add it to a MediaFactory that already supports video (e.g. DefaultMediaFactory), then the MediaFactory will potentially pick the wrong one. One way around this is to remove the existing one (via removeItem) so that there's no possibility of it being selected.

Or even simpler, just directly instantiate your custom VideoElement (instead of calling MediaFactory.createMediaElement).

I thought the reason for using a MediaFactory is to let the framework decide which type of MediaElement to use? If I directly instantiate my custom VideoElement, aren't I then forcing all requested media to use this custom VideoElement? This isn't desired behavior. Maybe I missed something...

Yes, the MediaFactory allows the framework to decide which MediaElement best handles a resource. If you want to support native VideoElements and your custom VideoElement, then you can add a separate MediaFactoryItem for your custom VideoElement. (I thought you were just trying to replace the default.) The key in this case is to specify something on the resource that will allow your item to know that its a video resource that it should handle. There are quite a few ways to do this.

Were you able to get this working? If so, any chance you could share a code sample of your subclassed VideoElement? We are trying to accomplish pretty much the same thing and I would like to see how you got this to work.

Regards,

- michael

UPDATE: I got this working. It was actually pretty straight forward with the help from above.