How to Use the HTML Video Tag to Play Videos in an Ionic/AngularJS App
When building an Ionic/AngularJS app with the Appery.io App Builder you can add an HTML
component to play back video files.
In this tutorial, you will learn how to do this.
To start, you need to create a new Ionic app.
- Drag an
HTML
component to the page and click Edit to modify the code. - Add the following to the tag editor:
<video controls="controls" width="640" height="340" name="Video Name" ></video>
- Save it and switch to the
SCOPE
tab. - For the
init()
function, pass the following:$scope.makeAction();
- Now, create a new function and name it
makeAction
and add the next code, replacingurlToVideo
with the URL of the video you need to play:var vidURL = "urlToVideo"; var myVideo = document.getElementsByTagName('video')[0]; myVideo.src = vidURL; myVideo.load(); myVideo.play();
Below is the example of playing back the video with URL
= http://clips.vorwaerts-gmbh.de/VfE_html5.mp4
:
Note that some HTML video may be unavailable for playback.