MediaElement1.Source = New Uri ("... ...");

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
ric
Posts: 17
Joined: Wed Nov 16, 2011 4:35 am

MediaElement1.Source = New Uri ("... ...");

Post by ric »

Hello everyone, I've the following trouble:

I need to show the stream from an Axis M7001 Video Encoder, that allows 20 max views.

If I open from 4 different computers the page with the MediaElement declared as shown below:

void Video_Opened(System.Object sender, System.EventArgs e)
{
MediaElement1.Source = new Uri ("axrtsphttp://192.168.1.101/axis-media/media.amp", UriKind.Absolute);
}

and from one of those I rapidly change page from that to another and back, when I reach the 20 times allowed the stream isn't available anymore.

The question is:

If I add this:

void Video_Closed(System.Object sender, System.EventArgs e)
{
MediaElement1.Source = null;
}

Is enough to free the MediaElement1.Source every time I go away from the viedo page? If not what could I do?

Bye
Ric

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: MediaElement1.Source = New Uri ("... ...");

Post by mark.monroe »

Hi Ric,

How are you calling your Video_Opened function? Each time it is called, it will create a connection to the Axis server. Can you not keep track of the 'Uri ("axrtsphttp://192.168.1.101/axis-media/media.amp", UriKind.Absolute)' object so that you do continually make new connections to the Axis server? Are you already doing that?
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

ric
Posts: 17
Joined: Wed Nov 16, 2011 4:35 am

Re: MediaElement1.Source = New Uri ("... ...");

Post by ric »

At the moment I open a new connection every time I open the Video page. But I don't think the problem i due to this calling. The video server is limited to 20 views and even if I change the way of calling that when I'll rech the 20 views The stream will stop.

In my opinion I think the solution is to Close the video stream every time I close the page, in this way I think the number of views will remain always 4.

Could you help me?

Thanks,
Ric

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: MediaElement1.Source = New Uri ("... ...");

Post by mark.monroe »

Hi Ric,

Often times with http connections they are held open for a while, just in case the client reconnects to the server again. By setting MediaElement1.Source = null you will not send a command to the http server to shut down the connection.

The only thing I can think of is trying the stop method on the media player, this.MediaPlayer1.Stop(). If that doesn't work, I would look at the Axis server and see if there are any timeouts that you can reduce so that it closes the video connection quicker once a client is no longer receiving video.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

ric
Posts: 17
Joined: Wed Nov 16, 2011 4:35 am

Re: MediaElement1.Source = New Uri ("... ...");

Post by ric »

I tried to use the Stop() method, but without using this before my object, like this:

MediaElement1.Stop();

It doesn't work and it generate an exception, is this caused something wrong in the code?

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: MediaElement1.Source = New Uri ("... ...");

Post by mark.monroe »

In iX 2.0 on a PC the stop function works. What version of iX are you using? In iX 2.0 the media player's default name is MediaPlayer1.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

ric
Posts: 17
Joined: Wed Nov 16, 2011 4:35 am

Re: MediaElement1.Source = New Uri ("... ...");

Post by ric »

Currently I'm using the 1.31 version. I'll check as soon as possible if the 2.0 version will fix this problem.

Thank you,
Ric

Post Reply