?
Solved

Playing video at certain time

Posted on 2003-03-05
9
Medium Priority
?
219 Views
Last Modified: 2013-11-13
Hey experts!

I'm looking to make a install that will install a video and set it to play at a certain time.  I'm not sure if I should either write a program to play a video, or somehow set the scheduler for windows to play it.  In either case, I'm not sure where to begin.  So my question is: Do you experts have any ideas on how to do this?  thanks!

0
Comment
Question by:Discomonkey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 19

Expert Comment

by:mrwad99
ID: 8189724
It depends what you mean by 'install' the video.  I think you mean just copy it to the hard drive, since you do not normaly use a program like installShield to accomplish this.

You could do this using C I am fairly sure since it is just parameter passing.  As for the windows scheduler then that again depends on your definition of install.

Let us know the exact purposes of what you need.
0
 
LVL 1

Author Comment

by:Discomonkey
ID: 8191290
Here's exactly what I want to do:
I have a movie clip (movie.avi or movie.mpg)

I want to make a .exe that when executed will:

1) copy movie.avi to a directory on the hard drive
2) set movie.avi to play at a particular time (say 11:00 pm)

now I know you can set task scheduler (win 98 has it, don't know about other os) to add a task that would accomplish this.  How can I access task scheduler via my program (my thoughts are that it is impossible)

so the only other option would be to just rely on the program.  I have no idea how to accomplish this.
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 8193778
It is not easy or even doable if the movie has to be *packaged* with the .exe, and I think that is what you want: am I correct ?  That will inevitably result in one hell of a big executable file.

I cannot see why you would want to do this anyway; if the executable is to be run on machine X, then this implies the movie must reside on machine X; hence it would be infinitely easier to copy the movie *beforehand* to machine X and the rely on your program purely to execute it.  

Of course you could write a batch file that would copy it from, say a CD, without anyone knowing and then set this to be run at a certain time via the your program; the program could then sit idle (and invisible) in memory waiting to run the movie itself.

You also need to be more specific about the program intended to play the movie (eg realplayer, windows media) although if you use a batch file this is not a problem, but the problem with batch files is the dos window the appears.

This is certainly an interesting problem, and it would be interesting to hear what the purpose of it is :D

-- A prank on someone maybe ?


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Discomonkey
ID: 8199591
well its actually a small file like maybe 5 megs or so, but the purpose of the program is a prank, it's such an awesome idea, I guess I'll write it, hopefully no one comes by and steals this idea because its too good.  Basically me and a friend want to make a virus like program (not harmful, just when you run it it'll pop something up to distract the person) and what it REALLY does is install the video from the movie The Ring where its that random jibberish that's all freaky and have it play in the middle of hte night on a friends's computer, and splice in their name, and since we know exactly when it goes off, we're gonna call that person exactly when the movie ends.  MAN I'm freaked out just thinkin about it.
If you've never seen the movie, its really damn good, but pretty freaky at parts (since the whole movie is about a movie that kills people 7 days after they see it)

So basically its an elaborate prank, Windows media player would be the prefered player to use, and the computer is left on over night so there's no problems there.  any ideas?  the program that sits in memory is a good idea (hey that's virus)  not sure how to go about any of this htough
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 8201391
Yeah this is more than doable.  I would do it in C.  

It is even easier if you have VC++ as it provides an easy way to make an app window invisible but still doing something in the background if you get me.

As regards the time then you could hard code it into the program or pass it via the command line.  Of course this makes it more difficult as you need to parse the time to make sure it is in the correct format, but it is all doable.

As regards distracting the user with something else; this is not really necessary as the program when run will appear to be a placebo anyway.  Unless they run some sort of process viewer they will not know it is there.

So basically since you cannot easily package the video into the mpeg, you need two files:

1. The movie (never)
2. The exe that, when run, will first copy the movie to a specified directory and then sit dormant waiting for the time to come when the movie is to be played.

Sound ok ?

I will have a crack at this later my time (currently 9:20GMT).
0
 
LVL 19

Accepted Solution

by:
mrwad99 earned 500 total points
ID: 8245789
#include <stdio.h>
#include <time.h>
#include <Windows.h>
#include <process.h>

#define DUMMY_STRING  __TEXT("I am already running")

int main(int argc, char** argv)
{
          HANDLE hMapping;
         
          // Test to ensure that we are not running more than one copy of the program.
          // Place a string in a certain memory area, and later test for its existence
          hMapping = CreateFileMapping( (HANDLE)0XFFFFFFFF, NULL, PAGE_READWRITE, 0, 256, DUMMY_STRING);
          if (hMapping != NULL) {
               if (GetLastError() == ERROR_ALREADY_EXISTS) {
                    exit(1);     // String already exists; no need for more than one copy running hence exit
               } else {          // This is the only program instance running
               }
          } else {
               exit(1);          // Other problem
          }

          system("@echo Please Wait....");
          system("@echo off");
          system("cp <filename> <dirname>");     // eg system("cp myMovie.avi C:\");  Copy the movie to play to the hard drive of your buddy's machine

          // get current time.
          time_t currentTime;
          time(&currentTime);
         
          struct tm tm_current;
          // localtime returns a pointer (struct tm*) so we want the dereferenced struct tm !
          tm_current = *(localtime(&currentTime));

          struct tm runTime;    
          runTime = *(localtime(&currentTime));

          // With the values as given, the task would execute at 14:33 on 1st April 2003
          runTime.tm_mday = 1;          // Day of month
          runTime.tm_hour = 14;     // Hour (24hr format)
          runTime.tm_min = 33;     // Minutes past hour
          runTime.tm_sec = 0;          // Seconds past minute
          time_t timeToRun = mktime(&runTime);

          double diff = difftime(timeToRun, currentTime);
          printf("Sleeping for %.2lf ", diff);
          Sleep(diff*1000);
          system("@echo off");
          system(" <full path to file> ");     // eg system("C:\myMovie.avi");  
     return 0;
}

You need to bind and link this with the following paramters (in MSCV++) :

Project->Settings->Link Tab ->Project Options box

/entry:"mainCRTStartup"

/subsystem:windows (this replaces /subsystem:console)

If you have not got MSVC++, or have other probs then get back to me and I will figure out another way to get the app to run invisibly.

Test this locally before you let it loose on your friend.
15:05GMT
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 8246057
whoops the command to copy the file in the system() call should be

'copy'

not

'cp'

Damn Unix commands still stuck in my head from University...
0
 
LVL 1

Author Comment

by:Discomonkey
ID: 8247295
AWESOME.  I haven't tested it yet, tonight i will, school has turned up the heat on me.  This looks good though I'm gonna play with it.  I'll get back to you asap.
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 9223083
Yo,

Did you ever try this code and did it work ?
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Introduction to Processes
Starting up a Project
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question