Skip to content

Commit

Permalink
Hello Github
Browse files Browse the repository at this point in the history
  • Loading branch information
DoubleRainbow committed Dec 25, 2015
1 parent f92aa63 commit 86bbe0c
Show file tree
Hide file tree
Showing 8 changed files with 1,322 additions and 2 deletions.
63 changes: 61 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,61 @@
# embed
Embed Torrents Time in your site or project with a tiny piece of code
# Embedding [Torrents Time](https://torrents-time.com)
Torrents Time is a one of a kind fully customizable bittorrent client, advanced video player and downloads manager which is installed directly on the browser.
Embeding Torrents Time in your website enables you to offer a unique, amazing and one of a kind experience to your websites' visitors.

Torrents Time was designed to fully support and enhance the needs of users on video streaming, downloads and torrents websites, while taking into consideration the needs and wants of those site owners to maximize the value they can gain from embedding Torrents Time on their site.

##Quick start
Embedding Torrents Time is as simple as adding an `iframe` to your website
```html
<iframe src="https://embed.torrents-time.com/#source=TorrentURL&publisher_id=1"></iframe>
```
Or just even by linking to it directly using an `<a tag`
```html
<a href="https://embed.torrents-time.com/#source=TorrentURL&publisher_id=1">WATCH</a>
```
####Javascript API
For those who don't want to include any 3rd party elements on their site or just seek for some more advanced embedding options, we have created this super simple `Javascript` API which takes about 5 seconds to implement in your site:
```html
<script src="torrentstime.min.js"></script>
<script>
torrentsTime.init({publisher_id:1});
</script>
<div class="torrentsTime" data-setup='{"source": "torrentURL"}'></div>
```

## Settings
You can enhance Torrents Time by simply providing one or more of these optional parameters:
* `source` - **Required**, This is the URL or the magnet link of the torrent file, or any other static file on your server you wish to stream/download using Torrents Time.

* `publisher_id` - **Optional**, This is your unique Publisher ID, if you haven't [registered](http://publishers.torrents-time.com/) yet as a Torrents Time publisher, check out the reasons [why you should register](http://publishers.torrents-time.com/).

* `title` - **Optional**, Set the video/downloaded file title. If not specified, the title will get auto detected from file name or torrent info.

* `autoPlay` - **Optional**, Default: false. providing `true` as the value will auto stream or download the file.

* `imdbid` **Optional**, IMDB ID, If specified, Torrents Time will automatically search for poster images and subtitles across the web.

* `poster` **Optional**, The poster parameter sets the image(s) that displays before the video begins playing. As soon as the user clicks play the poster will go away.

####Example
For setting the parameters in the iframe/link URL:
```html
https://embed.torrents-time.com/#source=TorrentURL&title=VideoName&imdb=tt1254207&autoPlay=1&publisher_id=1
```

For using with the implemented Javascript:
```html
<script src="torrentstime.min.js"></script>
<script>
torrentsTime.init({publisher_id:1});
</script>
<div class="torrentsTime" data-setup='{"source": "torrentURL", "title": "VideoName", "imdbid": "tt1254207", "id": "myPlayer"}'></div>
```
<sub>You can set the parameters within the `torrentsTime.init` function or within the `data-setup` attribute of the containment `<div` element.
The difference is that the parameters within the `torrentsTime.init` function will apply globably for all the Torrents Time instances embeded in the page and the parameters within the `data-setup` attribute will apply only for that specific instance.</sub>


****
##Documentation
For more detailed info, please check out our short [Getting Started Guide](./docs/setup.md) to learn everything you need to know about our `Javascript API`.
And if you're ready to dive in and discover more advanced options, the [documentation](./docs/index.md) is the first place to go for more information.
293 changes: 293 additions & 0 deletions docs/api_usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
[Torrents Time Documentation](./index.md)

#API
The Torrents Time API allows you to interact with the plugin through JavaScript.

