Skip to content

Commit 28c13bc

Browse files
committed
feat: standalone version
1 parent fc26fbf commit 28c13bc

15 files changed

+53
-93
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
## v 17.1.0 (2024/06/20)
3+
4+
- [NEW] - now using standalone component (not module)
5+
26
## v 17.0.0 (2024/06/20)
37

48
- upgrade - bump to version 17

README.md

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/orizens/ngx-youtube-player.svg?branch=master)](https://travis-ci.org/orizens/ngx-youtube-player)
1+
22
[![npm version](https://badge.fury.io/js/ngx-youtube-player.svg)](https://badge.fury.io/js/ngx-youtube-player)
33
[![npm downloads a month](https://img.shields.io/npm/dm/ngx-youtube-player.svg)](https://img.shields.io/npm/dm/ngx-youtube-player.svg)
44
[![npm downloads a week](https://img.shields.io/npm/dt/ngx-youtube-player.svg)](https://img.shields.io/npm/dt/ngx-youtube-player.svg)
@@ -7,36 +7,33 @@
77

88
`npm i ngx-youtube-player`
99

10-
# Angular Youtube Player Component
10+
# Angular Youtube Player Component (Standalone)
1111

1212
This is an Angular component based on [youtube player iframe api](https://developers.google.com/youtube/iframe_api_reference).
1313
This component came out as a result of the [open source project Echoes Player](http://github.com/orizens/echoes-player) - an alternative player for watching and listening to media from youtube.
1414

15-
## Breaking Change with v7
15+
## Breaking Change with v17
1616

17-
| Before < v7 | After >= v7 |
17+
| Before < v17 | After >= v17.1.0 |
1818
| --------------------- | ---------------------------------- |
19-
| `YoutubePlayerModule` | `NgxYoutubePlayerModule` |
20-
| `YoutubePlayerModule` | `NgxYoutubePlayerModule.forRoot()` |
19+
| `YoutubePlayerModule.forRoot()` | as standalone version |
2120

2221
## Angular Support
2322

24-
**Starting with version 6**, versions follow Angular's version to easily reflect compatibility.
25-
26-
Meaning, for Angular 11, use ngx-youtube-player @ ^11.0.0
23+
**Starting with version 17.1.0**, `YoutubePlayerComponent` is a standalone component
2724

2825
## LICENSE
2926

3027
Angular Youtube Component includes 2 optional licenses:
3128

32-
1. **Free** - for open source projects - includes standard play features, released under **MIT** license.
33-
2. **Commercial (Enterprize)** - **you must purchase a license**, includes the following features:
29+
1. **Free** - for open source projects - includes standard play features, released under **MIT** license.
30+
2. **Commercial (Enterprize)** - **you must purchase a license**, includes the following features:
3431

3532
- License types:
3633
- app developer (\$200) - a license for each developer working with this component for one product only
3734
- platform developer (\$550) - a license for each developer developer working with component for all products in one company
3835

39-
To purchase a license, please contact at https://orizens.com/contact
36+
To purchase a license, please contact at <https://orizens.com/contact>
4037

4138
## Installation
4239

@@ -66,20 +63,10 @@ Currently supported attributes:
6663
First, import the YoutubePlayerModule to your module:
6764

6865
```typescript
69-
import { NgModule } from "@angular/core";
70-
import { BrowserModule } from "@angular/platform-browser";
71-
import { YoutubePlayerModule } from "ngx-youtube-player";
7266
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
7367
import { AppComponent } from "./app";
7468

75-
@NgModule({
76-
imports: [BrowserModule, YoutubePlayerModule.forRoot()],
77-
declarations: [AppComponent],
78-
bootstrap: [AppComponent],
79-
})
80-
export class AppModule {}
81-
82-
platformBrowserDynamic().bootstrapModule(AppModule);
69+
bootstrapApplication(AppComponent);
8370
```
8471

8572
Next, use the **youtube-player** component. A Unique Id will be created for this player's instance:
@@ -88,6 +75,7 @@ Next, use the **youtube-player** component. A Unique Id will be created for this
8875
import { Component } from "@angular/core";
8976

9077
@Component({
78+
standalone: true,
9179
selector: "app",
9280
template: `
9381
<youtube-player
@@ -96,6 +84,7 @@ import { Component } from "@angular/core";
9684
(change)="onStateChange($event)"
9785
></youtube-player>
9886
`,
87+
imports: [YoutubePlayerComponent]
9988
})
10089
export class AppComponent {
10190
player: YT.Player;
@@ -111,13 +100,11 @@ export class AppComponent {
111100
}
112101
```
113102

114-
## Testing
103+
## Testing (DISABLED)
115104

116105
To start developing tdd/bdd style: `npm run dev`
117106
This will: compile ts files, watch for changes and start the test task. Whenever a ts file is changed, it will rerun the tests.
118107

119-
Travis-ci is integrated
120-
121108
# Showcase Examples
122109

123110
- [Echoes Player](http://orizens.github.io/echoes-player) ([github repo for echoes player](http://github.com/orizens/echoes-player))

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-youtube-player",
3-
"version": "17.0.0",
3+
"version": "17.1.0",
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",
@@ -56,4 +56,4 @@
5656
"url": "https://github.com/orizens/ngx-youtube-player/issues"
5757
},
5858
"homepage": "https://github.com/orizens/ngx-youtube-player"
59-
}
59+
}

projects/ngx-youtube-player/package-lock.json

Lines changed: 18 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/ngx-youtube-player/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-youtube-player",
3-
"version": "17.0.0",
3+
"version": "17.1.0",
44
"author": "Oren Farhi (orizens.com)",
55
"peerDependencies": {
66
"@angular/common": "^17.0.0",

projects/ngx-youtube-player/src/lib/ngx-youtube-player.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ import {
55
ElementRef,
66
EventEmitter,
77
Input,
8-
OnChanges,
98
Output,
109
Renderer2,
11-
SimpleChanges
1210
} from '@angular/core';
1311
import {
1412
YoutubePlayerService,
1513
defaultSizes
1614
} from './ngx-youtube-player.service';
1715

1816
@Component({
17+
standalone: true,
1918
changeDetection: ChangeDetectionStrategy.OnPush,
2019
selector: 'youtube-player',
2120
template: `
2221
<div id="yt-player-ngx-component"></div>
23-
`
22+
`,
23+
providers: [YoutubePlayerService],
2424
})
2525
export class YoutubePlayerComponent implements AfterContentInit {
2626
@Input() videoId = '';

projects/ngx-youtube-player/src/lib/ngx-youtube-player.module.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

projects/ngx-youtube-player/src/lib/ngx-youtube-player.service.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('YoutubePlayerService', () => {
2626
.createSpy('YTPlayer')
2727
.and.callFake((id: string, params: any) => params),
2828
PlayerState: 1
29-
};
29+
} as any;
3030

3131
it('should create an instance of YoutubePlayerService', () => {
3232
const service = new YoutubePlayerService(zone);
@@ -47,7 +47,7 @@ describe('YoutubePlayerService', () => {
4747
const actual = service.api;
4848
spyOn(service.api, 'next');
4949
win()['onYouTubeIframeAPIReady']();
50-
expect(service.api.next).toHaveBeenCalledWith(global['YT']);
50+
expect(service.api.next).toHaveBeenCalledWith(global['YT'] as any);
5151
});
5252

5353
it('should generate a unique id', () => {

projects/ngx-youtube-player/src/lib/ngx-youtube-player.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable, NgZone } from "@angular/core";
22
import { ReplaySubject } from "rxjs";
3-
import { IPlayerApiScriptOptions, IPlayerOutputs, IPlayerSize } from "./models";
3+
import { IPlayerApiScriptOptions, IPlayerOutputs, IPlayerSize } from "./types";
44

55
export function win() {
66
return window;

0 commit comments

Comments
 (0)