How it works
Step 1
Create an Ionic Angular app or use an existing one. For a new app, use the "tabs" template.
ionic start myApp tabsStep 2
Install the following dependencies
ionic cordova plugin add cordova-plugin-advanced-http
npm install ionic-youtube-search --save
https://www.npmjs.com/package/ionic-youtube-search
Step 3
Open the app in your IDE
Step 4
Import the "ionic-youtube-search" dependency in your *.page.ts file.
import * as youtube from 'ionic-youtube-search';
Step 5
Create a method that fetches the YouTube stream for a video ID. Then create a second method that plays the stream.
videos = [];
searchModel = '';
async search() {
this.videos = await youtube.search(this.searchModel);
}Step 6
Create a UI element, for example a button that lists all videos.
<ion-searchbar autocomplete="on" debounce="800" animated [(ngModel)]="searchModel" (ionClear)="videos = []" (ionChange)="search()"></ion-searchbar>
<ion-list>
<ion-list-header>
Recent Conversations
</ion-list-header>
<ion-item *ngFor="let video of videos">
<ion-avatar slot="start">
<img [src]="video.snippet.thumbnails.high.url">
</ion-avatar>
<ion-label>
<h2>{{video.snippet.title}}</h2>
<h3>{{video.snippet.publishedAt}}</h3>
<p>{{video.snippet.views.runs[0].text}}</p>
</ion-label>
</ion-item>
</ion-list>Step 7
Start the app in an emulator and test it.
ionic cordova emulate ios -l -c --target "YOUR SIMULATOR ID" -- --buildFlag="-UseModernBuildSystem=0"