##Initialize
First, trigger the `torrentsTime.init` function to start the plugin's initialization process.
The `init` function will embed the plugin `object` in the DOM and will prepare everything you need in order to interact with the plugin.
```javascript
torrentsTime.init();
```

While initializing, Torrents Time will trigger several key functions that you can use as event listeners.

####initEnded
Will anounce the completion of prepration process.
```javascript
torrentsTime.functions.initEnded = function(){
//The Initialization process completed

Alert("Is Torrents Time installed: " + torrentsTime.setup.isInstalled)
};
```
####deviceIsNotSupported
Will announce that the user's device is not supported by Torrents Time.
If not supported device is detected, Torrents Time will remove every `class="torrentsTime"` element from the DOM by default.
You can overwrite this behavior by setting your own function for this event:
```javascript
torrentsTime.functions.deviceIsNotSupported = function(){
Alert("Sorry, Your device is not support by Torrents Time :(");
};
```

####initialized
If the device is supported and the plugin is installed on the user's browser,
Torrents Time will embed the plugin `object` in the DOM and will trigger this function at the moment the plugin is ready for interaction.
```javascript
torrentsTime.init();

torrentsTime.functions.initialized = function( instance ){
Alert("The Torrents Time instance: " + instance.id + ", is ready for interaction!");
};
```

