Video Code: Mute and Autoplay - youtube

How do i mute a Youtube Video with in my iframe block without using JS? Is it a way which can be leveraged?
-I do not want to consume Youtube API. Is there any way that videos can be muted with just API parameters?

I think it is not possible if you are only using the YouTube API parameter.
If you check the supported parameter of the IFrame Player API, you will not see any parameter here that can mute the video.
So the only way to mute video is the player.mute():Void.
Here is the jsfiddle for the sample code.
For more information, check this related threads:
How do I automatically play a Youtube video (IFrame API) muted?
How to Embed a YouTube Video with Sound Muted

use &mute=1
example : <iframe src="https://www.youtube.com/embed/UNIQUE-VIDEO-ID?&autoplay=1 &mute=1&rel=0&controls=0"></iframe>

Related

AVPlayer can't play Vevo Youtube video

I'm developing my youtube app on iOS and using AVPlayer to play video. But I don't know why my player can't play the Vevo video. Any idea for my problem? Thanks a lot.
You should use the iOS Youtube Helper library for playing youtube videos.
https://developers.google.com/youtube/v3/guides/ios_youtube_helper
I don't know if you can use the AVPlayer. I've seen some examples using MPMoviePlayerController on CocoaControls, like this one: https://www.cocoacontrols.com/controls/hcyoutubeparser or this one: https://www.cocoacontrols.com/controls/xcdyoutubevideoplayerviewcontroller
But I don't think using youtube's url directly in your player fits the ToS of the platform. So I will recommend you tu use the Youtube Helper Library if you are planning to publish your app.

Getting the url of the youtube video

Is there a way to get the youtube video without the youtube player? The youtube player sdk - https://developers.google.com/youtube/android/player/
uses the existing youtube player, I need the url that it uses to play the video, so that I can use my custom video player. More of using youtube as a hosting service, where I can pull the videos from the server from which youtube player pulls it. Don't know if it is possible or legal.

Is it possible to play a video file (eg .avi) using youtube player?

Can I use youtube player to play my own videos?
Say I have a localhost running and I have some video files stored and I have a html code that has Youtube player's code and I can specify something like
<src="localhost/videos/cat.avi">
And it plays cat.avi on my browser just like youtube player.
No - you can't play local videos using youtube player.
If you want to play them you'll need to upload them to youtube.com.
Check out Play a local video with YouTube Player

Live streaming using YouTube on iOS

I've successfully streamed normal YouTube videos on iOS using the iOS YouTube helper, but live stream does not seem to work.
I am not sure whether live streaming is even supported, but I could not find it in their docs.
Any idea how to make it work on iOS (without breaching ToS)?
The playback of YouTube Live Events is supported by the YTPlayerView iOS helper classes. The player will treat the Live Event video just like a regular YouTube video (as the iFrame player should), and your video should play back no problem with the "Live Broadcast" message replacing the scrubber of the player like so:
The only difference I have noticed is that the video will return an "auto" quality value. I have submitted a patch to handle this case which has been merged in to the official repo here.

How to play just the audio of YouTube Video?

In my app I have played a youtube video by embedding it, but how can i only play the audio of the video? I tried using AVAudioPlayer and use the videos url as the file path but it didnt work, any help?
No it is not possible, only one workaround is just to use a hidden UIWebView and play in that.
Youtube forbids playing audio only! here is the message from youtube
Your API Client will not, and You will not encourage or create functionality for Your users or other third parties to: "separate, isolate, or modify the audio or video components of any YouTube audiovisual content made available through the YouTube API"
-Kuan Yong, YouTube API Team

Resources