I want to disable live YouTube songs being streamed from DisTube. How can I do this?
I thought there was something like a "disableLive" option in DisTube's options (inside of new Distube()).
Related
So I am creating a form where people can input all sorts of data describing a recipe. One of those data types is a youtube video URL. I want to take the data the user puts into the URL box and generate an iframe with the video so that can preview and make sure it's the right one. This is the code I am using:
function makeVideoPreview(aTable, aTextBox)
{
var aVideo = document.createElement("iframe");
aVideo.setAttribute("width", "560");
aVideo.setAttribute("height", "315");
var theURL = aTextBox.value;
var idIndex = theURL.indexOf("v=") + 2;
var vidID = theURL.slice(idIndex, theURL.length );;
var embedLink = "https://www.youtube.com/embed/"+ vidID;
aVideo.setAttribute("src", embedLink);
aVideo.setAttribute('allowfullscreen', 'true');
aVideo.setAttribute('frameborder', "0");
aTable.appendChild(aVideo);
}
If I use the debugger and step through the code, the iframe gets placed in the right place, begins to load, and then I get a 405 method not allowed error and it reloads the entire page.
If I copy the generated iframe from the debugger and paste it into the html source, it works fine. What in the world is going on?
I'm not a web guy. I mostly do native iOS development, but I am making this as a resource so that the company I am making the app for can add recipe content. I'm sure it is something I just don't understand about the platform.
thanks.
I just found an answer! I think. Apparently every element “button” defaults to submit. I assumed that submit was a submit and button was an action less element unless given a specific onclick or similar function. Apparently one must set the button type to be button or it defaults to submit.
I am new to Crossrider and I want be able to trigger events based on the user's interaction with the page.
For example, have a sound played when user hovers over an html input element:
extension.js
appAPI.ready(function() {
//the link to Alarm01 is valid
var Alarm01 = new Audio('http://localhost/playing-with-sound/jquery%20mobile%20forms/sounds/Alarm01.wav')
$('input').mouseenter(function(){
Alarm01.play();
})
});
The code above does not work. Does anyone know what is the proper way to do this?
I've also tried to put it in background.js - that does not work either. I am using Chrome as my browser.
The idea is to have the user select an event in a popup (for example, play Alarm01 on hover over an input element) and then have it immediately applied to the current web page. So that the next time the user hovers over an input element Alarm01 is played.
What is the proper way to access HTML page elements in a Crossrider extension?
Thank you!
EDIT: Follow up question
Is it possible to trigger events on user's interaction with JQuery Mobile elements? For example an element of data-role="slider":
appAPI.ready(function($) {
//the link to Alarm01 is valid
var Alarm01 = new Audio('http://localhost/playing-with-sound/jquery%20mobile%20forms/sounds/Alarm01.wav');
// Add audio to page
document.body.appendChild(Alarm01);
$('[data-role=slider]').on('change', function(){
Alarm01.play();
})
});
Thank you!!!!
EDIT:
If I include JQuery Mobile in extension.js I get double of every element on a the mobile website. So instead of getting one element of data-role="slider", I get two...
I get this:
as opposed to this:
You're almost there. As your code stands you created the audio object in the extension scope. However, to play the audio you must add it to the page scope (HTML DOM). Hence, simply add it to the body of the page and it works, something like:
appAPI.ready(function($) {
//the link to Alarm01 is valid
var Alarm01 = new Audio('http://localhost/playing-with-sound/jquery%20mobile%20forms/sounds/Alarm01.wav');
// Add audio to page
document.body.appendChild(Alarm01);
$('input').mouseenter(function(){
Alarm01.play();
})
});
[Disclosure: I am a Crossrider employee]
I've got a nice image on my website that has a play button on it. What I'd like to do is replace that image with a video (longtail video player) when a user clicks on the image. The image can be wrapped in a link or whatever.
Usually, people just have this sort of thing pop up a modal window but I was hoping for a slicker solution that would happen in the same space that the image was inside.
Is there some way to accomplish this using jQuery?
There are a number of ways to accomplish this, but there often quirks in the different browsers that you may have to work through.
One way is to embed the player on the page within a view that is hidden with a style (display: none). The player may have to have the wmode property in the flash embed set to "transparent" to do this. You can then hide the image and show the embed in the same location with jquery's hide and show methods:
$('#img-el').click( function () {
$(this).hide();
$('#player-embed-div').show();
});
Another way to do this is to use SWFObject (http://code.google.com/p/swfobject/) to embed the video dynamically on clicking the image:
$('#img-el').click( function () {
var so = new SWFObject("movie.swf", "mymovie", "400", "200", "8", "#336699");
so.write("img-el");
});
You may need to tweak the code above to get it to work and you may have trouble across browsers since the handling of Flash embedding is different across them.
You can replace the image with a <div> when clicked, and then setup the video player like this: http://jsfiddle.net/hxaZx/.
$("img").click(function() {
var $div = $("<div>").text("this is the div to use for video");
$(this).replaceWith($div);
// jwplayer($div.get(0)).setup({ ... });
});
If you don't mind the video being include onload, then I would embed both the image and the video and hide the video on startup. then, bind a clickhandler to the image that will hide the image and show the video.
var $image = $('#myimage');
var $video = $('#myvideo'); // hide #myvideo with css
$(function(){
$image.on('click', function(){
$image.hide();
$video.show();
});
});
A little while ago I was looking for a way to make the jpeg thumbnails of YouTube videos into a link to enlarge and open a player, in a similare way to the way Facebook shows videos in newsfeed.
The solution I used (which is definitely not the oly way, but worked for me) is similar to the answer from Pimvdb.
I simply had another page which had the YouTube player embed code on it (dynamically populated with the correct video by passing a variable to the URL) and then loaded that in with jquery.load
$('#imageElement').live("click", function () {
$('#currentlyHiddenVideoDiv').load('videoPage.asp?vidid=idOfVideoToPlay').show()
}
You'd have to have your own method of passing the required video id/link into the player page and of course, I realise this is not with the YouTube player, but an embedded player in a separate file loaded into the required page in this method should work much the same.
This means that the video content is only loaded in when required, to the that point you just load your player button.
I have a YouTube video embedded in my page. It is hidden (display:none). You need to click one of the video link buttons to display the video and play it. The links are defined like this:
Video 1
Video 2
xxxxxxxxx represent YouTube video IDs.
Here's the play function:
function play(id)
{
ytplayer.style.display = 'block';
ytplayer.loadVideoById( id, 0, 'hd1080' );
}
It's fundamentally pretty simple! But here's the problem. since the video player is hidden, the flash object is not activated. So when I click a video link, the line ytplayer.style.display = 'block'; displays the video player, but it takes about about half a second for flash to load. During this time it cannot accept any method calls, such as the next line ytplayer.loadVideoById( id, 0, 'hd1080' );. Essentially, I have to click the link twice, once to load up the flash video player, the second time to actually load the video into the player.
It looks like once you enable the video, you need to setup and wait for a callback:
onYouTubePlayerReady(playerid)
(Taken from this page: http://code.google.com/apis/youtube/js_api_reference.html)
In that function you could then do any calls that require the player to be loaded:
ytplayer.loadVideoById( id, 0, 'hd1080' );
If you aren't using the chromeless player, you may need to instead listen for the onStateChange and onError events.
i am trying to design a website in flash , and would like to know how to design a loading flash movie , something like a circle rotating till the website loads . I might not be able to explain properly , but its like when you install a software , the installation bar that you get , how to get that on a website using flash or java script?
Alright so you would need a preloader ( I am assuming you are using ActionScript 3.0). This will be a small SWF file that loads your main Flash file. Smallest implementations (like the following) are around 1-2 KB
So in your Flash IDE (Flash CS3,CS4,CS5) you want to create a new fla, lets call it preloader.fla. In this file you will want to have two layers. Name the first layer as actions and the second layer as content.
In your content layer just place a dynamic text field on the stage. Name it txt/percent or whatever you feel like... I am using txt.
In your actions layer you want select the first keyframe and open the actions (code) panel
Then you want to use the loader class to load the external file (your main flash movie) as follows
var ldr:Loader = new Loader();
To handle animations and so forth you will want to listen to the ProgressEvent. You will do this by listening to loading information within the contentLoaderInfo as follows
ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, update);
So as you main file's data gets loaded this event is fired . 'update' will be the function we will call to handle the progress in data.
A next event to listen to will be for when the loading of the main file has completed and we want to display it.
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, display);
Then we have a function display which handles the completion and displays the main file.
The last thing will be to load the content ,e.g. main.swf.
ldr.load(new URLRequest("main.swf"));
Here we will have text field just show a loading of the bytes from 0 - 100%;
function update(e:ProgressEvent):void {
var percent:Number = e.bytesLoaded / e.bytesTotal;
txt.text = Math.ceil(percent*100).toString();
}
Below is the function that removes the textfield (txt) and adds the main.swf to the display list.
function display(e:Event):void {
removeChildAt(0);
txt=null;
addChild(ldr);
}
Now you can change the txt in the content layer to something different if you want for example as you said a circle rotating...depends on how you want it displayed so I have placed some links below you can follow. Cheers.
Example 1 : [ Demo ] [ Source Code and Files ]
Example 2 : [ Demo ] [ Source Code and Files ]
If you just want a circle rotating until the website loads, please don't use flash.
You should just have an animated gif that waits for the page to load then disappears and shows the content when everything is loaded.
Animated gifs are fully supported accross browsers and will be about 1/100th of the size of the flash animation.