Embedded youtube videos - Simply play a video without audio? - javascript

Question:
How can I control the sound output of this embedded video without overly complicating things?
Possible Solution (Complex)
I've looked into the youtube javascript control API, and, correct me if I'm wrong, but that will force me to incorporate a lot of complication into the setup to accomplish what appears to be a very simple task.
Note:
This is all only tested for webkit at this stage
Setup:
I've created an element that simulates an iphone controlling the channel of a tv by swapping youtube videos like so:
var channel1 = "http://www.youtube.com/embed/dFU6Cy4Hd5A?autoplay=1&rel=0&controls=0&showinfo=0&disablekb=1&iv_load_policy=3&modestbranding=1";
$("#channel-1").click(function(){
$("#tv").attr("src", channel1);
});
where the #channel-1 id is connected to a specific button on the remote, and the tv id is connected to the video player.
It looks like this:
Edit:
If the API is the only to accomplish this, please include a link to a comprehensive tutorial teaching the youtube web API, because I've looked, and found nothing. The only thing I've found so far is the official API page, and that's like trying to learn PHP from the manual.

For loading videos you would use loadVideoById rather than the rather odd snippet you have in your question and to play without audio you simply mute the player using player.mute() (where player is a reference retrieved from the youtube player element itself like described here). And one last thing, don't forget to add enablejsapi=1 to the url of the player as described here.

I would use
event.target.mute();

Related

How can I display pre-roll VAST ads inside HTML5 video player?

So I have a website like YouTube and I want to monetize it. It uses simple HTML5 video player to display dynamic videos. I don't want to integrate any other player because my site is designed for HTML5 players. I have watched couple of videos about this, and neither of the source codes worked (It didn't display the ad itself). I use Adsterra VAST tag, so I don't know if it's their problem or not. I would be very happy if someone can help me with documentations or sample codes. Thank you!
So you would need to use IMA SDK for html5 player:
https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side
In there you can find the necessary code to do it, sorry for the late reply i just found this ticket.

Video autoloading

I'm running a projet of video galery. My problem is I want to the use the YouTube system so that when I click on a video in the list of the galery it appears in the main space and start playing (exactly what happens in YouTube). How can I do this please ?
Thanks
firstly, get the youtube api and a fetch method to get the videos,
now loop through the data returned and present it in the manner you want it. write a play method that will open a selected video on a play canvas, this is how I think you can implement what you want in bare design thinking. I dont know what technologies you're using, in my free time I'll write an example implementation in vue.js or react.js

Brightcove Smart Player API - hide seek controls

I'm upgrading someone else's code from the flash-only player API to the Smart Player API and I'm having a heck of a time trying to find out how to hide the seek controls on either player (both flash and HTML5 versions).
The old code that works is like this:
exp = player.getModule(APIModules.EXPERIENCE);
phead = exp.getElementByID("playhead");
phead.setVisible(false);
The new code that I've been trying to translate that into is like this:
BCL.experience = BCL.player.getModule(BCL.APIModules.EXPERIENCE);
BCL.experience.getElementByID('playhead').setVisible(false);
The error is that there is no method getElementByID and I've confirmed that it doesn't look like a typical DOM object with my console. Does anyone know how I can hide or disable the seek controls on the flash and html5 player?
I'm at a total loss for how this is done and I feel that I've read every page of their API documentation without success.

Controlling playback of multiple Youtube Videos with the Youtube JS api (playing at the same time)

I know that there's a very similar topic for this question, however I'm trying to do something a little different.
all of this is a little new for me... sorry...
Basically I'm trying to play multiple YouTube Videos in one page at the same time (mash up style) using YouTube API and JS
the thing is i want to control each of them separately, while they all playing. i found the code that is close to what i want. the thing is that the videos cannot be played together, once you hit play on a video the other one stops.
how can i control them separately, and still have the other videos playing in the background and not being influenced ?
here's the code i found on another topic
Thanks in advanced,
Maayan
The YouTube code playground has an example for this.

Get YouTube Audio URL on iOS

I am using this javascript code to get a downloadable video URL from the mobile youtube website.
[webView stringByEvaluatingJavaScriptFromString:#"function getURL() {var player = document.getElementById('player'); var video = player.getElementsByTagName('video')[0]; return video.getAttribute('src');} getURL();"];
Output URL: http://o-o.preferred.seabone-mil1.v22.nonxt2.c.youtube.com/videoplayback?el=results&begin=0&yms=5682703339584930992&itag=18&ip=87.0.0.0&app=youtube_mobile&signature=B8CD6B60D2609F5F137B885806F8FAECAA88492F.333D3F19876A77CECB264059A3852BD021401296&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Csource%2Cratebypass%2Ccp&len=254000&ratebypass=yes&source=youtube&expire=1323579819&sver=3&key=yt1&ipbits=8&cp=U0hRSFVSV19GU0NOMV9NTEFJOmV5Qk5wc3hWaUxG&id=b8e73777013e0b7e&ps=blazer
I would like to do the same with just the audio of the video. But i haven't succeeded yet. Can anyone help me?
I solved it! I use the youtube-mp3.org api which works really good. there are some questions about it on SO with good answers!
It's going to be difficult to extract the audio only portions from an existing video from within iOS. I'm sure there are libs out there that can help, but I think it's going to be an involved topic.
Perhaps you can take a look at Display YouTube Videos Without Exiting Your Application. It describes ways to play youtube videos from within your iOS application. Now if you do something similar but set the view to be hidden, you would be able to "listen" to the youtube videos's audio without showing the video itself on the screen.
I don't know what the end-goal is for you're application, but perhaps my suggestion will be food-for-thought.

Categories