Random DataSet entry

I’m trying to get a random row from a Data Set.

I’m using the follow sql code to do it:

id = FLOOR(1+ RAND()*8)

It ALMOST worked fine. The random goes well, but sometimes it results nothing.

What I’m doing wrong? There is another way to do this?

Well… I’m testing 2 ways to do this. And booth seems to work.

  1. I put a Formula column on data set, and use the this: " RAND()*(100-1)+1 ". In the ticker, I set to order the fields by this column. It works!

  2. I use the follow SQL: " id = FLOOR(1+ RAND()*100)LIMIT 1 ". The same thing I posted here before. On the CMS it will not work sometimes, but the player seems to handle perfectly.

Now, here is the deal:
The text shows fine, but the images no. Some rows show the images, others no…
The dataset are populated with 100 entries. Could it be a bit lazy to download all the images?

Where can I see the downloaded files on the Client?

If I upload all images on the CMS, it will work better than use a link on the data set?

Option 1 is probably better - with Option 2 you are most likely generating a random ID that doesn’t exist.

The images could be a little lazy at downloading, but you would only expect that the happen the first couple of times the results were returned.

I suppose the problem in your case is that each time the Player requests another copy of the dataset it will trigger a download of the image - if for some reason that takes too long, it will show without it (it actually shows a 1px transparent square and then waits for the actual image to arrive).

It probably gets worse when the update interval is set to something very low, because its a constantly moving target - Player requests new dataset, CMS serves it and downloads image, CMS tags image for download onto Player, Player requests new dataset before it even receives the image.

See what i mean?

As the time passed, most of images were downloaded. BUT, there is other 10 clients to download this content.

Is there a way to make the player download all this content at once?

I think you’d find that they would slowly lose them again for the reasons previously stated - i.e. only the results of the Ticker are cached, not the entire DataSet (which would be impractical). The results of the Ticker are changing with each request.

To do what you wanted you’d have to have the whole dataset returned each time and use some JavaScript to select the one you wanted to actually display (hiding the others).

You’d probably need a custom module to do that.

Is there a command like wget to use in Android? So I could run it one time with shell command via layout, and use dataset with local images instead use a external link.

Sure that is not practical, but it would be a good work around…

What you could do is create a Layout that shows all of the images in a ticker, schedule that as normal. Then create your random layout with priority to run at the same time as the other one.

The other one will cause all of the images to be cached and downloaded, making them available for the random one

I think…

Hmmm…

If I make a ticker with 30 images, It will have no time to download them while the region is being played. The data will continue to download, even if the layout is not playing?

And how could I reference the downloaded images on the dataset? All the downloaded content has a “random” name.

If you have a ticker with 30 images on it, the images will be downloaded once without ever being shown. Your random ticker with 1 image will share the same random image name as your 30 image ones - provided they are from the same dataset and same column.

I think is a misunderstanding here…

.Since my first post, I’m using a layout with a Ticker, wich I set a dataset as source.
On this ticker, I use that custom SQL to reorder the rows (to get them as ramdom).

So in case, I need just to make a region calling all the images (they are links on dataset) at same time, to make sure all of them will be downloaded properly?

This means that each time the ticker is shown on the Player it will need to download the random image presented to it, up until it has run 30 times and has them all. Until it has run 30 times you may well get a run that doesn’t show the image, because it doesn’t have it yet.

If you have another Layout that is never shown (due to schedule trickery) which actually shows all 30 images, they will all be downloaded immediately and be available on the device for the other ticker to use when it is shown.

Well… Just to register here my actual solution.

I have a the layout with a ticker, calling the random content from the dataset.

On the same layout I made another region with a ticker, calling ALL the dataset content.

This worked very well. =)

The only issue, is that if the player are not connected with the CMS, it can’t generate a random entry, so it shows the last image loaded every time, till it connect to the CMS again. But actually, this never happened. =)

1 Like