ycp-cjkn / Plum

A web app for collaboratively annotating YouTube videos
2 stars 3 forks source link

Implemented the Youtube API to allow videos to be played on video page #64

Closed kjones7 closed 5 years ago

kjones7 commented 5 years ago

NOTE: The "Create video pages" pull request (#62) should be merged into master before this

To test this out, simply go over to youtube, choose a random video, and use that URL for that video as the URL when creating the video. The URL MUST have the same pattern as this link though: https://www.youtube.com/watch?v=-O5kNPlUV7w

Once you do that it should load up the video once you visit the page. The video will start playing for 6 seconds and then stop. This is because that is what the default example does on the youtube API website (https://developers.google.com/youtube/iframe_api_reference) and I just left it that way for now. We can change that whenever.

Notice that using invalid youtube URLs still works, but an error just appears where the video normally would. We should implement some type of validation for the URL when creating the video to prevent this in the future.

Lastly, notice that I'm parsing the video identifier from the youtube URL (For example -O5kNPlUV7w from https://www.youtube.com/watch?v=-O5kNPlUV7w). I'm only storing this identifier and not the whole youtube URL since that's all the API needs. We can change that in the future or just stick with it.