Auto Link/Dialog Box after Video/Audio finishes - SOLVED :-)

Is this possible? I spent some time searching how to… but came up with nothing.
I know there are some knowledgeable web builders in this Forum, so I appeal to you all. I also acknowledge you all have your own project, so I don’t expect an immediate answer. Am I wrong, but wouldn’t this be a good feature to have?
Can Bloc 3 automatically Hyperlink to a specific link (Fruit and Vegetable Nutrition for a Healthy Diet Juice Plus+) after a Youtube (Design Your Life - Come Join Us - YouTube), Vimeo or self-hosted video is played?
I’m not a coder, so be nice :slight_smile:

1 Like

Hi @KBConcepts

Well, yes, it’s possible, but it will take some coding :wink:
Take a look at this code example, if you can code it, then it’s possible w/ some effort.

Sorry, I can’t help more, but I’m slammed w/ work.

Bill
BricsDesign

Hey no worries @Bill I appreciate any insight into this. The idea of event listener was interesting. I did not see anything code to show after playing the video it would open a Hyperlink.

I found a solution… wait 10 minutes please…

1 Like

CHECK HERE

Wasn’t that suppose to open a link when finish?
Wait I get it… it a Popup dialog box that someone can click on right?
That’s pretty cool. It maybe better than my idea.

Do you want to finish and automatically open the link or you want a message first and then follow to the link?

I didn’t know either one was possible. You’re brilliant! :grinning:
Is it easy to change the code either way?

TRY NOW… there you have both ways…

Wow @Pealco, you made that work both ways!
That’s so cool! Did you use Blocs 3 or something else?

So now there is how…

HTML Bric (FOR MESSAGE ONLY)

<video id="myVideo" width="100%" height="100%" controls="">
  <source src="vid/dolbycanyon.mp4" type="video/mp4" class="">
  Your browser does not support HTML5 video.
</video>

<script>
var vid = document.getElementById("myVideo");
vid.onended = function() {
  alert("This is free but now you need to pay..... Ahahah!");
};
</script>

HTML Bric (FOR MESSAGE AND URL)

<video id="myVideo" width="100%" height="100%" controls="">
  <source src="vid/dolbycanyon.mp4" type="video/mp4" class="">
  Your browser does not support HTML5 video.
</video>

<script>
var vid = document.getElementById("myVideo");
vid.onended = function() {
  alert("This is free but now you need to pay..... Ahahah!");
  window.location.href = 'https://blocsapp.com/#';
};
</script>

HTML Bric (FOR URL ONLY)

<video id="myVideo" width="100%" height="100%" controls="">
  <source src="vid/dolbycanyon.mp4" type="video/mp4" class="">
  Your browser does not support HTML5 video.
</video>

<script>
var vid = document.getElementById("myVideo");
vid.onended = function() {
  window.location.href = 'https://blocsapp.com/#';
};
</script>

Then if is local video, you have to add manually the video after the export to the folder vid.
And in the code change the name of the file.

Is is a remote video just type the url for the video.

Hope that will help you…

1 Like

Man, I wish I knew what you knew, I’d be rich! :grinning:
Do I open the Code Editor in Blocs 3 and simply paste the code?
That was really cool of you to take time out of your schedule to help me. I’m grateful!

STEP BY STEP:

  1. Add a structure with a 1 column for example.
  2. in that column add a HTML Bric
  3. add the code that I give you on the top.
  4. export your project.
  5. in the exported project open the “vid” folder and paste the video (this only applies if you use local videos)
1 Like

Now a gift for all:

You can use the following codes if you want this behavior to audio files:

ONLY MESSAGE:

<audio id="myAudio" width="100%" height="100%" controls="">
  <source src="http://cdn.mos.musicradar.com/audio/samples/techno-demo-loops/TechBassR120E-01.mp3" type="audio/mp3" class="">
  Your browser does not support HTML5 audio.
</audio>

<script>
var aud = document.getElementById("myAudio");
aud.onended = function() {
  alert("This is free but now you need to pay..... Ahahah!");
};
</script>

MESSAGE AND LINK:

<audio id="myAudio" width="100%" height="100%" controls="">
  <source src="http://cdn.mos.musicradar.com/audio/samples/techno-demo-loops/TechBassR120E-01.mp3" type="audio/mp3" class="">
  Your browser does not support HTML5 audio.
</audio>

<script>
var aud = document.getElementById("myAudio");
aud.onended = function() {
  alert("This is free but now you need to pay..... Ahahah!");
  window.location.href = 'https://blocsapp.com/#';
};
</script>

ONLY LINK:

<audio id="myAudio" width="100%" height="100%" controls="">
  <source src="http://cdn.mos.musicradar.com/audio/samples/techno-demo-loops/TechBassR120E-01.mp3" type="audio/mp3" class="">
  Your browser does not support HTML5 audio.
</audio>

<script>
var aud = document.getElementById("myAudio");
aud.onended = function() {
  window.location.href = 'https://blocsapp.com/#';
};
</script>
2 Likes

@KBConcepts there you have the link again, but now with all the possibilities.

LINK

:grin:

Thank so much to @Pealco he has spent a good amount of time on this and succeeded!

Everything is covered in the LINK.
Responsive, Auto-Play, Poster.

2 Likes

@Pealco

Thanks for helping the community! I can see that your coding skills are improving everyday! Good job! :slight_smile:

3 Likes

Thank you @Eldar for you nice words.
But I have to thank you, your courses give me attention, to the dinnamic of the Blocs, and how it respondes to classes and costume attributes, and because I force my self to learn about bootstrap and Js now I can do one or two more things.

The only thing that I want now, is to learn how the Bric Builder work, I already know how to put the Bric working, but don’t know how to make the html or JS be changed with the costume attributes that we can add. Can you please give a word to @Norm if he can take a little time to explain just a simple example with the Js?

But one more time thank you @Eldar for your words and for your hard work in the courses.

@Pealco, here a simple explanation using my animated background bric. If you don’t understand something, please let me know.

custom-bric.js file in “js” folder of the bric

In the HTML part in the bric builder