如何使用 Youtube API v3 将 Youtube 视频静音? [英] How to mute a Youtube Video by using Youtube API v3?

查看:60
本文介绍了如何使用 Youtube API v3 将 Youtube 视频静音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Youtube Api V3 在我的 android 应用中播放视频.但是,我将文本转语音与视频一起使用,因此我希望将视频静音,以便可以听到其他音频.

I'm using Youtube Api V3 for playing a video in my android App. However, I'm using Text to speech along with the video, so I would like to mute the video so that the other audio is audible.

我搜索了文档和互联网,但找到了仅适用于 javascript 的解决方案.任何帮助,将不胜感激.谢谢.

I've searched the documentation and internet, but found solution only for javascript. Any help would be appreciated. Thanks.

推荐答案

我仍然没有找到使用 Api 将 Youtube 视频静音的确切解决方案.

I Still haven't found the exact solution to mute the Youtube Video using the Api.

相反,这是我已经达到的变通解决方案,就我而言.希望对其他人有所帮助.

Instead, Here's the work-around solution I've reached, in my case. Hope it might be helpful for someone else.

我已将 TTS 流设置为 STREAM_ALARM.(请参阅 this 问题)

I've set the TTS Stream to STREAM_ALARM.(refer this question)

HashMap<String, String> params = new HashMap<>();
params.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_ALARM));

textToSpeech.speak("Hello World", TextToSpeech.QUEUE_FLUSH, params);

现在我将 SREAM_MUSIC 音量静音,我得到了我想要的结果.任何有更好想法的人都非常欢迎.

Now I Mute the SREAM_MUSIC Volume and I got the result I wanted. Anyone got better Ideas are more than welcome.

setVolumeControlStream(AudioManager.STREAM_MUSIC);
AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
if (am != null) {
    am.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
}

这篇关于如何使用 Youtube API v3 将 Youtube 视频静音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