added showing iframe media in overlay
This commit is contained in:
parent
258fc00914
commit
fe8aadd8ff
|
@ -9,4 +9,7 @@
|
||||||
<video class="media-viewer-canvas__image" *ngIf="videoUrl" role="application" loop controls="controls" (click)="blockClick($event)">
|
<video class="media-viewer-canvas__image" *ngIf="videoUrl" role="application" loop controls="controls" (click)="blockClick($event)">
|
||||||
<source src="{{ videoUrl }}" type="video/mp4">
|
<source src="{{ videoUrl }}" type="video/mp4">
|
||||||
</video>
|
</video>
|
||||||
|
|
||||||
|
<div #video *ngIf="html" class="media-viewer-canvas__image media-viewer-canvas__iframe" [innerHTML]="html">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -27,4 +27,12 @@
|
||||||
margin-left: 50vw;
|
margin-left: 50vw;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__iframe {
|
||||||
|
height: 60vw;
|
||||||
|
width: 95vw;
|
||||||
|
max-height: 600px;
|
||||||
|
max-width: 950px;
|
||||||
|
border: 1px solid greenyellow;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
import { Component, OnInit, Input, Output } from '@angular/core';
|
import { Component, OnInit, Input, Output } from '@angular/core';
|
||||||
|
import { SafeHtml } from '@angular/platform-browser';
|
||||||
import { faChevronLeft, faChevronRight, faTimes } from "@fortawesome/free-solid-svg-icons";
|
import { faChevronLeft, faChevronRight, faTimes } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
import { OpenMediaEvent } from '../../models/common.model';
|
import { OpenMediaEvent } from '../../models/common.model';
|
||||||
import { Attachment } from '../../services/models/mastodon.interfaces';
|
import { Attachment } from '../../services/models/mastodon.interfaces';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-media-viewer',
|
selector: 'app-media-viewer',
|
||||||
templateUrl: './media-viewer.component.html',
|
templateUrl: './media-viewer.component.html',
|
||||||
|
@ -20,14 +22,19 @@ export class MediaViewerComponent implements OnInit {
|
||||||
imageUrl: string;
|
imageUrl: string;
|
||||||
gifvUrl: string;
|
gifvUrl: string;
|
||||||
videoUrl: string;
|
videoUrl: string;
|
||||||
|
html: SafeHtml;
|
||||||
|
|
||||||
@Input('openedMediaEvent')
|
@Input('openedMediaEvent')
|
||||||
set openedMediaEvent(value: OpenMediaEvent) {
|
set openedMediaEvent(value: OpenMediaEvent) {
|
||||||
this._mediaEvent = value;
|
this._mediaEvent = value;
|
||||||
|
|
||||||
|
if (value.iframe) {
|
||||||
|
this.html = value.iframe;
|
||||||
|
} else {
|
||||||
const attachment = value.attachments[value.selectedIndex];
|
const attachment = value.attachments[value.selectedIndex];
|
||||||
this.loadAttachment(attachment);
|
this.loadAttachment(attachment);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
get openedMediaEvent(): OpenMediaEvent {
|
get openedMediaEvent(): OpenMediaEvent {
|
||||||
return this._mediaEvent;
|
return this._mediaEvent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ export class AttachementsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
attachmentSelected(index: number): boolean {
|
attachmentSelected(index: number): boolean {
|
||||||
let openMediaEvent = new OpenMediaEvent(index, this.attachments);
|
let openMediaEvent = new OpenMediaEvent(index, this.attachments, null);
|
||||||
this.navigationService.openMedia(openMediaEvent);
|
this.navigationService.openMedia(openMediaEvent);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import { faPlay, faExpand, faExternalLinkAlt } from "@fortawesome/free-solid-svg
|
||||||
import { faFileAlt } from "@fortawesome/free-regular-svg-icons";
|
import { faFileAlt } from "@fortawesome/free-regular-svg-icons";
|
||||||
|
|
||||||
import { Card } from '../../../../services/models/mastodon.interfaces';
|
import { Card } from '../../../../services/models/mastodon.interfaces';
|
||||||
|
import { NavigationService } from '../../../../services/navigation.service';
|
||||||
|
import { OpenMediaEvent } from '../../../../models/common.model';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -24,14 +26,12 @@ export class CardComponent implements OnInit {
|
||||||
html: SafeHtml;
|
html: SafeHtml;
|
||||||
showHtml: boolean;
|
showHtml: boolean;
|
||||||
|
|
||||||
constructor(private sanitizer: DomSanitizer) { }
|
constructor(
|
||||||
|
private readonly navigationService: NavigationService,
|
||||||
|
private readonly sanitizer: DomSanitizer) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
// console.warn('card');
|
|
||||||
// console.warn(this.card);
|
|
||||||
|
|
||||||
this.host = this.card.url.replace('https://', '').replace('http://', '').split('/')[0];
|
this.host = this.card.url.replace('https://', '').replace('http://', '').split('/')[0];
|
||||||
this.html = this.sanitize(this.card);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private sanitize(card: Card): SafeHtml{
|
private sanitize(card: Card): SafeHtml{
|
||||||
|
@ -44,6 +44,7 @@ export class CardComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
play(): boolean {
|
play(): boolean {
|
||||||
|
this.html = this.sanitize(this.card);
|
||||||
this.showHtml = true;
|
this.showHtml = true;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -57,6 +58,10 @@ export class CardComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
expand(): boolean {
|
expand(): boolean {
|
||||||
|
this.html = this.sanitize(this.card);
|
||||||
|
|
||||||
|
const openMedia = new OpenMediaEvent(null, null, this.html);
|
||||||
|
this.navigationService.openMedia(openMedia);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
|
import { SafeHtml } from '@angular/platform-browser';
|
||||||
|
|
||||||
import { Attachment, Status } from "../services/models/mastodon.interfaces";
|
import { Attachment, Status } from "../services/models/mastodon.interfaces";
|
||||||
import { AccountInfo } from '../states/accounts.state';
|
import { AccountInfo } from '../states/accounts.state';
|
||||||
|
|
||||||
|
|
||||||
export class OpenMediaEvent {
|
export class OpenMediaEvent {
|
||||||
constructor(
|
constructor(
|
||||||
public selectedIndex: number,
|
public selectedIndex: number,
|
||||||
public attachments: Attachment[]) {
|
public attachments: Attachment[],
|
||||||
|
public iframe: SafeHtml) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue