Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

youtube-player startSeconds and endSeconds not working #18212

Closed
taivo opened this issue Jan 19, 2020 · 1 comment · Fixed by #18214 or hrueger/AGLight#112
Closed

youtube-player startSeconds and endSeconds not working #18212

taivo opened this issue Jan 19, 2020 · 1 comment · Fixed by #18214 or hrueger/AGLight#112
Assignees
Labels
P2 The issue is important to a large percentage of users, with a workaround

Comments

@taivo
Copy link

taivo commented Jan 19, 2020

Reproduction

Steps to reproduce:

  1. Create a wrapper component that uses , just like the example in the docs except with startSeconds and endSeconds
<youtube-player width="100%" height="100%" 
    videoId="PRQCAL_RMVo" 
    [startSeconds]="40" 
    [endSeconds]="60"
</youtube-player>
  1. Observe that the startSeconds and endSeconds parameters were not respected. Clicking the play button shows video starting at 0 second.

Expected Behavior

What behavior were you expecting to see?
I expected to see the video start playing at the 40 second mark.

Actual Behavior

This method

set startSeconds(startSeconds) {
      this._startSeconds.emit(startSeconds);
}

fired before this line in YouTubePlayer.ngOnInit

const startSecondsObs = this._startSeconds.pipe(startWith(undefined));

The same is true for endSeconds and suggestedQuality.

The effect is that the initial startSeconds and endSeconds value specified by the wrapper component is reset to undefined

For example: if the template was

<youtube-player width="100%" height="100%" 
    videoId="PRQCAL_RMVo" 
    [startSeconds]="40" 
    [endSeconds]="60"
</youtube-player>

The property startSeconds will trigger this._startSeconds.emit(40);, then startSecondObs will be set to startWith(undefined), and from there on, the initial values 40 and 60 no longer honored.

Work around: in the component that uses , use template variables to keep track of startSeconds, endSeconds, and suggestedQuality, and leverage setTimeout or lodash.defer to set those values a 2nd time.


Glancing at the code, I believe the correct approach has been handled for videoId, width, and height. It just has not been propagated to startSeconds, endSeconds, and suggestedQuality.

Environment

  • Angular:
  • CDK/Material:
  • Browser(s):
  • Operating System (e.g. Windows, macOS, Ubuntu):
@crisbeto crisbeto self-assigned this Jan 19, 2020
@crisbeto crisbeto added has pr P2 The issue is important to a large percentage of users, with a workaround labels Jan 19, 2020
crisbeto added a commit to crisbeto/material2 that referenced this issue Jan 19, 2020
The way the `youtube-player` is set up is that the start and end seconds are observables which means that the consumer will miss out on any values that were emitted before they subscribed. These changes switch them to a `BehaviorSubject` which emits its last value upon subscription.

Also does some internal cleanup in the component.

Fixes angular#18212.
jelbourn pushed a commit that referenced this issue Jan 22, 2020
#18214)

The way the `youtube-player` is set up is that the start and end seconds are observables which means that the consumer will miss out on any values that were emitted before they subscribed. These changes switch them to a `BehaviorSubject` which emits its last value upon subscription.

Also does some internal cleanup in the component.

Fixes #18212.
jelbourn pushed a commit that referenced this issue Jan 22, 2020
#18214)

The way the `youtube-player` is set up is that the start and end seconds are observables which means that the consumer will miss out on any values that were emitted before they subscribed. These changes switch them to a `BehaviorSubject` which emits its last value upon subscription.

Also does some internal cleanup in the component.

Fixes #18212.

(cherry picked from commit 8f2007f)
yifange pushed a commit to yifange/components that referenced this issue Jan 30, 2020
angular#18214)

The way the `youtube-player` is set up is that the start and end seconds are observables which means that the consumer will miss out on any values that were emitted before they subscribed. These changes switch them to a `BehaviorSubject` which emits its last value upon subscription.

Also does some internal cleanup in the component.

Fixes angular#18212.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
2 participants