##interaction
You can interact directly with any Torrents Time instance embedded in the page, by specifying its `instance id`.
You can set the `id` for each instance by passing it in the option parameters inside the `data-setup` attribute of the containment div:
```html
<div class="torrentsTime" data-setup='{"id":"myPlayer", "source": "torrentURL"}'></div>
```
>If the `id` parameter is not specified, the `instance id` will be generated automatically and it will consist of the letter `i` followed by an ascending digit.
>For example, if you embedded only one instance in your web page and you didn't specify an `id` parameter, the instance id will be set automatically as `i0`
After the plugin is embedded in the page, you can access the embedded instance methods and properties. For example:
```javascript
torrentsTime.myPlayer.play();
```
It is possible to reach all the embedded instances in the page by referring to `torrentsTime.instances`
```javascript
var TTinstances = torrentsTime.intances;

//example for pausing all Torrents Time instances at once:
for(var instance in TTinstances){
TTinstances[ instance ].pause();
}
```
###Instance methods
* [start](#start)
* [beforeStart](#beforestart)
* [play](#play)
* [pause](#pause)
* [stop](#stop)
* [mute](#mute)
* [setVolume](#setvolume)
* [seek](#seek)
* [setFullScreen](#setfullscreen)

####start
The start function will initiate the download process of the file.
This function will be triggered programmatically, or upon user interaction as soon as user hits play.
```javascript
torrentsTime.myPlayer.start()
```

####beforeStart
Just before Torrents Time is actually starting the download, you have the chance to execute your own code.
You can do so, by adding functions to the `beforeStart` object. In a case your function will return `false` as value, the download process will be prevented. For example:
```javascript
torrentsTime.myPlayer.beforeStart.showAdvertisement = function(){
return confirm('Yes this is a fucking annoying advertisement, just for testing purposes, please do not actually use it in your site! \nDo you want to proceed? ');

//let’s not show this ad like... EVER!
delete torrentsTime.myPlayer.beforeStart.showAdvertisement;
}
```

####play
Start playing / download
```javascript
torrentsTime.myPlayer.play()
```

####pause
Pause playback / download
```javascript
torrentsTime.myPlayer.pause()
```

####stop
Stop the playback / download
```javascript
torrentsTime.myPlayer.stop()
```

####mute
`Boolean`
```javascript
torrentsTime.myPlayer.mute(true)
```

####setVolume
`0-100`
```javascript
torrentsTime.myPlayer.setVolume(85)
```

####seek
`seconds`
```javascript
torrentsTime.myPlayer.seek(612)
```

####setFullScreen
`Boolean`
```javascript
torrentsTime.myPlayer.setFullScreen(true)
```

####displayPoster
You can add / update the poster images even after the plugin is loaded and then trigger the `displayPoster` function to update the view
```javascript
torrentsTime.myPlayer.setup.poster = "changePoster.png";
torrentsTime.myPlayer.displayPoster()
```

###Instance properties
* [id](#id)
* [wrapper](#wrapper)
* [setup](#setup)


####id
You can grab the `id` string from any instance object
```javascript
var instance_id = torrentsTime.myPlayer.id
```

####wrapper
A reference to the instance's containment div DOM element
```javascript
var wrappaer_div = torrentsTime.myPlayer.wrapper;
```

####setup
An object containing all the options parameters that were set up at the initialize stage
```javascript
console.log( torrentsTime.myPlayer.setup );
```


##Listeners function
You can set up listeners function that will be triggered upon events.
* [preload_started](#preload_started)
* [preload_ongoing](#preload_ongoing)
* [preload_complete](#preload_complete)
* [playback_complete](#playback_complete)
* [paused](#paused)
* [stopped](#stopped)
* [load_status](#load_status)
* [playback_time](#playback_time)
* [volume_changed](#volume_changed)
* [fullscreen_changed](#fullscreen_changed)
* [vpn_status](#vpn_status)
* [crashed](#crashed)

####preload_started
```javascript
torrentsTime.function.preload_started = function( params ){
var instance_id = params.id
}
```

####preload_ongoing
Gives indication on streaming preloading
```javascript
torrentsTime.function.preload_ongoing = function( params ){
var instance_id = params.id;
var percent = params.percent //int
var seeders = params.seeders //int
var peers = params.peers //int
var speed = params.speed //int (bytes)
}
```

####playback_complete
The video playback is completed
```javascript
torrentsTime.function.playback_complete = function( params ){
var instance_id = params.id
}
```

####preload_complete
Preload is completed and the video is starting to play
```javascript
torrentsTime.function.preload_complete = function( params ){
var instance_id = params.id
}
```

####paused
Playback / download has paused
```javascript
torrentsTime.function.paused = function( params ){
var instance_id = params.id
}
```

####stopped
Playback / download has stopped
```javascript
torrentsTime.function.stopped = function( params ){
var instance_id = params.id
}
```

####load_status
```javascript
torrentsTime.function.load_status = function( params ){
console.log( params );
}
```


####playback_time
```javascript
torrentsTime.function.playback_time = function( params ){
var instance_id = params.id
console.log( params );
}
```


####volume_changed
```javascript
torrentsTime.function.volume_changed = function( params ){
var instance_id = params.id
var level = params.state;
}
```

####fullscreen_changed
```javascript
torrentsTime.function.fullscreen_changed = function( params ){
var instance_id = params.id
var isFullScreen = params.state
}
```


####vpn_status
Indicates if the VPN status has changed
* `0` - VPN is not installed
* `1` - VPN is deactivated
* `2` - VPN is turned off
* `3` - VPN is turned on

```javascript
torrentsTime.function.fullscreen_changed = function( params ){
var instance_id = params.id
var VPN_status = params.state;
}
```


####crash
An unexpected error occurred.
Try to re-initialize the whole process
```javascript
torrentsTime.function.crash = function( params ){
var instance_id = params.id
}
```
20 changes: 20 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Torrents Time homepage](https://torrents-time.com)

#Torrens Time Documentation
There are two categories of docs: ***Guides*** and ***API docs***.
Guides explain general topics and use cases (e.g. setup/getting started).
API docs gives specific details about functions, properties, and events.

(Corrections and additions are welcome)

###Guides
* [Getting started](./setup.md) - The setup documentation explains in detail how you can implement the Javascript API in your web page.

* [Options](./options.md) - There are a number of options that can be used to change how Torrents Time looks and behaves.

* [API usage](./api_usage.md) - Using the API and interacting with Torrents Time and customizing it to your needs is as simple as writing 1 line of code.


###API docs

* [methods](./source.md) - explaining the Javascript API [source code](./../torrentstime.js).
Loading

0 comments on commit 86bbe0c

Please sign in to comment.