Skip to main content
Participating Frequently
June 29, 2012
Question

How do I tell FMS to only serve a section of a file using server-side ActionScript?

  • June 29, 2012
  • 1 reply
  • 2519 views

We have a bunch of mp3 files on our server and we'd like to serve only particular sections of particular files to users.  For example, hello.mp3 might be four minutes long, but when user 1 tries to play it, he should only be able to play the section from 0:30 to 1:00, whereas user 2 should be able to play the whole thing.

I'm coming from a background using Wowza Media Server, where this is fairly easy to achieve: http://fmsguru.com/showtutorial.cfm?tutorialID=78.

Wowza doesn't require any change to the player (it doesn't call any special methods), so I'm looking for the same here.

I've been fiddling around with the main.asc file and the "Server-Side ActionScript" API to try and achieve something similar.  In particular I've found the Stream.play method, which seems relevant.  But I can't figure out how to attach a handler to a "play" event; all the examples I've seen only attach to Application.onConnect, which doesn't seem to include a connection to a particular file, which I need in order to determine the section that can be played.

So I'd like to do something along the lines of this (this is completely made up and doesn't follow any of the APIs; it's just an illustration of what I'm trying to achieve):

application.onConnect = function(client) {

   client.onPlay = function(stream) { // Client.onPlay doesn't exist; what should I do here?

       var section = getStreamSection(client, stream);

       stream.play(section.start, section.end);

    };

};

var getStreamSection = function(client, stream) {

   return { start: 30, end: 60 }; // Return value is based on the user's credentials and the file they're trying to stream

};

This topic has been closed for replies.

1 reply

June 29, 2012

The stream.play function needs to be used as follows :

myStream.play(streamName, [startTime, length, reset, remoteConnection, virtualKey])

You can find more details about the function here : http://livedocs.adobe.com/flashmediaserver/3.0/hpdocs/flashmediaserver_SSLR.pdf

Hope this helps.

Thanks,

Apurva

amagee__Author
Participating Frequently
June 29, 2012

Sorry, I'm aware of the function's signature but I still have no idea how to fit it into the situation I've described.

amagee__Author
Participating Frequently
July 3, 2012

Can anyone help?  I still have no idea how to write an asc plugin to allow a user to play only a section of a track, and no more.  The documentation doesn't seem to be helpful at all for this problem.