jwplayer-capacitor
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -94,2 +94,46 @@ { | ||
"slug": "seek" | ||
}, | ||
{ | ||
"name": "addListener", | ||
"signature": "(eventName: 'playerEvent', listenerFunc: EventChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle", | ||
"parameters": [ | ||
{ | ||
"name": "eventName", | ||
"docs": "", | ||
"type": "\"playerEvent\"" | ||
}, | ||
{ | ||
"name": "listenerFunc", | ||
"docs": "", | ||
"type": "(event: JWPlayerEvent) => void" | ||
} | ||
], | ||
"returns": "any", | ||
"tags": [ | ||
{ | ||
"name": "since", | ||
"text": "1.0.0" | ||
} | ||
], | ||
"docs": "Listen for events in player", | ||
"complexTypes": [ | ||
"EventChangeListener", | ||
"PluginListenerHandle" | ||
], | ||
"slug": "addlistener" | ||
}, | ||
{ | ||
"name": "removeAllListeners", | ||
"signature": "() => any", | ||
"parameters": [], | ||
"returns": "any", | ||
"tags": [ | ||
{ | ||
"name": "since", | ||
"text": "1.0.0" | ||
} | ||
], | ||
"docs": "Remove all listeners (including the network status changes) for this plugin.", | ||
"complexTypes": [], | ||
"slug": "removealllisteners" | ||
} | ||
@@ -152,2 +196,18 @@ ], | ||
] | ||
}, | ||
{ | ||
"name": "PluginListenerHandle", | ||
"slug": "pluginlistenerhandle", | ||
"docs": "", | ||
"tags": [], | ||
"methods": [], | ||
"properties": [ | ||
{ | ||
"name": "remove", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "() => any" | ||
} | ||
] | ||
} | ||
@@ -154,0 +214,0 @@ ], |
@@ -0,1 +1,2 @@ | ||
import type { PluginListenerHandle } from '@capacitor/core'; | ||
export interface JWPlayerMediaTrack { | ||
@@ -39,2 +40,31 @@ file: string; | ||
}): Promise<any>; | ||
/** | ||
* Listen for events in player | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
addListener(eventName: 'playerEvent', listenerFunc: EventChangeListener): Promise<PluginListenerHandle> & PluginListenerHandle; | ||
/** | ||
* Remove all listeners (including the network status changes) for this plugin. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
removeAllListeners(): Promise<void>; | ||
} | ||
export interface JWPlayerEvent { | ||
/** | ||
* Whether there is an active connection or not. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
name: string; | ||
/** | ||
* The type of network connection currently in use. | ||
* | ||
* If there is no active network connection, `connectionType` will be `'none'`. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
data: any; | ||
} | ||
export declare type EventChangeListener = (event: JWPlayerEvent) => void; |
@@ -27,2 +27,3 @@ import { WebPlugin } from '@capacitor/core'; | ||
}): Promise<any>; | ||
private loadEvents; | ||
getPosition(): Promise<{ | ||
@@ -29,0 +30,0 @@ value: number; |
@@ -9,3 +9,2 @@ import { WebPlugin } from '@capacitor/core'; | ||
async echo(options) { | ||
console.log('ECHO', options); | ||
return options; | ||
@@ -43,2 +42,3 @@ } | ||
}) })); | ||
this.loadEvents(); | ||
} | ||
@@ -57,2 +57,67 @@ else { | ||
} | ||
loadEvents() { | ||
this.playerInstance.on('play', (eventData) => { | ||
const event = { | ||
name: 'play', | ||
data: eventData | ||
}; | ||
this.notifyListeners('playerEvent', event); | ||
}); | ||
this.playerInstance.on('pause', (eventData) => { | ||
const event = { | ||
name: 'pause', | ||
data: eventData | ||
}; | ||
this.notifyListeners('playerEvent', event); | ||
}); | ||
this.playerInstance.on('playAttemptFailed', (eventData) => { | ||
const event = { | ||
name: 'playAttemptFailed', | ||
data: eventData | ||
}; | ||
this.notifyListeners('playerEvent', event); | ||
}); | ||
this.playerInstance.on('buffer', (eventData) => { | ||
const event = { | ||
name: 'buffer', | ||
data: eventData | ||
}; | ||
this.notifyListeners('playerEvent', event); | ||
}); | ||
this.playerInstance.on('idle', (eventData) => { | ||
const event = { | ||
name: 'idle', | ||
data: eventData | ||
}; | ||
this.notifyListeners('playerEvent', event); | ||
}); | ||
this.playerInstance.on('complete', (eventData) => { | ||
const event = { | ||
name: 'complete', | ||
data: eventData | ||
}; | ||
this.notifyListeners('playerEvent', event); | ||
}); | ||
this.playerInstance.on('error', (eventData) => { | ||
const event = { | ||
name: 'error', | ||
data: eventData | ||
}; | ||
this.notifyListeners('playerEvent', event); | ||
}); | ||
this.playerInstance.on('warning', (eventData) => { | ||
const event = { | ||
name: 'warning', | ||
data: eventData | ||
}; | ||
this.notifyListeners('playerEvent', event); | ||
}); | ||
this.playerInstance.on('seek', (eventData) => { | ||
const event = { | ||
name: 'seek', | ||
data: eventData | ||
}; | ||
this.notifyListeners('playerEvent', event); | ||
}); | ||
} | ||
getPosition() { | ||
@@ -59,0 +124,0 @@ if (this.playerInstance !== undefined) { |
{ | ||
"name": "jwplayer-capacitor", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Integration of JWPlayer Web and Mobile SDKs with Capacitor", | ||
@@ -5,0 +5,0 @@ "main": "dist/plugin.cjs.js", |
@@ -22,2 +22,4 @@ # jwplayer-capacitor | ||
* [`seek(...)`](#seek) | ||
* [`addListener(...)`](#addlistener) | ||
* [`removeAllListeners()`](#removealllisteners) | ||
* [Interfaces](#interfaces) | ||
@@ -112,2 +114,37 @@ | ||
### addListener(...) | ||
```typescript | ||
addListener(eventName: 'playerEvent', listenerFunc: EventChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle | ||
``` | ||
Listen for events in player | ||
| Param | Type | | ||
| ------------------ | ---------------------------------------------- | | ||
| **`eventName`** | <code>"playerEvent"</code> | | ||
| **`listenerFunc`** | <code>(event: JWPlayerEvent) => void</code> | | ||
**Returns:** <code>any</code> | ||
**Since:** 1.0.0 | ||
-------------------- | ||
### removeAllListeners() | ||
```typescript | ||
removeAllListeners() => any | ||
``` | ||
Remove all listeners (including the network status changes) for this plugin. | ||
**Returns:** <code>any</code> | ||
**Since:** 1.0.0 | ||
-------------------- | ||
### Interfaces | ||
@@ -132,2 +169,9 @@ | ||
#### PluginListenerHandle | ||
| Prop | Type | | ||
| ------------ | ------------------------- | | ||
| **`remove`** | <code>() => any</code> | | ||
</docgen-api> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1633618
5560
175