简体   繁体   English

如何在 soundcloud 上同时播放多首曲目?

[英]How can I play multiple tracks on soundcloud simultaneously?

I try to play multiple tracks from soundcloud automatically.我尝试从 soundcloud 自动播放多首曲目。

I`m using Selenium to open the browser and to visit Soundcloud and then let the track play.(It works one time)我正在使用 Selenium 打开浏览器并访问 Soundcloud,然后让曲目播放。(它工作一次)

But Soundcloud prevent this, if one track is started the other one that already is playing stops.但是 Soundcloud 会阻止这种情况,如果一首曲目开始,另一首已经在播放的曲目会停止。

Any suggestions ?有什么建议 ?

This is my code in Python until now:到目前为止,这是我在 Python 中的代码:

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.由于 Soundcloud 不允许,因此无法在 Soundcloud 平台上的一个浏览器会话中同时在不同选项卡中播放两首歌曲。

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.我现在想到的唯一解决方案是使用 selenium 运行两个浏览器会话,然后在不同的浏览器会话上播放歌曲。 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.让我知道这是否有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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