有没有办法在手机入睡时播放抽搐音频而不会有用户互动的方法?

发布于 2025-01-24 21:11:20 字数 1599 浏览 5 评论 0原文

- 首先,我知道这是侵入性的,我正在尝试发出警报 -

我正在寻找一个设置一个警报的Android应用程序,该应用程序将播放Twitch Audio而无需用户互动。对于警报部件,我使用 armardmanager 但是,当警报触发时,我正在努力在锁定的电话屏幕上进行Twitch进行自动播放。

我对如何执行此操作的两个主要想法(在Android上)是:

IDEA#1:嵌入Twitch Player在网页中,当警报触发时在锁屏上显示: twitch嵌入 全屏意图 但是,玩家静音了,我无法找到解决这个问题的方法(似乎没有得到支持) [类似的问题#1] https://discuss.dev.twitch.tv/t/i------------------------mute-unmute-unmute-video-clips-clips-in-twitch-preview/31585 [类似的问题2] https ///discuss.dev.twitch.tv/t/how-to-unmute-clips-on-load/26054/2

创意#2:只需在锁定屏幕时使用Twitch应用程序启动流。目前,我是如何启动YouTube音频流的方式,并且在手机被锁定在后台时会启动。我知道在Twitch Android应用程序中有一些功能,因为能够通过在流中更改设置而在没有应用程序打开的情况下播放流。但是,目前,如果我尝试在屏幕锁定时使用Twitch启动流,据我所知,在用户打开手机之前,视频不会加载。

是的,有没有一种方法可以在手机入睡时在没有用户互动的情况下播放抽搐音频?

谢谢

--First off I am aware this is invasive, I'm trying to make an alarm--

I'm looking to create an Android app that sets an alarm which will play Twitch audio without any interaction from the user. For the alarm part I'm using AlarmManager
However I am struggling to get twitch to autoplay on the locked phone screen when the alarm triggers.

My two leading ideas for how to do this (on Android) are:

Idea#1: Embed twitch player in a webpage that is shown on the lockscreen when the alarm triggers:
Twitch Embed
Fullscreen intent
However the player is muted and I haven't been able to find a way around this (and doesn't seem like it is supported)
[Similar issue #1]https://discuss.dev.twitch.tv/t/i-am-unable-to-mute-unmute-video-clips-in-twitch-preview/31585
[Similar issue #2]https://discuss.dev.twitch.tv/t/how-to-unmute-clips-on-load/26054/2

Idea #2: Just launch a stream using the Twitch app while the screen is locked. This is currently how I am starting a stream for Youtube audio and it launches while the phone is locked in the background fine. I know there is some functionality for this in the Twitch android app due to being able to play streams without the app open by changing settings in a stream. However currently if I try to launch a stream using Twitch while the screen is locked, as far as I can tell the video doesn't load until the user opens the phone.

So yeah, Is there a way to play Twitch audio without interaction from the user when the phone is asleep?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

把时间冻结 2025-01-31 21:11:20
  • 编辑添加的代码作为文本,

我设法使用解决方案#1(使用Android WebView的全屏意图)解决此问题。但是,我没有嵌入本机Twitch播放器,而是使用Android WebView直接打开Twitch网站。使视频未静音的重要部分是设置 flag to false。代码在下面
``

val rO  =  intent.getSerializableExtra("RingtoneOption") as RingtoneOption
        val url = rO.liveContentURL
        setContentView(R.layout.activity_full_screen_alarm)
        turnScreenOnAndKeyguardOff()
        var myWebView = findViewById<View>(R.id.webview) as WebView
        val webSettings = myWebView.settings
        webSettings.javaScriptEnabled = true
        webSettings.mediaPlaybackRequiresUserGesture = false;
        myWebView.webViewClient = WebViewClient()
        myWebView.webChromeClient = WebChromeClient()
        myWebView.loadUrl(url)

``

  • Edit added code as text

I managed to solve this using solution #1 (Fullscreen intent with android webview). However instead of embeding the native twitch player, I used android webview to open the twitch website directly. The important part to make the videos not muted was to set the mediaPlaybackRequiresUserGesture flag to false. Code is below
`

val rO  =  intent.getSerializableExtra("RingtoneOption") as RingtoneOption
        val url = rO.liveContentURL
        setContentView(R.layout.activity_full_screen_alarm)
        turnScreenOnAndKeyguardOff()
        var myWebView = findViewById<View>(R.id.webview) as WebView
        val webSettings = myWebView.settings
        webSettings.javaScriptEnabled = true
        webSettings.mediaPlaybackRequiresUserGesture = false;
        myWebView.webViewClient = WebViewClient()
        myWebView.webChromeClient = WebChromeClient()
        myWebView.loadUrl(url)

`

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文