Source language: Translate to:

Playing different movies with 1 script

General questions about NeoAppBuilder - our rapid application development tool for building HTML5, web and mobile apps.

Moderator: Neosoft Support

Playing different movies with 1 script

Postby impulsmedia » Mon Feb 23, 2015 1:42 pm

Hello,
I try to set up a small app which starts playing different movies depending on the users selection. As "movie-preview" I use a still (preview_video1.png) shown in a picture object. Until now I realize the video-play-event after a click on my preview png in an iframe object which refers to a file with the code below. My simple (and my be stupid question...) is, how to fill the source tag <source src=".... URL" type="video/mp4"> with a var i.e. [SourceVideo], which is set on clicking my preview_videoX.png. Thanks for your help.

Code: Select all
<!DOCTYPE html>
<html>
<body>

<button onclick="playVid()" type="button">Play Video</button>
<button onclick="pauseVid()" type="button">Pause Video</button><br>

<video id="myVideo" width="320" height="176">
  <source src="http://www.myurl.de/videos/video1.mp4" type="video/mp4">
</video>

<script>
var vid = document.getElementById("myVideo");

function playVid() {
    myVideo.play();
}

function pauseVid() {
    myVideo.pause();
}
thanks in advance and greetings from Germany,
Walter
impulsmedia
 
Posts: 38
Joined: Wed Mar 22, 2006 9:01 am
Location: GERMANY

Re: Playing different movies with 1 script

Postby PaulTomo » Mon Feb 23, 2015 2:36 pm

Walter, This may help!

Not identical to your code but this worked for my test's with both images and mp3's.

First I parsed the list of titles and put the clips into an array, I then picked one of them at random and added just it's title from the split to a variable.

Code: Select all
SetVar [Clip] "[VideoSplit(2)]"


You need to add the HTML code to assign an ID, I put it on the button I was using as my click to start.

Code: Select all
<style>div {width: 330px; height: 250px;}</style><div id="myVideo"></div>


I then added some JS to the code area of the same button.

Code: Select all
BeginJS
document.getElementById("myVideo").src = 'http://MyWebSite/Video_Clips/'+$rootScope.Clip+'.mp4';
var myVideo = document.getElementById("myVideo");
myVideo.play();
EndJS


The bit that you are probably after is how you assign and to load the Video as a variable.
+$rootScope.Clip+'

This loads the [Clip] variable that was assigned from the split.

I just put all the code on the same click to start button.

Good luck.
User avatar
PaulTomo
 
Posts: 62
Joined: Tue Apr 28, 2009 1:15 am
Location: UK

Re: Playing different movies with 1 script

Postby impulsmedia » Tue Feb 24, 2015 1:21 am

Thank you, I´ll check this out asap.
thanks in advance and greetings from Germany,
Walter
impulsmedia
 
Posts: 38
Joined: Wed Mar 22, 2006 9:01 am
Location: GERMANY

Re: Playing different movies with 1 script

Postby Neosoft Support » Tue Feb 24, 2015 11:02 am

In the next update you will be able to change the contents of an iFrame object by using a variable as the source property.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA


Return to General NeoAppBuilder Discussion

Who is online

Users browsing this forum: No registered users and 0 guests