问题
I can't seem to make jwplayer (version 6)
stop playback while it's playing an ad. jwplayer().stop() and pause()
does absolutely nothing.
Are there any ad-specific playback control methods? Can't find them in the documents.
回答1:
For a non-VPAID ad
You can pause the ad by calling jwplayer().play()
.
a. To see this workaround, you can use this test page: http://support.jwplayer.com/customer/portal/articles/1431665-basic-preroll-video-ads
b. If you want to use this technique, you need to know the active state of the ad in the player, because you might end up making the ad resume and not pause (which would be the opposite of what you want). Your first inclination might be jwplayer().getState()
but this won't work because that will return the state of the video content and NOT the state of the ad. To work around this issue, you can keep track of the ad's state manually by listening to the onAdPlay
hook and it's siblings.
For a VPAID ad
You can't pause/stop the ad at all.
To answer Ethan's question about a page to reproduce:
i. Go to http://support.jwplayer.com/customer/portal/articles/1434330-vpaid-interactive-pre-roll
ii. Open the developer console
iii. Execute this command: jwplayer().play()
and note how the player starts playing the ad (which is good)
iv. Execute this command: jwplayer.play()
and note how the player won't pause (which is bad)
For step "iv", you can also try jwplayer.pause()
and jwplayer.stop()
. None of them will stop the VPAID ad.
Update
I am working with jwplayer on this issue, but for a VPAID ad here is a workaround which I've had some success with:
jwplayer().callInternal("jwCallVPAID", "pauseAd");
Note: This will only work if the VPAID creative has implemented a "pause" function which can be called externally, which they might not have.
You can also call "resumeAd" and "stopAd" in a similar fashion.
来源:https://stackoverflow.com/questions/22202139/stop-jwplayer-ad-playback