need an assistance to setup a Scroll To Play mode for JWPlayer. Anyone can help?
Basically, I need a video to start only when a user scrolled down the page, where the video player is embed. Autoplay or Click To Play functions do not suit me here. Unfortunately, there is no built in functionality in the CMS of JWPlayer for Scroll To Play settings.
Any advice on this will help me a lot!
Thanks in advance!
You can start the player when the player is visible. Something like:
scrollView.getViewTreeObserver().addOnScrollChangedListener(
new ViewTreeObserver.OnScrollChangedListener() {
#Override
public void onScrollChanged() {
Rect scrollBounds = new Rect();
scrollView.getHitRect(scrollBounds);
if (player.getLocalVisibleRect(scrollBounds)) {
// if player is visible (even a single pixel)
if (player.getState() != PLAYING) {
player.play(true);
}
} else {
// if player is not visible (even a single pixel)
if (player.getState() == PLAYING) {
player.pause(true);
}
}
}
})
```
Related
I have a video i am playing on the stage, once the video has stopped playing I either want the video to be removed or to go to a new frame.
I have tried using playheadTime to do this but it doesn't work.
Here is the code i've tried
if(badVideo.playheadTime == 115)
{
stage.removeChild(badVideo );
}
The video is 1:55 long
If any one knows how I should go about doing this it would be appriciated.
I suppose that you use FLVPlayback...
You need to use the COMPLETE event :
import fl.video.VideoEvent;
badVideo.addEventListener( VideoEvent.COMPLETE , onVideoComplete);
function onVideoComplete(e:VideoEvent):void {
badVideo.removeEventListener(VideoEvent.COMPLETE , onVideoComplete);
// do what you want
}
Doc
I've got a Flash CS6 FLA with an instance of the FLVPlayback component (2.5.0.26) and an instance of the Progress Bar component on the stage, loading an external FLV.
I'm trying to preload a specific percentage of video before playing.
When hosted on a server, the video launches and plays as expected 80% of the time, but 20% of the time the video gets stuck in a buffering state on launch (blank area where video should be), and I can't get it to play through AS3 or by clicking the play button on the skin controls. Oddly, if I refresh the browser when it's stuck I see a glimpse of the video before the page reloads and then plays the video as expected.
I've tested on a Mac (Lion) in Chrome, Firefox, and Safari and had the same results.
The video problem gets worse if I limit my bandwidth using SpeedLimit.
Any suggestions would be greatly appreciated.
Code:
public class SimpleVideoLoad extends MovieClip {
var isLoaded:Boolean = false;
public function SimpleVideoLoad() {
// constructor code
loadVideo();
}
function loadVideo():void
{
my_FLVPlybk.x = 0;
my_FLVPlybk.y = 0;
my_FLVPlybk.width = 743;
my_FLVPlybk.height = 300;
my_FLVPlybk.source = "CARSdotCOM_OLD.flv";
//preloader component
pb.source = my_FLVPlybk;
pb.addEventListener(ProgressEvent.PROGRESS, progressHandlerPB);
}
//progress bar component
function progressHandlerPB(event:ProgressEvent):void {
var percentOfVideoLoaded = pb.percentComplete;
if (percentOfVideoLoaded>10 && isLoaded == false){
isLoaded = true;
my_FLVPlybk.play();
}
}
}
I am using an html5 video player on a website.
When the user starts playing it, the player goes into fullscreen mode and plays the video.
When the video has ended, I catch the ended event and close the video player via myvideo.webkitExitFullScreen();.
Now, I need another event when the player actually gets closed either if the user taps the "done" button in top bar or if the player gets closed via video.webkitExitFullScreen();.
Is there a way to do this?
Updated Answer
You can use the webkitendfullscreen and webkitenterfullscreen events:
var vid = document.getElementById("some-vid");
vid.addEventListener('webkitendfullscreen', function (e) {
// handle end full screen
});
vid.addEventListener('webkitenterfullscreen', function (e) {
// handle enter full screen
});
Previous Answer
A similar question was asked here: How do I capture keyboard events while watching an HTML5 video in fullscreen mode? - not sure how to link these 2 questions.
I'm just going to assume you use jQuery for ease of writing this code. You just need to know when the video has changed modes from full-screen to not-full-screen... so on Resize you can check the video.webkitDisplayingFullscreen; property.
var isVideoFullscreen = video.webkitDisplayingFullscreen;
$(window).bind("resize", function (e) {
// check to see if your browser has exited fullscreen
if (isVideoFullscreen != video.webkitDisplayingFullscreen) { // video fullscreen mode has changed
isVideoFullscreen = video.webkitDisplayingFullscreen;
if (isVideoFullscreen) {
// you have just ENTERED full screen video
} else {
// you have just EXITED full screen video
}
}
});
Hope this helps or points you in the right direction
$('video').bind('webkitfullscreenchange mozfullscreenchange fullscreenchange', function(e) {
var state = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
var event = state ? 'FullscreenOn' : 'FullscreenOff';
// Now do something interesting
alert('Event: ' + event);
});
I have a flash musicplayer, that is very simple by itself. it has one button, Start/Stop.
The player itself is in footer.
The Problem: when the page loads music won't start (FLASH player won't play) before you don't see it on the page, I mean, when the screen is small by resolution, you don't see the footer - and music doesn't start. when you scroll down to footer (when you see the player) it starts playing.
How should I do that no matter if you see the player or not - the player starts playing.
THANKSSS!!!!
Do play & stop buttons in JavaScript for the 1px square player in position fixed on the top.
in javascript :
str = "stop";
function appel(str) {
document.getElementById("id_flash").echo(str);
}
in as3 :
import flash.external.*;
function echo(str:String):Void {
switch(str) {
case "play":
sound.play();
break;
case "stop":
sound.stop();
break;
}
}
ExternalInterface.addCallback("echo", null, echo);
I'm writing a Flex video player with a "slow advance" button, and my first approach is to simply toggle between play() and pause() on a timer. I'd like to say something like
if (video.isPlaying) {
video.pause();
} else {
video.play();
}
But I can't find anything like an 'isPlaying' property. Am I barking up the wrong tree?
The property (Boolean) is not "isPlaying" but simply "playing" :)
FTQuest
How about something like this:
if (video.currentCSSState == 'playing'){
// is playing
} else {
// is not playing
}
Since currentCSSState is a protected method you'll have to extend the video component and either expose it or ad your own "isPlaying" property/method.