(sorry, I was in Eclipse-mode and hit Ctrl-S)
============= MyDynamicStreamTrait.as ==================
public class MyDynamicStreamTrait extends MediaTraitBase
public function MyDynamicStreamTrait( resource:URLResource = null, timeTrait:MyTimeTrait = null, loadTrait:MyLoadTrait = null )
super( MediaTraitType.DYNAMIC_STREAM );
this._timeTrait = timeTrait;
this._loadTrait = loadTrait;
this._netStream = loadTrait.netStream;
this._resource = resource;
trace( 'created' );
/* various logic */
As soon as the 'new MyDynamicStreamTrait(wrappedElement.resource, mytt, loadTrait);' statement is executed, the ArgumentError is thrown.
None of my other trait extensions is behaving this way.
Any idea on what's happening?
Traits are not meant to be extensible, they're a fixed set of APIs for controlling media in the system. So instead of subclassing MediaTraitBase, you should have your custom trait extend DynamicStreamTrait. Doing so will allow other parts of the system that are dynamic-streaming-aware to work with your implementation.
The first version of the class was actually extending DynamicStreamTrait, but the same error happened, no difference.
Anyway I have multiple extended traits, most of all for seek-ahead and for time calculations, and I never met any problem like this.
Maybe I'm doing it the wrong way:
The point is that I have different progressive streams for the same content, then, when a user indicates a quality change, I use some metadata of the newly selected stream to know when to open the new stream, and oon the exact time of the keyframe of the new stream I make the switch.
This behavior seems what's intended "semantically" for a DynamicStreamTrait without autoSwitch.
How could I do this without extending DynamicStreamTrait?
Extending DynamicStreamTrait is an appropriate solution, I was simply pointing out that extending MediaTraitBase is not. My hunch is that the ArgumentError is generated because you're passing the wrong set of parameters into DynamicStreamTrait's constructor (via the "super" call). The params should be:
autoSwitch:Boolean, currentIndex:int, numDynamicStreams:int
Note that all have optional values. There's no need to pass in the MediaTraitType.DYNAMIC_STREAM_TRAIT param, as that's automatically generated by the DynamicStreamTrait class. If that's not your issue, please repost with the trait class that extends DynamicStreamTrait.
This is the constructor of the first attempt to extend the DynamicStreamTrait.
public function MyDynamicStreamTrait( resource:URLResource = null, timeTrait:MyTimeTrait =
null, loadTrait:MyLoadTrait = null )
super( false, 0, 4 );
(assign the custom traits to be referenced...)
Anyway the constructor breaks before even executing an instruction.
By the way, I'm using sprint 9, not trunk.
I don't see anything wrong with that snippet of code. Can you post a small, compilable sample?