問題描述
Tương tác với trình phát youtube được nhúng của học viện Khan (Interacting with Khan academy's embedded youtube player)
I was wondering if there is a way to interact with the youtube video's iframe that is inside teh Khan Academy's embedded code (which renders an iframe with the youtube iframe inside it).
I am trying to play/pause the youtube video from my inside my page, as well as query the progress of the video.
All I can find is this page for info (and it doesn't have any info at all): http://www.khanacademy.org/about/blog/post/29139422372/embeddable‑khan‑academy‑video‑player
I would simply embed the youtube video itself, but I would like for the logged‑in student to receive credit at the KA for watching the video, so I need to use their embed.
參考解法
方法 1:
If you want to automate watching the videos, you can open a web browser under the control of selenium.
- make a list of videos to watch (using the API, or extract the info from the site)
- open the page for the video, it will load but not start playing
- click on the video element to start playing
- loop to watch for the video to be finished (the progress is in the video, I would not bother with that), the video frame closes and a result points screen is shown, which you can detect
Take care to keep track of videos watched, and there can be multiple URLs to the same video. Also some videos have questions associated with that, if you are watching unattended, you should switch those off.
A few subjects have enough video material to give you Earth badges for Ridiculous Listener (so far I found seven of them, but this might change with rearrangements).
方法 2:
That's 2 different things. You can't do both at the same time. So you should open 2 questions.
1/ How to interact with the Youtube player, and embed it (but you didn't mention where you want to embed it)
2/ How to fetch the bonus points from the Khan Academy API (but we don't know how you want to present the data, and where).
3/ Make a script that control the player and call the function to get the data from Khan Academy at the same time.
Your request is not very well described. I can't really understand what you are trying to achieve. Is it as a teacher? What is exactly the situation? I don't understand for instance "from my inside my page". What do you mean? Do you want to make your own private website for your students, to make a different presentation, fetching data from Youtube and Khan Academy? We need explanations about the final goal.
So, to try to answer your first question, you have many helps on the internet, for instance, read documentation like:
http://tutorialzine.com/2015/08/how‑to‑control‑youtubes‑video‑player‑with‑javascript
And here you have all the documentation about the Khan Academy API, to fetch the points, the badge, etc...
An extensive answer would be to write the script and to paste it here. I don't think we can make more precise answers for your question, as you need to start your code and then, ask precise questions about the problems you will met. Your question needs to be problem by problem.
(by electrichead、Anthon、Quidam)