videogular2
Version:
Videogular is a video application framework for desktop and mobile powered by Angular 2.0
886 lines (402 loc) • 28.6 kB
HTML
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>VgAPI · GitBook</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2">
<link rel="stylesheet" href="../../../../gitbook/style.css">
<link rel="stylesheet" href="../../../../gitbook/gitbook-plugin-responsive-iframes/plugin.css">
<link rel="stylesheet" href="../../../../gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="../../../../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../../../../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../../../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../../../../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="../vg-fullscreen-api/" />
<link rel="prev" href="../../vg-media/" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="header">Introduction</li>
<li class="chapter " data-level="1.1" data-path="../../../../">
<a href="../../../../">
What's Videogular?
</a>
</li>
<li class="header">Getting Started</li>
<li class="chapter " data-level="2.1" data-path="../../../../getting-started/">
<a href="../../../../getting-started/">
Getting Started
</a>
</li>
<li class="chapter " data-level="2.2" data-path="../../../../getting-started/how-videogular-works.html">
<a href="../../../../getting-started/how-videogular-works.html">
How Videogular works
</a>
</li>
<li class="chapter " data-level="2.3" data-path="../../../../getting-started/master-media.html">
<a href="../../../../getting-started/master-media.html">
Master Media
</a>
</li>
<li class="chapter " data-level="2.4" data-path="../../../../getting-started/using-the-api.html">
<a href="../../../../getting-started/using-the-api.html">
Using the API
</a>
</li>
<li class="header">Modules</li>
<li class="chapter " data-level="3.1" data-path="../../">
<a href="../../">
videogular2/core
</a>
<ul class="articles">
<li class="chapter " data-level="3.1.1" data-path="../../vg-player/">
<a href="../../vg-player/">
VgPlayer
</a>
</li>
<li class="chapter " data-level="3.1.2" data-path="../../vg-media/">
<a href="../../vg-media/">
VgMedia
</a>
</li>
<li class="chapter active" data-level="3.1.3" data-path="./">
<a href="./">
VgAPI
</a>
</li>
<li class="chapter " data-level="3.1.4" data-path="../vg-fullscreen-api/">
<a href="../vg-fullscreen-api/">
VgFullscreenAPI
</a>
</li>
<li class="chapter " data-level="3.1.5" data-path="../vg-utils/">
<a href="../vg-utils/">
VgUtils
</a>
</li>
<li class="chapter " data-level="3.1.6" data-path="../vg-controls-hidden/">
<a href="../vg-controls-hidden/">
VgControlsHidden
</a>
</li>
<li class="chapter " data-level="3.1.7" data-path="../../vg-cue-points/">
<a href="../../vg-cue-points/">
VgCuePoints
</a>
</li>
<li class="chapter " data-level="3.1.8" data-path="../../events/">
<a href="../../events/">
VgEvents
</a>
</li>
<li class="chapter " data-level="3.1.9" data-path="../../states/">
<a href="../../states/">
VgStates
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="3.2" data-path="../../../buffering/">
<a href="../../../buffering/">
videogular2/buffering
</a>
<ul class="articles">
<li class="chapter " data-level="3.2.1" data-path="../../../buffering/vg-buffering/">
<a href="../../../buffering/vg-buffering/">
VgBuffering
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="3.3" data-path="../../../controls/">
<a href="../../../controls/">
videogular2/controls
</a>
<ul class="articles">
<li class="chapter " data-level="3.3.1" data-path="../../../controls/vg-controls/">
<a href="../../../controls/vg-controls/">
VgControls
</a>
</li>
<li class="chapter " data-level="3.3.2" data-path="../../../controls/vg-play-pause/">
<a href="../../../controls/vg-play-pause/">
VgPlayPause
</a>
</li>
<li class="chapter " data-level="3.3.3" data-path="../../../controls/vg-playback/">
<a href="../../../controls/vg-playback/">
VgPlaybackButton
</a>
</li>
<li class="chapter " data-level="3.3.4" data-path="../../../controls/vg-scrub-bar/">
<a href="../../../controls/vg-scrub-bar/">
VgScrubBar
</a>
<ul class="articles">
<li class="chapter " data-level="3.3.4.1" data-path="../../../controls/vg-scrub-bar/vg-scrub-bar-current-time/">
<a href="../../../controls/vg-scrub-bar/vg-scrub-bar-current-time/">
VgScrubBarCurrentTime
</a>
</li>
<li class="chapter " data-level="3.3.4.2" data-path="../../../controls/vg-scrub-bar/vg-scrub-bar-buffering-time/">
<a href="../../../controls/vg-scrub-bar/vg-scrub-bar-buffering-time/">
VgScrubBarBufferingTime
</a>
</li>
<li class="chapter " data-level="3.3.4.3" data-path="../../../controls/vg-scrub-bar/vg-scrub-bar-cue-points/">
<a href="../../../controls/vg-scrub-bar/vg-scrub-bar-cue-points/">
VgScrubBarCuePoints
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="3.3.5" data-path="../../../controls/vg-time-display/">
<a href="../../../controls/vg-time-display/">
VgTimeDisplay
</a>
<ul class="articles">
<li class="chapter " data-level="3.3.5.1" data-path="../../../controls/vg-time-display/vg-utc.html">
<a href="../../../controls/vg-time-display/vg-utc.html">
VgUtcPipe
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="3.3.6" data-path="../../../controls/vg-track-selector/">
<a href="../../../controls/vg-track-selector/">
VgTrackSelector
</a>
</li>
<li class="chapter " data-level="3.3.7" data-path="../../../controls/vg-mute/">
<a href="../../../controls/vg-mute/">
VgMute
</a>
</li>
<li class="chapter " data-level="3.3.8" data-path="../../../controls/vg-volume/">
<a href="../../../controls/vg-volume/">
VgVolume
</a>
</li>
<li class="chapter " data-level="3.3.9" data-path="../../../controls/vg-fullscreen/">
<a href="../../../controls/vg-fullscreen/">
VgFullscreen
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="3.4" data-path="../../../ima-ads/">
<a href="../../../ima-ads/">
videogular2/ima-ads
</a>
<ul class="articles">
<li class="chapter " data-level="3.4.1" data-path="../../../ima-ads/vg-ima-ads/">
<a href="../../../ima-ads/vg-ima-ads/">
VgImaAds
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="3.5" data-path="../../../overlay-play/">
<a href="../../../overlay-play/">
videogular2/overlay-play
</a>
<ul class="articles">
<li class="chapter " data-level="3.5.1" data-path="../../../overlay-play/vg-overlay-play/">
<a href="../../../overlay-play/vg-overlay-play/">
VgOverlayPlay
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="3.6" data-path="../../../streaming/">
<a href="../../../streaming/">
videogular2/streaming
</a>
<ul class="articles">
<li class="chapter " data-level="3.6.1" data-path="../../../streaming/vg-dash/">
<a href="../../../streaming/vg-dash/">
VgDASH
</a>
</li>
<li class="chapter " data-level="3.6.2" data-path="../../../streaming/vg-hls/">
<a href="../../../streaming/vg-hls/">
VgHLS
</a>
</li>
</ul>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="../../../.." >VgAPI</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h1 id="vgapi-injectable-service">VgAPI @Injectable Service</h1>
<p>Service that controls all media objects inside <code>vg-player</code> element.</p>
<p>This service is created by the element <code>vg-player</code> when it is instantiated. On component initialization, <code>vg-player</code> will register all medias inside of it but you can also register elements outside of <code>vg-player</code> element programmatically through the method <code>registerMedia</code>.</p>
<h2 id="methods">Methods</h2>
<h3 id="getdefaultmediavoid">getDefaultMedia():void</h3>
<p>Returns the first media registered to the API.</p>
<h3 id="getmastermediaiplayable">getMasterMedia():IPlayable</h3>
<p>Returns the master media registered to the API.</p>
<h3 id="ismasterdefinedboolean">isMasterDefined():boolean</h3>
<p>Returns if there is a master media registered to the API.</p>
<h3 id="getmediabyididstring--nullany">getMediaById(id:string = null):any</h3>
<p>Returns a media by <code>id</code>. The <code>id</code> must match with the attribute <code>id</code> on the media object.</p>
<h3 id="play">play()</h3>
<p>Play all medias registered.</p>
<h3 id="pause">pause()</h3>
<p>Pause all medias registered.</p>
<h3 id="registerelementelemhtmlelement">registerElement(elem:HTMLElement)</h3>
<p>Registers a new element as container and saves a reference internally in to the <code>videogularElement</code> property.</p>
<h3 id="registermediamediaany">registerMedia(media:any)</h3>
<p>Register a new media element and saves internally a reference in to the <code>medias</code> property.</p>
<h3 id="seektimevaluenumber-bypercentboolean">seekTime(value:number, byPercent:boolean)</h3>
<p>Will seek to <code>value</code> in seconds or in percentage if <code>byPercent</code> is true. By default <code>byPercent</code> is false. If there's a master media defined the seek by percentage would be calculated based on master media's duration.</p>
<h3 id="addtexttracktypesubtitles--caption--descriptions--chapters--metadata-labelstring-languagestring-modedisabled--hidden--showing">addTextTrack(type:'subtitles' | 'caption' | 'descriptions' | 'chapters' | 'metadata', label?:string, language?:string, mode?:'disabled' | 'hidden' | 'showing')</h3>
<p>Create a track dynamically in all registered <code>medias</code>. You can add <code>VTTCue</code> objects using the <code>addCue</code> method available in the <code>TextTrack</code> class.</p>
<hr>
<h2 id="properties">Properties</h2>
<h3 id="duration-read-only-numberobject">duration [read-only] :number|object</h3>
<p>Returns a <code>number</code> with media duration or an object with all durations if there are more than one media object registered.</p>
<h3 id="currenttime-read-write-numberobject">currentTime [read-write] :number|object</h3>
<p>Seeks to a specific time to all medias registered.
Returns a <code>number</code> with current time or an object with all current times if there are more than one media object registered.</p>
<h3 id="state-read-write-stringobject">state [read-write] :string|object</h3>
<p>Updates media state to all medias registered. States can be <code>play</code> or <code>pause</code>.
Returns a <code>string</code> with current state or an object with all states if there are more than one media object registered.</p>
<h3 id="volume-read-write-numberobject">volume [read-write] :number|object</h3>
<p>Updates volume to all medias registered. Volume is a float value between 0 and 1 where 1 is default.
Returns a <code>number</code> with current volume or an object with all volumes if there are more than one media object registered.</p>
<h3 id="playbackrate-read-write-numberobject">playbackRate [read-write] :number|object</h3>
<p>Updates playback speed to a specific value to all medias registered. Playback rate is a float value greater than 0 where 1 is default.
Returns a <code>number</code> with current playback rate or an object with all rates if there are more than one media object registered.</p>
<h3 id="canplay-read-only-booleanobject">canPlay [read-only] :boolean|object</h3>
<p>When media object is ready to be played <code>canPlay</code> property value is <code>true</code>. Default value is <code>false</code>. It will return an object with all <code>canPlay</code> values if there are more than one media object registered.</p>
<h3 id="canplaythrough-read-only-booleanobject">canPlayThrough [read-only] :boolean|object</h3>
<p>When media object is ready to be played without buffering <code>canPlayThrough</code> property value is <code>true</code>. Default value is <code>false</code>. It will return an object with all <code>canPlayThrough</code> values if there are more than one media object registered.</p>
<h3 id="ismetadataloaded-read-only-booleanobject">isMetadataLoaded [read-only] :boolean|object</h3>
<p>When media metadata has been loaded <code>isMetadataLoaded</code> property value is <code>true</code>. Default value is <code>false</code>. It will return an object with all <code>isMetadataLoaded</code> values if there are more than one media object registered.</p>
<h3 id="iswaiting-read-only-booleanobject">isWaiting [read-only] :boolean|object</h3>
<p>When media is loading data <code>isWaiting</code> property value is <code>true</code>. Default value is <code>false</code>. It will return an object with all <code>isWaiting</code> values if there are more than one media object registered.</p>
<h3 id="iscompleted-read-only-booleanobject">isCompleted [read-only] :boolean|object</h3>
<p>When a media have been reached the end of the video <code>isCompleted</code> property value is <code>true</code>. Default value is <code>false</code>. It will return an object with all <code>isCompleted</code> values if there are more than one media object registered.</p>
<h3 id="islive-read-only-booleanobject">isLive [read-only] :boolean|object</h3>
<p>Boolean value to know if the current media is a live stream.</p>
<h3 id="ismaster-read-only-booleanobject">isMaster [read-only] :boolean|object</h3>
<p>Boolean value to know if the current media is the master media.</p>
<h3 id="time-read-only-object">time [read-only] :object</h3>
<p>Returns an <code>object</code> with time information or an object with all times if there are more than one media object registered.</p>
<p>Object definition is:</p>
<pre><code class="lang-json">{
current: <float>,
total: <float>,
left: <float>
}
</code></pre>
<p>Default value is:</p>
<pre><code class="lang-json">{
current: <span class="hljs-number">0</span>,
total: <span class="hljs-number">0</span>,
left: <span class="hljs-number">0</span>
}
</code></pre>
<h3 id="buffer-read-only-object">buffer [read-only] :object</h3>
<p>Returns an <code>object</code> with buffer information or an object with all buffers if there are more than one media object registered.</p>
<p>Object definition is:</p>
<pre><code class="lang-json">{
end: <span class="xml"><span class="hljs-tag"><<span class="hljs-name">float</span>></span>
}
</span></code></pre>
<p>Default value is:</p>
<pre><code class="lang-json">{
end: <span class="hljs-number">0</span>
}
</code></pre>
<h3 id="buffered-read-only-object">buffered [read-only] :object</h3>
<p>Returns an <code>object</code> with buffer information or an object with all buffers if there are more than one media object registered.</p>
<p>This is the native object and is different from <code>buffer</code> property which haves basically the same information in a property and transformed to milliseconds.</p>
<p>Object definition is:</p>
<pre><code class="lang-json">{
end: <span class="xml"><span class="hljs-tag"><<span class="hljs-name">function</span>></span>
length: :number>
}
</span></code></pre>
<p>Default value is <code>undefined</code>.</p>
<h3 id="subscriptions-read-only-imediasubscriptions">subscriptions [read-only] :IMediaSubscriptions</h3>
<p>Returns an <code>IMediaSubscriptions</code> with a list of observables or an object with all observables in all medias if there are more than one media object registered.</p>
<h3 id="videogularelement-read-write-object">videogularElement [read-write] :object</h3>
<p>This property haves a reference to the container element, usually <code>vg-player</code> but it could be overridden in case that you're building your own implementation of <code>vg-player</code>.</p>
<h3 id="texttracks-read-only-texttrack">textTracks [read-only] :TextTrack[]</h3>
<p>Returns an array of <code>TextTrack</code> objects. Use this array to get your track to add and remove <code>VTTCue</code> objects dynamically.</p>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="../../vg-media/" class="navigation navigation-prev " aria-label="Previous page: VgMedia">
<i class="fa fa-angle-left"></i>
</a>
<a href="../vg-fullscreen-api/" class="navigation navigation-next " aria-label="Next page: VgFullscreenAPI">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"VgAPI","level":"3.1.3","depth":2,"next":{"title":"VgFullscreenAPI","level":"3.1.4","depth":2,"path":"modules/core/services/vg-fullscreen-api/README.md","ref":"modules/core/services/vg-fullscreen-api/README.md","articles":[]},"previous":{"title":"VgMedia","level":"3.1.2","depth":2,"path":"modules/core/vg-media/README.md","ref":"modules/core/vg-media/README.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["ga","responsive-iframes"],"pluginsConfig":{"ga":{"configuration":"auto","token":"UA-45418240-1"},"responsive-iframes":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"modules/core/services/vg-api/README.md","mtime":"2017-06-22T07:43:44.601Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-06-22T07:45:27.174Z"},"basePath":"../../../..","book":{"language":""}});
});
</script>
</div>
<script src="../../../../gitbook/gitbook.js"></script>
<script src="../../../../gitbook/theme.js"></script>
<script src="../../../../gitbook/gitbook-plugin-ga/plugin.js"></script>
<script src="../../../../gitbook/gitbook-plugin-responsive-iframes/plugin.js"></script>
<script src="../../../../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../../../../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../../../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../../../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../../../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../../../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>