Turbe$Z Posted March 8, 2020 Posted March 8, 2020 I created a youtube player, and i want to remove the event handler, when the music ends, but i dont know how to get the song length from web browser... anyone can help? My Fun server: My DD server:
Moderators Patrick Posted March 8, 2020 Moderators Posted March 8, 2020 I think it is not possible, because you can't execute javascript in remote browsers. community profile | map converters | map images | pDownloader | pAttach | model encrypter
Moderators thisdp Posted March 9, 2020 Moderators Posted March 9, 2020 It may be possible if using fetchRemote with youtube's API
Turbe$Z Posted March 9, 2020 Author Posted March 9, 2020 24 minutes ago, thisdp said: It may be possible if using fetchRemote with youtube's API I tried fetchRemote the yt link, but the responseData got nil... My Fun server: My DD server:
Moderators Patrick Posted March 9, 2020 Moderators Posted March 9, 2020 (edited) 6 hours ago, thisdp said: It may be possible if using fetchRemote with youtube's API Ohh.. it's a good idea. local apiKey = "censored" -- How to get own: https://www.youtube.com/watch?v=pP4zvduVAqo local browser = createBrowser(500, 500, false) function receiveData(result) local data = fromJSON(result) local isoDuration = data.items[1].contentDetails.duration local min, sec = isoDuration:match("^.-(%d+)M(%d+)S") -- this pattern work only with minimum 1 min, and maximum 1 hour videos setTimer(function() removeEventHandler("onClientRender", root, render) end, (min*60 + sec) * 1000, 1) end function render() dxDrawImage(0, 0, 500, 500, browser) end addEventHandler("onClientBrowserCreated", browser, function() local url = "https://www.youtube.com/watch?v=NLb-gZNKzT8" local id = url:match("%?v=(...........)") -- maybe need a better pattern :'D loadBrowserURL(source, url) addEventHandler("onClientRender", root, render) fetchRemote("https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id="..id.."&key="..apiKey, receiveData) end) @Turbe$Z something like that Edited March 9, 2020 by Patrick 1 community profile | map converters | map images | pDownloader | pAttach | model encrypter
Moderators thisdp Posted March 9, 2020 Moderators Posted March 9, 2020 7 hours ago, Turbe$Z said: I tried fetchRemote the yt link, but the responseData got nil... that's weird
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now