Random video on region

I need to set a region to display 1 random video at time.

Since Xibo does not provide a feature like this, I’m trying to make a random function, calling the downloaded file.

So, in JS I call a randomic value (this values are the file names), that will be passed to a embedded tag in html:

< v i deo controls autoplay>
< s ource src=“data/data/uk.org.xibo.client/files/random_file.mp4” type=“video/mp4”>
< / vi deo>

It’s not working yet. I tried to run the mp4 on the android default player, but it didn’t run. Is this ramdom system going to work, or I can’t execute the video files by my own?

It might work if you reference the file by it’s full path - ie file:///data/data/uk.org.xibo.client/files/random_file.mp4

Indeed, using the full path worked. =)

BUT, the video doesn’t shows, I can see only the player controls (play, pause, progress bar…).

I know that the video are playing, because the progressbar runs till the end. And sometimes, when changes the layout, the last frame of video blinks on screen.

Maybe it’s about the layer where the video is rendered (?)… Is there any workaround that I could make?

I’m using this HTML code with a “embedded” option in the region.

Do you have anything over the top of that region? Have you tried adjusting the media transparency option?

No, I have only one region on the layout.

What do you mean about the media transparency? It’s about the “background transparent” option? I tried this already, but hasn’t solved.

As I said, the controls of the webplayer are shown, only the video seems to be hidden.

Yes I mean the background transparent option. Did you ensure the Player had sufficient time to download the updated layout and start showing it during your test?

Yes… Since the layout is just a few lines of code, it doesn’t take much time to update. And the video are already there, cause it’s already being used by another layout.

What’s the device? Android version?

It’s a Odroid c1. The android verion is 4.4.2

I don’t have experience with that device. I know we’ve had other reports of video working in WebView before but it’s not something I’ve tried directly myself.

Well… There is no way to make this works. The video always is shown behind the background.

Youtube embedded videos works. The youtube video would be downloaded every time, or it is stored as temporary file?

It would be streamed every time. You need to upload the video into Xibo to have it cached on the Player.

Well… Overall this random method works well. I tested it on my smartphone, and all goes well. If someone is looking for a random solution, this can be a good workaround. The only “issue” is that all your videos (the ones which will be randomized), need to have the same length.

Only on my device it isn’t working. For some reason, it is displaying the video in some layer behind all the others.

Could you share your javascript? I would very much like to do this

I didn’t have the code anymore, so I wrote it again, don’t know if it’s working 100%, it need to be tested.

> <body onload="rdm_video()">

> <p id="demo"></p>

> <script>

> function rdm_video() {
> var rdm=Math.floor(Math.random() * (5- 1+ 1)) + 1;

> var video_file;
> switch (rdm) {
>     case 1:
>         video_file = "file_name1.mp4";
>         break;
>     case 2:
>         video_file = "file_name2.mp4";
>         break;
>     case 3:
>         video_file = "file_name3.mp4";
>         break;
>     case 4:
>         video_file = "file_name4.mp4";
>         break;
>     case 5:
>         video_file = "file_name5.mp4";
>         break;

> }

> document.getElementById("demo").innerHTML ="<video autoplay src='file:///data/data/uk.org.xibo.client/files/"+video_file+"'></video>";
> }

> </script>

> </body>

What I did here is:
randomize a number;
switch the number to the file name;
Print the result in html, using the video tag. (here is where can have a spelling error…)

Hope it can work to you. =)

Obs.:This will work if all your videos have the same length, because the duration of layout will be according the region…

Thanks for posting that up. Just an observation though.

I would put your video files somewhere other than in the Xibo Player library. If it sees files in there it doesn’t recognise it may delete them without warning. Best to make a folder on the shared storage on the device for this purpose and store the files there.

If you’re assigning the files from the CMS then what’s above will be fine, but the files will be called number.mp4 (eg 24.mp4) rather than some other alpha-numeric.

Also avoid using onload. You need to use the Javascript hook we provide in the embedded html media type to bootstrap your code to ensure that everything executes in the correct order.

Thanks for the observations Alex!

And yes, I was using the xibo library because I have to update and change the videos via CMS.

A important point in this bootstrap, is that the videos you want to use must be in any other region or layout (I made a very small region on the same layout), so the player can download the files you want to display.

Or you can manually assign the videos to the Player rather than have them in a dummy region. You do that from the Displays section of the CMS.

It will then ensure the videos are downloaded but they won’t be used for anything directly by the Player.

I’m still having some problems with my HTML5 embedded videos. Has any chance to some “random feature” be implemented as a feature in Xibo?

I’ve seen others posts referring to something like this.

I think it could be a “media” type. Once I can choose what i want to display in a region (ticker, video, image, forecast, etc…), it could have a Random media, where you could assign the videos or images you want to randomize.

Example. I have 7 TVs. Each TV has a different playlist, but one or other content are the same.

Each play list has about 10~20 videos. After this playlist ends, I would like to play a random video.

So… what do you think about a feature like this?

By all means log it in the Features category and it will be considered for future development.