[Pro] Randomize Video Selection

Hey, gang!

Haven’t been on here for a very long time. Kind of been out of the web design business. But I have a question…

Is there a way to have videos (mp4s) randomized when a certain folder is accessed? And, have selections chosen from specific folders?

For instance…a person pics a folder. Videos are randomly displayed from that folder. Or, they want videos randomly selected from two of the three folders only. Maybe choose a radio button or something.

This will not reside on the web. It would be accessed from an iPad or computer.

I know this sounds a little confusing. I can try to clarify if need be.

As I said, I’ve been out of the loop for a while, so any help would be appreciated.

Thanks!

Bob


freewaytalk mailing list
email@hidden
Update your subscriptions at:

You can do this with a little JavaScript programming. Nothing else will work if you are running these off-line (not from a server). If you do want to run them from a server, then you can also use PHP or another server-side language. The basics of this are to provide a data structure like an array, filled with the filenames of the videos, and then programmatically choose one of them.

<script type="text/javascript">
var movies = ['movie-1.mp4', 'movie-3.mp4', 'movie-8.mp4'];
var key = Math.round(Math.random() * (movies.length - 1));
var movie = movies[key];
</script>

Then you would put a placeholder movie on the screen, and use this script to override its content with the chosen movie:

<video id="placeholder" src="movie-2.mp4" controls></video>

<!-- (below that video in the source order, so use Before /Body in the Page / HTML Markup picker) -->

<script type="text/javascript">
document.querySelector('#placeholder').src = movie;
</script>

Questions: what do you do with the other videos? Do you show them as well, or just the randomly-chosen one of the moment? What does the folder structure have to do with this? If you are viewing this off-line, where do the videos live? (I am assuming you won’t be trying to access the internal file structure of an iPad, since that is off-limits to user-land applications like MobileSafari.) Do you have a sketch of this on line somewhere that we can look at it and think about it more?

Walter

On Jan 27, 2016, at 10:41 AM, Robert B email@hidden wrote:

Hey, gang!

Haven’t been on here for a very long time. Kind of been out of the web design business. But I have a question…

Is there a way to have videos (mp4s) randomized when a certain folder is accessed? And, have selections chosen from specific folders?

For instance…a person pics a folder. Videos are randomly displayed from that folder. Or, they want videos randomly selected from two of the three folders only. Maybe choose a radio button or something.

This will not reside on the web. It would be accessed from an iPad or computer.

I know this sounds a little confusing. I can try to clarify if need be.

As I said, I’ve been out of the loop for a while, so any help would be appreciated.

Thanks!

Bob


freewaytalk mailing list
email@hidden
Update your subscriptions at:
Information for existing FreewayTalk / Groups.io users - Site Feedback - Softpress Talk


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

Thanks for the response, Walt!

I’ve been asked to do this as a “favor” (read: free). I’m not sue he knows what he wants ultimately. Here’s the gist"

He runs an exercise class. There will be various workouts split into different folders. Lets use two as an example: cardio and strength. A user will pick one of the folders. Then, a random video will play.

This is basically done now manually using 3 x 5 cards. He wants to automate it and have it so people can access it where ever they are. Web, app, or whatever. He suggested via web, but I wasn’t sue if it’s better to use it through a browser from a disk?

He’s asked for other things, too, but I thought I’d start here.

If you need more clarification, I’ll see what I can do. I’m a little confused myself. I think he’s asking for too much at the start.

Bob


freewaytalk mailing list
email@hidden
Update your subscriptions at:

It’s really hard to make an offline-playable site for an iPad, so the easiest thing of all will be to have a private Web server (private meaning you don’t publicize the address) with the site on it. Then you can use all the tools that come with a real server. If you want to learn a little PHP, that would be one way to do this.

You could probably make this entirely in HTML and JavaScript, though. For each of these “folders”, you would make a single page with a tall HTML box in the middle of it, and all of your videos inserted inline within that one box (don’t worry, they won’t all display or play at once). Then you would add a script to the page that would find all of the videos on the page, randomly pick one, and hide the rest. Each time you reload, you would have a chance of seeing a different video. I can easily imagine the script replacing the removed videos with links that would cause them to play, too. It’s basically a lightbox with a randomizer.

Here is what such a script would look like:

<script type="text/javascript">
var videos = document.querySelectorAll('video');
var rand = Math.round(Math.random() * (videos.length - 1));
[].forEach.call( videos, function( video, idx ){
  if(idx != rand){
    video.style.display = "none";
  }
});
</script>

Walter

On Jan 29, 2016, at 5:47 PM, Robert B email@hidden wrote:

Thanks for the response, Walt!

I’ve been asked to do this as a “favor” (read: free). I’m not sue he knows what he wants ultimately. Here’s the gist"

He runs an exercise class. There will be various workouts split into different folders. Lets use two as an example: cardio and strength. A user will pick one of the folders. Then, a random video will play.

This is basically done now manually using 3 x 5 cards. He wants to automate it and have it so people can access it where ever they are. Web, app, or whatever. He suggested via web, but I wasn’t sue if it’s better to use it through a browser from a disk?

He’s asked for other things, too, but I thought I’d start here.

If you need more clarification, I’ll see what I can do. I’m a little confused myself. I think he’s asking for too much at the start.

Bob


freewaytalk mailing list
email@hidden
Update your subscriptions at:
Information for existing FreewayTalk / Groups.io users - Site Feedback - Softpress Talk


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

Sorry it’s taken so long to get back to this. I HATE being one of those people that asks questions then never returns!

It seems this “little” project is a lot more involved than I thought it would be. My cousin (his project) hasn’t decided the best language to do this in yet. I believe he’s still editing video clips!

It’s basically an exercise system with LOTS of choices and video clips. He had written up seven pages of requirements for the system and was still adding. Lots of logic type decisions will need to be coded.

I do think he still wants to try to use HTML and a closed system of some kind.

Thanks for your input, Walt. WAY out of my wheelhouse!

Bob


freewaytalk mailing list
email@hidden
Update your subscriptions at: