Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

A problem with images display

$
0
0

Hello,

I am trying to display images like a movie. I am loading the images from a container called "_ImManger" that returns a MemoryStream to a bindable ImageSoure.
this runs in a closed loop with a delay.
It works fine displaying the images BUT, every couple of seconds or so it gets stuck. (e.g. the ui freezes for a moment...)
I think this is a memory issue...

Any ideas?...

CODE:

Loop:

TimeSpan freq = TimeSpan.FromMilliseconds(1000.0 / 60.0); // freq = 1/fps (frames per sec)

        while (_Play) {
            try {

                DateTime currentTime = DateTime.Now;

                PlayerImageSource = ImageSource.FromStream(()=> {return _ImManger.GetImage();}); 

                await Task.Delay((int)freq.TotalMilliseconds);

                _LastTime = currentTime;

            } 
            catch (Exception ex)
            {
                //TODO
            }
        } 

Bindable element:

public ImageSource PlayerImageSource {
set { SetProperty (ref _ImageSource, value); }
get { return _ImageSource; }
}

Thanks!


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>