Wowza Community

Override play insert Midroll

stream.setName(streamName, streamExt, stream.getExt(), queryStr, 0, -1, -1);

Richard

Hi Richard,

I am getting this error "

The method setName(String, String, String, double, double, int) in the type IMediaStream is not applicable for the arguments (String, String, String, String, int, int, int) ModuleInsertMidRoll/src/com/wowza/com/wowza/ModuleInsertMidRoll ModuleInsertMidRoll.java line 95

" when I try to compile this.

Thanks.

Hi Richard,

I finally was able to compile this. I copied same into live WMS and added below into Application.xml /Properties

MidRoll

Extremists.flv

FeatureBreak

10000

Nothing seems to be showing as as Roll Over Ads. Is there are other thing that I needed to do?

Thanks.

I was thinking that “Extremists.flv” would show as a Roll Over “Ads” in which application the following property/properties are inserted.

"

MidRoll

Extremists.flv

FeatureBreak

10000

"

Thanks.

May be am doing this wrongly. I am trying to use this with the “Server listener that starts streams with playlists and schedules from smil file”. So what I did was to add the "

MidRoll

Extremists.flv

FeatureBreak

10000

"

to the application.xml am using in this case a live stream and thought that “Extremists.flv” would play as a Roll Over at FeatureBreak. But from what you said above it seems that is not how this works. Correct?

Thanks.

Thanks got that picture better now. So with the “Stream controller example” you pointed to, could that be in the form of using the Stream class scheduler to play a stream for xxx of time, the plays for say 30 mins and then the scheduler continues the stream after the 30mins. The AdvertRoll would have played for say 20secs before reverting back to the next file or continue from where/when it stopped. This is the only way that came to my mind now perhaps you have better suggestion.

What I mean is this

I see.

Many thanks

Hi Richard,

I am experiencing some troubles making it work. My goal is to insert an ad at the beginning of a requested video.

So here is my code:

String stream_name = params.getString(PARAM1);
System.out.println("Inserting ad for stream: " + stream_name);
AMFDataList custom_data_list = new AMFDataList();

// The ad
custom_data_list.add("play");
custom_data_list.add(0.0);
custom_data_list.add("null");
custom_data_list.add("mp4:/uploads/medias/advert.mp4");
custom_data_list.add(new AMFDataItem(0)); // start
custom_data_list.add(new AMFDataItem(20)); //duration
custom_data_list.add(new AMFDataItem(true)); //reset
invokePrevious(this, client, function, custom_data_list);

// The movie
custom_data_list.set(PARAM1, new AMFDataItem(stream_name));
custom_data_list.set(PARAM2, new AMFDataItem(0));
custom_data_list.set(PARAM3, new AMFDataItem(-1));
custom_data_list.set(PARAM4, new AMFDataItem(false));
invokePrevious(this, client, function, custom_data_list);

The problem is that my ad does not play, the movie immediately plays.

If I remove the movie section, the ad alone plays.

Can you explain a little what the options are for, I don’t really understand the physics here.

Thanks

EDIT: by the way I also implemented IMediaStreamFileMapper#streamFileForRead, maybe that’s why the movie immediately starts playing?

EDIT2: is it possible to prevent users from scrubbing the timeline while watching the ad?

EDIT3: actually for my ad to play, I must specify a duration of -1 otherwise it will not play at all (even when defined alone with no movie following), why is that? Why can you define a duration and not me???

EDIT4: Richard is your system compatible with a player like Flowplayer? Or should I code my own player? I suspect Flowplayer to stop playing after the ad is finished, so it doesn’t move on to the movie that follows.

EDIT5: ok I got it working in Flowplayer, one must set the live option to true so that it carries on.

Hi Richard,

When wowza switches from one video to another, is an event (or something else) dispatched to the client?

I’d like to be able to deactivate the timeline when an ad plays, and then reactivate it when the movie resumes. On the client side I need to detect these switches.

I’m definitely having a problem when I specify a duration for a video, it simply does not play, and it gets skipped to the next video that has a duration of “-1”, i.e: play until the end.

What’s wrong?

In order to notify the client of switched stream I tried using the following method call:

stream.send("switch_movie");
  1. I’m not sure the call was dispatched by wowza

  2. If the call was dispatched how to intercept it on the client side?

EDIT: it didn’t get called, because calling stream.close() inside this play method does not close the stream as expected. So how to do that?

EDIT2: actually I cannot notify the client from within this play method, I need to use another trick.

EDIT: I am trying to implement the seek method so that I can block seeking on the server-side which is even better!

The slash doesn’t seem to be a problem, it works the same whether the slash is there or not. Did you test for the duration issue? I still cannot tell Wowza to play a video for a limited amount of time, only a duration of -1 will let the video play :frowning:

While I’m at it, is it possible to know which item of the ‘playlist’ is currently playing?

Let’s say client requests a stream called: Matrix4.mp4

The server would inject an ad at the beginning: wowza_ad.mp4

Now the stream is playing and it’s currently in the middle of the ad, and the client wants to seek past the ad, hmmm no good. So in my seek() method is it possible for the server to know that it’s currently playing the wowza_ad.mp4 file and that it should not let the client seek?

At first I was trying to get the stream name, but it’s a wrong approach as it always returns “Matrix4.mp4” whether it’s currently playing the ad or not.

Thanks for any suggestion :slight_smile:

Yes, but in order to completely prevent evil users from bypassing the ads, on the server I must be able to deactivate the seeking feature when the current video being played is an ad. So how to identify ads when they are being played :confused:

Ok I was able to retrieve the current video being played, so my anti seek system is now working.

So back to my last questions:

  1. Were you able to reproduce my duration problem?

  2. When injecting ads to my movie, the duration is now incorrectly reported, is it possible to return to flowplayer (or whatever player) the new total duration, i.e: movie_duration + ∑advert_durations ?

Thanks for your invaluable help :cool:

Richard! How didn’t we spot such a stupid mistake! The duration is in MILLIseconds! So a value of 10, was 10ms, no wonder why I couldn’t see the movie play! :stuck_out_tongue:

I was cracked up when I realized that!

And about notifying the player about the correct total duration, do you have any idea how to do that? Once I think I encountered something like that, but I can’t find it anymore.

Thanks Richard for your snippet of code, and merry Xmas :slight_smile:

Does it work with Cupertino streaming? I tested codes above for Flash player and it’s working just fine. But it doesn’t seem to work with iPhone

Updated post for calculated duration.

Richard

Hi Richard,

In the play() method, you don’t have a reference to the stream to set the property “overrideDuration”. This can be done in the “onStreamCreate” method:

public void onStreamCreate(IMediaStream aMediaStream) 

And it works!

Olivier