Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Input outside of focus ? [Not solved]

Discussion in 'Scripting' started by RickyX, Aug 6, 2016.

  1. RickyX

    RickyX

    Joined:
    Jan 16, 2013
    Posts:
    280
    Hello.
    So i ran into this problem. I'm making my own custom youtube playlist player inside unity which i know isn't a good engine to do this in, but i'm so used to it i just don't want to try anything else. What i don't like in youtube's playlist player is that it doesn't have a randomize option that won't repeat the same videos. I want it to go through the list, make a random order every time but to not repeat the videos until it goes through all of the videos. Okay that much about useless info, let's get to the point.
    So, so far i got the basic code. I'm collecting urls from a .txt file and storing them inside a list of strings, and then i have some more code to actually open these links randomly and to delete the ones that were already played off the list. The problem is though, to actually play the next video you have to go back inside the game view and press a button and it will open the next one. But what i want is for it to either do it automatically after the video is finished, which i think would require either youtube API which i find complicated to implement into my project. Or some kind of web API to check when the video is finished in order to play the next one right ? That could work but i have no idea where to start. Another method which i wouldn't mind to have in replacement from previous is to have a hotkey that will open the next song while i'm not focused onto the game view. Of course, unity's input system only listens to inputs while you're focused onto the game view, the game window.
    So, what would be the best solution for either of these methods. With the 2 hour research i did, i found nothing helpful. Thanks in advance.
     
  2. RickyX

    RickyX

    Joined:
    Jan 16, 2013
    Posts:
    280
    Hope i'm allowed to bump
     
  3. RavenOfCode

    RavenOfCode

    Joined:
    Apr 5, 2015
    Posts:
    869
    I would also be interested in knowing if this was possible. A quick search didn't show me anything on this topic accept some network stuff which isn't what I was thinking.
     
  4. djfunkey

    djfunkey

    Joined:
    Jul 16, 2012
    Posts:
    201
    Have you got the Run In Background option checked in the Player Settings?
     
    RavenOfCode likes this.
  5. RavenOfCode

    RavenOfCode

    Joined:
    Apr 5, 2015
    Posts:
    869
    Never new about that thanks! It also seems you can set this via script too, which is very useful.
     
  6. RickyX

    RickyX

    Joined:
    Jan 16, 2013
    Posts:
    280
    That allows me to collect input while i'm focused on some other window ?
     
  7. RickyX

    RickyX

    Joined:
    Jan 16, 2013
    Posts:
    280
    I tried enabling this through code. It doesn't work. "Application.runInBackground = true". Maybe i need an actual build ? I'm running it in unity.
     
  8. RavenOfCode

    RavenOfCode

    Joined:
    Apr 5, 2015
    Posts:
    869
    You probably need to have it in the build, as in the editor it doesn't use Player Settings.
     
  9. RickyX

    RickyX

    Joined:
    Jan 16, 2013
    Posts:
    280
    Hmm... Alright i'll try it and let you know
     
  10. RickyX

    RickyX

    Joined:
    Jan 16, 2013
    Posts:
    280
    Yeah it doesn't work mate.
     
  11. RickyX

    RickyX

    Joined:
    Jan 16, 2013
    Posts:
    280
  12. image28

    image28

    Joined:
    Jul 17, 2013
    Posts:
    457
    Would be sweet to add and android remote for youtube on the computer.....
     
  13. RickyX

    RickyX

    Joined:
    Jan 16, 2013
    Posts:
    280
    I did a deeper research on the youtube API. And guess what, they require .NET 4.5 which unity doesn't support -.- This engine sometimes...
     
  14. RickyX

    RickyX

    Joined:
    Jan 16, 2013
    Posts:
    280
    Bump...