How do I tell FMS to only serve a section of a file using server-side ActionScript?
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
};
