How to start YouTube videos automatically

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
snelson2678
Posts: 8
Joined: Sun Dec 16, 2007 10:18 pm

How to start YouTube videos automatically

Post by snelson2678 » Wed Dec 19, 2007 2:13 pm

I created a simple loop to visit a list of pages from a .csv file and play the youtube video on the page. It works great up until this line:

TAG POS=1 TYPE=EMBED ATTR=HREF:http://www.youtube.com/*/*/
WAIT SECONDS=60

Here is the error message I get:

Error# 801 in line:14 , TAG not found

TYPE=EMBED

ATTR=HREF:http://www.youtube.com/*/*/

(I also tried single wildcard)

Any ideas why this wild card does not work??
snelson2678
Posts: 8
Joined: Sun Dec 16, 2007 10:18 pm

Post by snelson2678 » Mon Dec 24, 2007 10:41 pm

I downloaded the trial version and tried to run this:

VERSION BUILD=3700331
TAB T=1
TAB CLOSEALLOTHERS
CMDLINE !DATASOURCE F:\DomainsForvideo.csv
'Number of columns in the CSV file. This must be accurate!
SET !DATASOURCE_COLUMNS 1
'Start at line 2 to skip the header in the file
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=http://{{!COL1}}
WAIT SECONDS=10
TAG POS=1 TYPE=EMBED ATTR=HREF:http://www.youtube.com/*
WAIT SECONDS=10

Here is the error:

Error in Line 9:

TYPE=EMBED ATTR=HREF:http://www.youtube.com/*

all I want to do is go t a specific web page and play any you tube video that loads.

Thanks
User avatar
Tech Support
Posts: 4947
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Wed Dec 26, 2007 2:42 pm

In my tests, YouTube videos play automatically as soon as the page loads?

But if you want to start/stop playing the videos via the macro please switch to DirectScreen click mode before recording the click on the Player (controls). Youtube and other video download sites use Flash Players.
snelson2678
Posts: 8
Joined: Sun Dec 16, 2007 10:18 pm

Differnt location

Post by snelson2678 » Thu Dec 27, 2007 12:31 am

What do you do if the video is loaded in a different location on the page each time?
User avatar
Tech Support
Posts: 4947
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Sat Dec 29, 2007 12:58 am

There are two useful options:

1. Use ImageClick to find the image of the Play button and click it.

2. Use the !TAGX and !TAGY values to find the coordinates of the video player. Then add a certain value to x and y to find the part of the player that you want to click (the Play/Stop button in our case). This approach works also with elements below the fold, because it automatically scrolls them up in the visible part.

Example:

Code: Select all

VERSION BUILD=6101220     
TAB T=1     
TAB CLOSEALLOTHERS     
URL GOTO=http://www.youtube.com/watch?v=JEUrQEj6Sd4     
'Get the position of the video (in this case we use the title)
TAG POS=1 TYPE=SPAN ATTR=TXT:Microsoft<SP>Silverlight   
SET !VAR1 {{!TAGX}}
SET !VAR2 {{!TAGY}} 
ADD !VAR1 -80
ADD !VAR2 400
WAIT SECONDS=3
'Stop video
DS CMD=MOVETO X={{!VAR1}} Y={{!VAR2}}
DS CMD=CLICK X={{!VAR1}} Y={{!VAR2}}
WAIT SECONDS=3
'Start again
DS CMD=MOVETO X={{!VAR1}} Y={{!VAR2}}
DS CMD=CLICK X={{!VAR1}} Y={{!VAR2}}
In this example we stop the video first, because YouTube starts playing the video automatically when the page loads.

Methods #1 or #2 work for all video sites.
eval1
Posts: 3
Joined: Wed Jan 23, 2008 4:11 pm

Post by eval1 » Wed Jan 23, 2008 4:18 pm

Thanks for the example... however, I'm having problems running this. I've tried a few flash examples, and when I play the test back, I can see the small red icon blink over the play/pause button, but the button isn't pressed. I tried in IE and the iMacro browser, and neither would work with this exact example.

I took this code, created a macro, pasted this in. Then I ran it. The youtube video appeared, I could see the time count down, then for the "pause" button, I just see this little red blink occur over the button. Then it's gone, but the button wasn't pressed, video keeps playing.

Any ideas? I've got 6.11 - the demo (we're evaluating some testing software for flash) and I've got flash 9 running...

Thanks,
Chris
User avatar
Tech Support
Posts: 4947
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Wed Jan 23, 2008 8:15 pm

Eval1, do the other demo macros with DirectScreen work on your PC (especially Demo-Draw and Demo-Flash)?
eval1
Posts: 3
Joined: Wed Jan 23, 2008 4:11 pm

Post by eval1 » Thu Jan 24, 2008 12:56 pm

Yes - both those demos work. But, if I try any other direct draw, it doesn't appear to work.

I kept trying other things, rewrote the flash macro, etc. Sometimes it will push a button, but the next click won't work. And it's not consistent. The next play it won't press any. Most of the time, I get none pressed.

Thanks
eval1
Posts: 3
Joined: Wed Jan 23, 2008 4:11 pm

Post by eval1 » Thu Jan 24, 2008 4:40 pm

Hmm - what is interesting is. I started the app up and Demo_Flash and it worked. I then tried running the YouTube flash test here in this post. It worked! Hmm. Then I tried one of the tests I built using flash . It pressed the first button, then wouldn't press any others. I went back and ran the this YouTube flash test and it didn't work this time. There's nothing complex about the testcase. I'll keep playing around, I'm not sure why it "breaks" it after it is run...
provoquestosito
Posts: 75
Joined: Sat Jan 30, 2010 12:43 am

Re:

Post by provoquestosito » Thu Feb 09, 2012 10:44 pm

This do not work

Do not stop and do not play video on youtube

I tried and do not work.
Tech Support wrote: Example:

Code: Select all

VERSION BUILD=6101220     
TAB T=1     
TAB CLOSEALLOTHERS     
URL GOTO=http://www.youtube.com/watch?v=JEUrQEj6Sd4     
'Get the position of the video (in this case we use the title)
TAG POS=1 TYPE=SPAN ATTR=TXT:Microsoft<SP>Silverlight   
SET !VAR1 {{!TAGX}}
SET !VAR2 {{!TAGY}} 
ADD !VAR1 -80
ADD !VAR2 400
WAIT SECONDS=3
'Stop video
DS CMD=MOVETO X={{!VAR1}} Y={{!VAR2}}
DS CMD=CLICK X={{!VAR1}} Y={{!VAR2}}
WAIT SECONDS=3
'Start again
DS CMD=MOVETO X={{!VAR1}} Y={{!VAR2}}
DS CMD=CLICK X={{!VAR1}} Y={{!VAR2}}
In this example we stop the video first, because YouTube starts playing the video automatically when the page loads.
Post Reply