How to automatically scroll to an anchor while audio plays - anchor

I'm working on an online learning portal. I have an audio player on a page designed by https://www.cleanhtmlplayer.com. I want to automatically scroll to an anchor of a page at specific timestamps of the audio.
For example, I have Anchor 1 and Anchor 2 in a webpage. As the audio is playing, I want the page to automatically scroll to Anchor 2 at the 5-minute mark. Is this possible?

You could add a listener to the timeupdate event and take an action depending on the value of the currentTime property.
If you rather prefer to use the Clean Html Player API, then when initializing in javascript on the plyrOptions argument, use the listeners property to bind to the timeupdate event.

Related

YouTube API html5 desktop click video area vs Android Chrome touch video area for pause

I can't find a simple yes/no answer - maybe my inability to ask the right question. I'm probably not seeing the obvious.
https://developers.google.com/youtube/iframe_api_reference
If I set-up the iframe api example as per the linked page, with an appropriate header (e.g. viewport etc.) then when I view the page in Chrome on the desktop, I can click on the video area to play, and pause the video. I do not need to use the play/pause control.
If I view the same site on my Note 4, I can touch the video area to play. But in order to pause, I have to click on the (now tiny) pause control. Touching the video area does nothing.
I know I can programmatically add some other element and initiate a pause via the API ... but I don't think I can add a touch or onclick event to the player ... and the player state change event won't be any good if the player isn't changing state on subsequent touches?
Yes / No (trying to keep within non-vague / discursive guidelines) ... is it possible, without "hacks" to pause the video, on mobile, with a touch to the video area?
I suspect not, as YouTube's own site, on my Note 4, behaves in the same way. I just can't find any discussion/questions about it. I ask the question, as it seems counter-intuitive to reduce the control area on a smaller touch device for pausing. It's annoying to me ... trying to use embedded YouTube in CSS3D where I have a video-wall 2x2 and the controls become tiny. I might have to overlay a transparent control element for touch but just want to check I haven't gone mad.

YouTube stopVideo() is pausing instead of stopping?

My website is running Bootstrap 3.0 and I have an intro video and full length video hosted on YouTube that I am trying to implement. The intro video autoplays when the page is loaded, and then I have a button that opens up a modal window with the full video with audio.
I would like to stop the video completely on close of the modal window so that if they click the button to open it again, the video starts from the beginning. Unfortunately, the stopVideo function doesn't seem to be working how I would expect. Basically, it's just pausing the video, so if I open the modal back up, the video starts playing right from where it left off.
How can I make it so that the video stops and starts from the beginning if it's reopened?
Here is my current code:
$('#myModal').on('show.bs.modal', function () {
$('#placeholder')[0].contentWindow.postMessage('{"event":"command","func":"' + 'pauseVideo' + '","args":""}', '*');
$('#full')[0].contentWindow.postMessage('{"event":"command","func":"' + 'playVideo' + '","args":""}', '*');
});
$('#myModal').on('hidden.bs.modal', function () {
$('#full')[0].contentWindow.postMessage('{"event":"command","func":"' + 'stopVideo' + '","args":""}', '*');
$('#placeholder')[0].contentWindow.postMessage('{"event":"command","func":"' + 'playVideo' + '","args":""}', '*');
});
Thanks!
You can use seekTo to get back to the begining of the video when the modal is open.
An play the video after the seekTo
Doc from API
player.seekTo(seconds:Number, allowSeekAhead:Boolean):Void
Seeks to a specified time in the video. If the player is paused when
the function is called, it will remain paused. If the function is
called from another state (playing, video cued, etc.), the player will
play the video. The seconds parameter identifies the time to which the
player should advance.
The player will advance to the closest keyframe before that time
unless the player has already downloaded the portion of the video to
which the user is seeking. In that case, the player will advance to
the closest keyframe before or after the specified time as dictated by
the seek() method of the Flash player's NetStream object. (See Adobe's
documentation for more information.)
The allowSeekAhead parameter determines whether the player will make a
new request to the server if the seconds parameter specifies a time
outside of the currently buffered video data.
We recommend that you set this parameter to false while the user drags
the mouse along a video progress bar and then set it to true when the
user releases the mouse. This approach lets a user scroll to different
points of a video without requesting new video streams by scrolling
past unbuffered points in the video. When the user releases the mouse
button, the player advances to the desired point in the video and
requests a new video stream if necessary.
I also encountered this problem,spend hours digging into it. however I didn't find a sure reason, but the following reason may be it:
("stopVideo()") Stops and cancels loading of the current video.
and
Important: Unlike the pauseVideo function, which leaves the player in the paused (2) state, the stopVideo function could put the player into any not-playing state, including ended (0), paused (2), video cued (5) or unstarted (-1).
This is quoted from the YouTube API page
But I'm confused by this, because even if the background mechanism are not the same between stop and pause api, they act still identical(sometimes), so I'm still confused and curious about the real usage of stopVideo().

Embedding youtube video with only play,pause and refresh buttons

I want to embed youtube video in my website. My requirement is that the player should have only three options: play, pause and refresh. I want to disable the progressbar slider so that viewer can not move forward or backward.
I used the parameter "controls=0", but it removes the progressbar completely. I just want to disable the dragging functionality.
Anybody knows how to do this?
setting autohide=2 should do it.
https://developers.google.com/youtube/player_parameters#autohide

Youtube embeded in delphi autoplay&loop refreshing

I've just made simple YouTube player in SDI using embedded links inside the TWebBrowser component, and managed to create auto play and loop (loop one and loop all) buttons as well as quality changing radio buttons, but they're all based on hyperlink changes, and therefore does not perform a change while video playing, but have to send "Go" command again. I've implemented it with the buttons mentioned above, but it's annoying to restart video when making a change, especially if I just want to set loop somewhere in the middle of the song.
Is there any way of maybe reading current time and set then set link with that time starting, or any other way of solving this, so when pressing the button, the action will be accepted with no refresh, or won't restart the video from beginning?
The default buttons for changing quality within the player itself does exactly that, but can't find a command.
Also, on YouTube there is a button in playlist to loop, as well as randomize, but can't find them either.

MPMoviePlayerController, disallow fullscreen but allow navigation through clip?

I have a video in my iPad app, but I dont want it to be able to go to fullscreen. However I do potentially want the user to be able to navigate to the part of the video that they want to see.
As far as I can tell there are only three options for the controls that you give the user:
None, Embedded, or Fullscreen.
None gives the user no control.
Embedded and Fullscreen basically give the use the same amount of control but just start in different states.
Basically what I want is Embedded with the switch to Fullscreen option taken out.
Anybody know if its possible? Thanks
You can set the controls style to "None", and then add your own custom view to navigate using a UISlider (I've done this in the past).
MPMoviePlayerController adheres to the MPMediaPlayback protocol, so you take the total playback time of the movie, multiply it by the UISlider value (when it changes), and then adjust the movie's playback head position.
You'll also need an NSTimer or KVO to monitor the playback time so it can update the slider UI element in realtime.

Resources