Custom File Types/Open In App

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • RizlaUK
    Indigo Rose Customer
    • May 2006
    • 5552

    Custom File Types/Open In App

    Hey Guys,

    after i posted my last app i received a few requests for the code to make the file open in the app, so here it is

    in this example i used a .mxt (so it dosent mess up your file association)

    build the app and run it once to set the association, then rename a compatible audio file and .mxt and double click it and it will open in the example app

    I take no credit for this code, it is code i got from a few posts in the forum, all i did was combine the code into a working example

    Have Fun
    Last edited by RizlaUK; 02-01-2009, 11:35 AM.
    Embrace change in your life, you never know, it could all work out for the best
  • medina07
    Forum Member
    • Feb 2006
    • 82

    #2
    Thanks

    Very good work, is of a lot of utility, thank you to share it with us.:yes :yes

    Comment

    • Desrat
      Forum Member
      • Nov 2006
      • 240

      #3
      thats a very useful example to have..thanks RizlaUk

      Comment

      • AudioSam
        Indigo Rose Customer
        • Jan 2007
        • 272

        #4
        Thanks RizlaUk

        Good Work RizlaUK.
        It works, ...How you do that?
        lol
        Thank You
        AudioSam

        Comment

        • Ham
          Forum Member
          • Apr 2005
          • 189

          #5
          Really nice RizlaUK:yes :yes

          Comment

          • RizlaUK
            Indigo Rose Customer
            • May 2006
            • 5552

            #6
            hey, wow, 4 weeks later and my post appears, i had given up on this one, guess the powers that be was just to busy (working on AMS 7 with any luck )
            Embrace change in your life, you never know, it could all work out for the best

            Comment

            • medina07
              Forum Member
              • Feb 2006
              • 82

              #7
              Help

              I am trying to load the file with extension (.mp3) to a ListBox and from this to the Media Player, but I get an error (MediaPlayer doesn't support the following extension: (.) ).
              But when I load the file (.mp3) directly to MediaPlayer everything it works marvelously - I have changed "CHANNEL_NARRATION" for MediaPlayer plugin-
              Where is the error?

              Code:
              check to see if any commandline arg was passed to the app
              if _CommandLineArgs[1] then
              	if String.Left(_CommandLineArgs[1], 3) ~= "SFX" then
              		YourCustomFile = _CommandLineArgs[1]
              		sPath = String.SplitPath(YourCustomFile);
              		Input.SetText("Input1", sPath.Filename);
              
              			-- Add the item to the ListBox
              			ListBox.AddItem("Playlist", String.SplitPath(YourCustomFile).Filename, sPath.Filename);
                                      -- Select item from ListBox
                                      ListBox.SelectItem("Playlist", 1);
              			
              	end
              end

              Comment

              • medina07
                Forum Member
                • Feb 2006
                • 82

                #8
                My app loads the name of the song from the ListBox but doesn't run it.
                Attached Files

                Comment

                • RizlaUK
                  Indigo Rose Customer
                  • May 2006
                  • 5552

                  #9
                  i assume you are loading the file into the mp plugin via the listbox "Data" field

                  if that is the case you are loading just the filename, which is useless, you need to send the full path to it

                  and you are splitting the path twice (waist of code)

                  try this:

                  Code:
                  [i][COLOR='#008000']--check to see if any commandline arg was passed to the app[/COLOR][/i]
                  [b][COLOR='#0000FF']if[/COLOR][/b] _CommandLineArgs[COLOR='#FF0000'][[/COLOR]1[COLOR='#FF0000']][/COLOR] [b][COLOR='#0000FF']then[/COLOR][/b] 
                  	[b][COLOR='#0000FF']if[/COLOR][/b] String[COLOR='#FF0000'].[/COLOR]Left[COLOR='#FF0000']([/COLOR]_CommandLineArgs[COLOR='#FF0000'][[/COLOR]1[COLOR='#FF0000']][/COLOR][COLOR='#FF0000'],[/COLOR] 3[COLOR='#FF0000'])[/COLOR] [COLOR='#FF0000']~[/COLOR][COLOR='#FF0000']=[/COLOR] [COLOR='#800080']"SFX"[/COLOR] [b][COLOR='#0000FF']then[/COLOR][/b] 
                  		YourCustomFile [COLOR='#FF0000']=[/COLOR] _CommandLineArgs[COLOR='#FF0000'][[/COLOR]1[COLOR='#FF0000']][/COLOR] 
                  		sPath [COLOR='#FF0000']=[/COLOR] String[COLOR='#FF0000'].[/COLOR]SplitPath[COLOR='#FF0000']([/COLOR]YourCustomFile[COLOR='#FF0000'])[/COLOR]; 
                  		Input[COLOR='#FF0000'].[/COLOR]SetText[COLOR='#FF0000']([/COLOR] [COLOR='#800080']"Input1"[/COLOR][COLOR='#FF0000'],[/COLOR] sPath[COLOR='#FF0000'].[/COLOR]Filename[COLOR='#FF0000'])[/COLOR]; 
                  
                  		 [i][COLOR='#008000']	-- Add the item to the ListBox[/COLOR][/i]
                  			ListBox[COLOR='#FF0000'].[/COLOR]AddItem[COLOR='#FF0000']([/COLOR] [COLOR='#800080']"Playlist"[/COLOR][COLOR='#FF0000'],[/COLOR] sPath[COLOR='#FF0000'].[/COLOR]Filename[COLOR='#FF0000'],[/COLOR] YourCustomFile[COLOR='#FF0000'])[/COLOR]; 
                             [i][COLOR='#008000'] -- Select item from ListBox[/COLOR][/i]
                              ListBox[COLOR='#FF0000'].[/COLOR]SelectItem[COLOR='#FF0000']([/COLOR] [COLOR='#800080']"Playlist"[/COLOR][COLOR='#FF0000'],[/COLOR] 1[COLOR='#FF0000'])[/COLOR]; 
                  			
                  	[b][COLOR='#0000FF']end[/COLOR][/b] 
                  [b][COLOR='#0000FF']end[/COLOR][/b]
                  output enhanced with AMS Code Pretty
                  Embrace change in your life, you never know, it could all work out for the best

                  Comment

                  • mz241508
                    Forum Member
                    • Oct 2006
                    • 351

                    #10
                    Try this code:
                    Code:
                    --check to see if any commandline arg was passed to the app
                    if _CommandLineArgs[1] then
                    	if String.Left(_CommandLineArgs[1], 3) ~= "SFX" then
                    		YourCustomFile = _CommandLineArgs[1]
                    		sPath = String.SplitPath(YourCustomFile);
                    		Input.SetText("Input1", sPath.Filename);
                    
                    		-- Add the item to the ListBox
                    		ListBox.AddItem("Playlist", sPath.Filename, [COLOR="Red"]YourCustomFile[/COLOR]);
                    		-- Select item from ListBox
                    		ListBox.SelectItem("Playlist", 1);
                    	end
                    end
                    LOL, looks like RizlaUK beat me to it!

                    Comment

                    • RizlaUK
                      Indigo Rose Customer
                      • May 2006
                      • 5552

                      #11
                      lol....beat ya by 30 seconds
                      Embrace change in your life, you never know, it could all work out for the best

                      Comment

                      • medina07
                        Forum Member
                        • Feb 2006
                        • 82

                        #12
                        Thank you RizlaUK and mz241508 now everything works perfectly.:yes :yes
                        Attached Files

                        Comment

                        • medina07
                          Forum Member
                          • Feb 2006
                          • 82

                          #13
                          This way I can initialize the file automatically from the ListBox

                          Code:
                          --check to see if any commandline arg was passed to the app
                          if _CommandLineArgs[1] then 
                          	if String.Left(_CommandLineArgs[1], 3) ~= "SFX" then 
                          		YourCustomFile = _CommandLineArgs[1] 
                          		sPath = String.SplitPath(YourCustomFile); 
                          		Input.SetText( "Input1", sPath.Filename); 
                          
                          		 	-- Add the item to the ListBox
                          			ListBox.AddItem( "Playlist", sPath.Filename, YourCustomFile); 
                                      -- Select item from ListBox
                                      ListBox.SelectItem( "Playlist", 1);
                                       -- Get the selected item(s) from the ListBox
                          Selected = ListBox.GetSelected("Playlist");
                          -- Ensure that there was an item selected
                          if Selected then
                          	-- Get the path to the selected file (stored in the item's 'data')
                          	FilePath = ListBox.GetItemData("Playlist", Selected[1]);
                          	-- load the file
                          	MediaPlayer.Load("Media", FilePath);
                          	-- play the file
                          	MediaPlayer.Play("Media");
                          	-- start the timer
                          	Page.StartTimer(500);
                          	-- set as playing
                          	Playing = true
                          	-- set as not paused
                          	Paused = false
                          	-- set as loaded
                          	Loaded = true
                          	-- set the total time
                          	Label.SetText("Total", Clock(MediaPlayer.GetLength("Media")));
                          end
                          end            
                          end

                          Comment

                          • SiNisTer
                            Forum Member
                            • Mar 2007
                            • 187

                            #14
                            Thank for the codes guys

                            Hey guys I tried the some of the codes & it works perfectly until you try to open multiple mp3 files - then it starts to open several instances of the player (the application) to load each file:lol
                            I hope some one can try to update this part of the codes...It'll be really useful...

                            BTW is there also a way to read the data in a saved .m3u playlist and load this into the listbox when I double click it considering the my app is set as the default Application for the file?

                            Comment

                            • Desolator
                              Forum Member
                              • Apr 2007
                              • 292

                              #15
                              Yes. Detect the extension and load the playlist.

                              Comment

                              Working...
                              X