首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将选定的视图传递给主玩家角/Youtube

将选定的视图传递给主玩家角/Youtube
EN

Stack Overflow用户
提问于 2021-05-30 18:19:03
回答 1查看 74关注 0票数 0

所以今天我试着完成一个我坐了一段时间的角度项目。它是一个模拟YouTube应用程序,使用youtubes来获取一个显示资源。我似乎无法通过从视频列表发送我的视频到主要玩家。我的服务很好。当我做一个搜索,我的视频列表是更新和渲染。我正在处理的问题是将选定的视频传递给主播放器。任何线索。谢谢各位

像往常一样,任何让这件事变得更容易理解的提示/建议都将被采纳。

这是我的Youtube组件

代码语言:javascript
复制
@Component({
  selector: 'app-video-player',
  templateUrl: './video-player.component.html',
  styleUrls: ['./video-player.component.css']
})
export class VideoPlayerComponent implements OnInit {
  @Input() thumbnail!: any;
  @Input() title!: any;
  @Output() newVideos: EventEmitter<any> = new EventEmitter();

  hi:string = "Video Name"
  title2:any = "Description"
  videos: VideoObject[];
  constructor(private youtubeservice: YouTubeService) { }

  ngOnInit(): void {
    console.log("YOUTUBE PLAYER COMPONENT", this.title)
    
  }

Youtube主要玩家

代码语言:javascript
复制
 <youtube-player 
    videoId="k5E2AVpwsko" 
    id="size" 
 >

</youtube-player>
        {{ hi }}
        <h5>{{ title}}</h5>
        {{ title2}}
    </div>

我的视频列表组件..。我想把选定的视频传递给疼痛播放器

代码语言:javascript
复制
@Component({
  selector: 'app-video-list',
  templateUrl: './video-list.component.html',
  styleUrls: ['./video-list.component.css']
})
export class VideoListComponent implements OnInit {
videos!:VideoObject[];

constructor(private youtubeservice: YouTubeService) { }

  ngOnInit() {
  
    this.youtubeservice.getVids("Sesame Street").subscribe((results:any) =>{
     this.videos = results;
      console.log("List Component ", this.videos)
     });

     
  }
  updateVids(vid:VideoObject){
    this.youtubeservice.updateVids(vid).subscribe((results:any) => {
      this.videos = results;
      console.log("FROM VIDEO LIST", this.videos)
    })
  }
  
}

视频列表模板

代码语言:javascript
复制
<app-search (searchVideos)="updateVids($event)"> </app-search>
<div>
  <app-video-list-entry
    *ngFor="let vid of videos"
    [thumbnail]="vid.snippet.thumbnails.default.url"
    [title]="vid.snippet.title"
    [channelId]="vid.snippet.channelId"
    [channelUrl]="vid.id.videoId"
  >
  </app-video-list-entry>
</div>
EN

回答 1

Stack Overflow用户

发布于 2021-05-30 19:20:14

VideoListEntry组件的单击处理程序可以让父组件将channelUrl传递给它。将channelUrl保存在组件状态,如果<youtube-player>组件位于同一组件中,只需将Url传递给<youtube-player>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67764482

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档