ask to exit help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • GoOgLe
    Forum Member
    • Mar 2007
    • 452

    ask to exit help

    how can make it ask when application exit if media player plugin is playing, and not ask if it is not playing ???
  • ShadowUK
    No longer a forum member
    • Oct 2007
    • 1322

    #2
    Code:
    if (MediaPlayer.GetState("Plugin1") == 2) then
    	if (Dialog.Message("My Application", "Are you sure you would like to quit?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1) == 6) then
    		Application.Exit();
    	end
    else
    	Application.Exit();
    end
    In any action you want, Change the title and Plugin1 to whatever your project object is.

    Also, next time include a project so we don't have to create a new one.

    Comment

    • GoOgLe
      Forum Member
      • Mar 2007
      • 452

      #3
      thanks ShadowUK but either i choose yes or no still close the app ???

      Comment

      • ShadowUK
        No longer a forum member
        • Oct 2007
        • 1322

        #4
        Change it then.

        Comment

        • GoOgLe
          Forum Member
          • Mar 2007
          • 452

          #5
          i tried that but it didnt work either !!!

          Code:
          result = MediaPlayer.GetState("Plugin2")
          if ( result == 2) then
          	ask = Dialog.Message("My Application", "Are you sure you would like to quit?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1)
          	if (ask == "CANCEL")  then else
          		Application.Exit();
          	end
          else
          	Application.Exit();
          end

          Comment

          • GoOgLe
            Forum Member
            • Mar 2007
            • 452

            #6
            what am i doing wrong ?

            Comment

            • holtgrewe
              Indigo Rose Customer
              • Jul 2002
              • 779

              #7
              result = MediaPlayer.GetState("Plugin2")
              if ( result == 2) then
              ask = Dialog.Message("My Application", "Are you sure you would like to quit?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1)
              if (ask == "CANCEL") then else
              Application.Exit();
              end
              else
              Application.Exit();
              end
              Try this:
              "CANCEL" will never be returned using type MB_YESNO.
              It's not tested, but should work for you.

              Code:
              result = MediaPlayer.GetState("Plugin2")
              if ( result == 2) then
              	ask = Dialog.Message("My Application", "Are you sure you would like to quit?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1)
              	if (ask == IDYES)  then 
               		Application.Exit();
              	end
              else
              	Application.Exit();
              end
              or use ShadowUK 's code where he tests for 6 (IDYES)...
              Last edited by holtgrewe; 04-16-2008, 08:19 AM. Reason: agree with ShadowUK

              Comment

              • ShadowUK
                No longer a forum member
                • Oct 2007
                • 1322

                #8
                Code:
                if (MediaPlayer.GetState("Plugin1") == 2) then
                	if (Dialog.Message("My Application", "Are you sure you would like to quit?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1) == 6) then
                		Application.Exit();
                	else
                             Application.ExitScript();
                        end
                else
                	Application.Exit();
                end
                Next time, read the manual.

                Comment

                • RizlaUK
                  Indigo Rose Customer
                  • May 2006
                  • 5552

                  #9
                  Next time, read the manual.
                  lol

                  there is a hidden global function "QueryAllowProjectClose()", use it !!

                  QueryAllowProjectClose ( )

                  Called whenever the project is 'told' to close. Using this function, you can control how the user can close the application, such as confirming with the user that they intended to close the application.
                  Code:
                  function QueryAllowProjectClose()
                  	if (MediaPlayer.GetState("Plugin1") == 2) then
                  		if (Dialog.Message("My Application", "Are you sure you would like to quit?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1) == 6) then
                  			return true
                  		else
                  	             return false
                  	        end
                  	else
                  		return true
                  	end
                  end
                  just put the function in globals, no need to call it, it is done automaticly
                  Last edited by RizlaUK; 04-16-2008, 08:44 AM.
                  Embrace change in your life, you never know, it could all work out for the best

                  Comment

                  • ShadowUK
                    No longer a forum member
                    • Oct 2007
                    • 1322

                    #10
                    Originally posted by RizlaUK View Post
                    lol

                    there is a hidden global function "QueryAllowProjectClose()", use it !!



                    Code:
                    function QueryAllowProjectClose()
                    	if (MediaPlayer.GetState("Plugin1") == 2) then
                    		if (Dialog.Message("My Application", "Are you sure you would like to quit?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1) == 6) then
                    			return true
                    		else
                    	             return false
                    	        end
                    	else
                    		return true
                    	end
                    end
                    just put the function in globals, no need to call it, it is done automaticly
                    PM me all of them please :P

                    Comment

                    • GoOgLe
                      Forum Member
                      • Mar 2007
                      • 452

                      #11
                      asks to close or not anyway... i dont want it to ask if mediaplayer is not playing... i dont understand what is wrong with it !!!

                      On Globals :
                      Code:
                      function QueryAllowProjectClose()
                      	if (MediaPlayer.GetState("Plugin2") == 2) then
                      		if (Dialog.Message("My Application", "Are you sure you would like to quit?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1) == 6) then
                      			return true
                      		else
                      	             return false
                      	        end
                      	else
                      		return true
                      	end
                      end
                      On Close :
                      Code:
                      QueryAllowProjectClose()
                      Attached Files
                      Last edited by GoOgLe; 04-16-2008, 09:57 AM.

                      Comment

                      • ShadowUK
                        No longer a forum member
                        • Oct 2007
                        • 1322

                        #12
                        Originally posted by GoOgLe View Post
                        asks to close or not anyway... i dont want it to ask if mediaplayer is not playing... i dont understand what is wrong with it !!!

                        On Globals :
                        Code:
                        function QueryAllowProjectClose()
                        	if (MediaPlayer.GetState("Plugin2") == 2) then
                        		if (Dialog.Message("My Application", "Are you sure you would like to quit?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1) == 6) then
                        			return true
                        		else
                        	             return false
                        	        end
                        	else
                        		return true
                        	end
                        end
                        On Close :
                        Code:
                        QueryAllowProjectClose()
                        just put the function in globals, no need to call it, it is done automaticly
                        no need to call it, it is done automaticly
                        it is done automaticly
                        automaticly

                        Comment

                        • GoOgLe
                          Forum Member
                          • Mar 2007
                          • 452

                          #13
                          @ShadowUK

                          why dont u try before answer... it doesnt work still get the same result... i tried with only putting it to Globals... it asks to close or not anyway even if u dont play anything ....

                          Comment

                          • mwreyf1
                            Indigo Rose Customer
                            • Aug 2004
                            • 417

                            #14
                            Keep in mind...

                            You must first load a file into the MediaPlayer plugin before you can get the correct return codes.

                            You do not necessarily have to start the video automatically but you HAVE to at least load it.

                            Example:
                            MediaPlayer.Load("Plugin1", "AutoPlay\\Videos\\Magnolia.mpg");

                            Comment

                            • ShadowUK
                              No longer a forum member
                              • Oct 2007
                              • 1322

                              #15
                              Originally posted by GoOgLe View Post
                              @ShadowUK

                              why dont u try before answer... it doesnt work still get the same result... i tried with only putting it to Globals... it asks to close or not anyway even if u dont play anything ....
                              Well, Sorry for trying!

                              Comment

                              Working...
                              X