player.addEventListener("YT.PlayerState.PLAYING",function(){console.log(player.getDuration()); }); Run Code Online (Sandbox Code Playgroud) 添加或删除事件监听器 player.addEventListener(event:String, listener:String):Void为指定事件添加侦听器功能。下面的“事件”部分标识了玩家可能触发的不同事件。侦听器...
function playerPause() { if (postData[nowPlaying].provider == 'youtube' ) { player.pauseVideo(); } else if (postData[nowPlaying].provider == 'soundcloud' ) { player.api_pause(); }; } Run Code Online (Sandbox Code Playgroud) 和eventListeners: soundcloud.addEventListener('onMediaEnd',...
JavaScript 定义全局 init 方法。这个方法名是规定的。不可自定义哦。 declare global { interface Window { onYouTubeIframeAPIReady: ()=>void; } } 然后append script vartag = document.createElement("script"); tag.src= "https://www.youtube.com/iframe_api";varfirstScriptTag = document.getElements...
onYouTubeIframeAPIReady,false);}$(document).ready(function(){});
function onPlayerReady(event) { event.target.playVideo(); } // 5. The API calls this function when the player's state changes. // The function indicates that when playing a video (state=1), // the player should play for six seconds and then stop. ...
代码语言:javascript 复制 using System; using System.Text.RegularExpressions; public class Program { public static void Main() { string youtubeUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; string videoId = GetYouTubeVideoId(youtubeUrl); Console.WriteLine(videoId); } public static...
playVideo = async function(callback) { // example: token and video url exists in props try { let { state, } = await RNYouTubePlayer.play('<< YouTube API Token >>', 'KawcajJGX-w'); if (state === 'stopped') { callback(); // stopped watching video, do something } } catch...
void loadVideo(string videoId, bool autoplay, var options) void pause() void play() void runJavaScript(string code, function callback) void runPlayerScript(string targetFunction, var arguments, function callback) void seekTo(int seconds, bool allowSeekAhead) void stop()...
} public MyWebViewRenderer(WKWebViewConfiguration config) : base(config) { userController = config.UserContentController; var script = new WKUserScript(new NSString(_JavascriptFunction_CSharpOpenWeb), WKUserScriptInjectionTime.AtDocumentEnd, false); ...
import { VideoUploaded as VideoUploadedEvent } from "../generated/YouTube/YouTube"; import { Video } from "../generated/schema"; export function handleVideoUploaded(event: VideoUploadedEvent): void { let video = new Video(event.params.id.toString()); video.hash = event.params.hash; video...