简体   繁体   中英

How can I play multiple tracks on soundcloud simultaneously?

I try to play multiple tracks from soundcloud automatically.

I`m using Selenium to open the browser and to visit Soundcloud and then let the track play.(It works one time)

But Soundcloud prevent this, if one track is started the other one that already is playing stops.

Any suggestions ?

This is my code in Python until now:

from selenium import webdriver


driver = webdriver.Chrome(
    r"C:\Users\qwerty\PycharmProjects\venv\Lib\site-packages\selenium\webdriver\chrome\chromedriver.exe")

driver.get("https://soundcloud.com/johnnyvandenberg/bring-her-back-home")
driver.find_element_by_class_name("sc-button-play").click()

for i in range(1,5):

    driver.execute_script('''window.open("https://soundcloud.com/johnnyvandenberg/bring-her-back-home","_blank");''')
    driver.find_element_by_class_name("sc-button-play").click()

There is no way to run to play two songs in different tabs at the same time in one browser session on the Soundcloud platform since Soundcloud is not allowing it.

The only solution that comes to my mind right now is to run two browser sessions with selenium and then play songs on different browser sessions. With that, you can do assertation for specific test cases.

Here is how you can run parallel browser sessions:

public static void main(String[] args) {
    System.setProperty("webdriver.chrome.driver", "E:/Dev/WebDrivers/chromedriver.exe");
    WebDriver driver1 = new ChromeDriver();
    WebDriver driver2 = new ChromeDriver();
    driver1.get("https://someurl.com/1");
    driver2.get("https://someurl.com/2");
   //Do something
    driver1.quit();
    driver2.quit();
}

Let me know if this is helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM