INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: C# Scripting Plugin For Media Center 11 (Beta Version)  (Read 14489 times)

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
C# Scripting Plugin For Media Center 11 (Beta Version)
« on: January 07, 2006, 08:21:46 am »

This Plugin has been superseded by the .NET Script Plugin
http://yabb.jriver.com/interact/index.php?topic=38693.msg263177#msg263177

This thread is now Locked.

Michel Lefebvre

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 281
Re: C# Scripting Plugin For Media Center 11 (Alpha Version)
« Reply #1 on: January 11, 2006, 03:23:26 pm »

This is very cool!

I've installed it and it works with the sample code. I'll play with the automation commands this weekend. Maybe I'll be able to come up with a way to automate the photo workflow I use... It's sooo repetitive, it would be great if I could script most of it!

Thanks!

Michel.
Logged

Michel Lefebvre

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 281
Re: C# Scripting Plugin For Media Center 11 (Alpha Version)
« Reply #2 on: January 12, 2006, 07:01:26 am »

Looking forward to it!

M.
Logged

Michel Lefebvre

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 281
Re: C# Scripting Plugin For Media Center 11 (Alpha Version)
« Reply #3 on: January 13, 2006, 09:19:28 am »

Hi,

www.savefile.com seems to be down so I can't download the new version....

I tried pinging it but no response...

Michel.

UPDATE: It works now. I downloaded the file. :-)

M.
Logged

NoCodeUK

  • Citizen of the Universe
  • *****
  • Posts: 1820
Re: C# Scripting Plugin For Media Center 11 (Alpha Version)
« Reply #4 on: January 18, 2006, 09:43:55 am »

This is very good.  Would be even better if I could write some scripts :)
Logged
"It's called No Code because it's full of code. It's misinformation." - Eddie Vedder

Michel Lefebvre

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 281
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #5 on: January 30, 2006, 11:17:59 am »

Hi,

I've trying to download the file from this new site (mooload.com) and it's not working...

Mybe you could email me the file?

M.
Logged

Michel Lefebvre

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 281
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #6 on: January 30, 2006, 03:15:01 pm »

Downloaded flawlessly!

M.
Logged

Michel Lefebvre

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 281
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #7 on: January 31, 2006, 09:44:57 am »

Installation was no problem on my notebook which had the .Net framework 2.0 but when I fired up MC 11.1109, it gave me a message that "Interface Plug-in 'C# Script Plugin" could not be found or created.

Went to the Plugin Manager and tried to uninstall the plugin to re-install but I got the same error message...

 ?

M.
Logged

Michel Lefebvre

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 281
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #8 on: February 01, 2006, 12:38:21 pm »

This time the download, install and firing up of the plugin was perfect.

When running the script, i get this error:

"Compiling Script...

Failure Compiling Script :-
Unable to cast transparent proxy to type 'CSScriptLibrary.AsmRemoteBrowser'."

M.
Logged

Michel Lefebvre

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 281
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #9 on: February 03, 2006, 01:47:22 pm »

You won't believe it...

"ezUpload.org is currently down for maintenance and upgrades, but will be back up shortly. Once we are back up, we will have an all new layout and more features. Please keep checking back for updates!

pyius @ ezUpload.org "

M.
Logged

Michel Lefebvre

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 281
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #10 on: February 03, 2006, 02:27:04 pm »

That download site worked.

The plugin installed and ran perfectly. No problems at all this time.

M.
Logged

BlueGlow

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 331
  • Absence of alternatives clears the mind nicely.
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #11 on: March 10, 2006, 02:16:20 am »

Mr ChriZ,
This is an extremely cool plugin. I just converted a few methods from the BusyBox example to see if they would work in the C# plugin and everything is smooth. I'm going to use it now to script a complicated rename job that I need to do on about 3,000 tracks.

This is great, great work, thanks!

How is the progress coming on the next version?
Is there a way to save and load scripts?


Here are the steps to try out the examples for anyone else who would like to use Chris' slick C# script plugin:

- Close MC
- Install C# script plugin.
- Open MC and click on C# Script Plugin in the Services & Plug-ins branch of the tree
- Click the green New Script button at the bottom of the main panel
- Replace the script text with the script below
- Comment/uncomment items in the init method
- Click the green Run Script button


// Quickie conversion of a few busybox methods to try out c# script
using System;
using System.Windows.Forms;

//css_reference MediaCenter.dll;

class Script
{
   static public void Init(object MediaJukebox, object textBoxReference)
   {
      MediaJukebox.MJAutomation mediaCenterInterface = (MediaJukebox.MJAutomation)MediaJukebox;
      System.Windows.Forms.TextBox outputTextBox = (System.Windows.Forms.TextBox)textBoxReference;
         
   //Show a Sample Message Box Proving we are running!
   //MessageBox.Show("I am a Running Script!");
    outputTextBox.AppendText("\r\nThis script is running.");
    //Set the Volume Of Media Center!
      MediaJukebox.MJMixerAutomation MCMixer;
      MCMixer = mediaCenterInterface.GetMJMixer();
      //MCMixer.Volume = 50;
      //ListPlaylists(mediaCenterInterface, outputTextBox);
      //ListPlayingNow(mediaCenterInterface, outputTextBox);
      PlayRandomTracks(mediaCenterInterface, outputTextBox);
   }

  static public void ListPlaylists(MediaJukebox.MJAutomation g_MJ, System.Windows.Forms.TextBox outputTextBox)
  {
    outputTextBox.AppendText("\r\n List Playlists");
    // get the playlists collection
    MediaJukebox.MJPlaylistsAutomation MJPlaylists = (MediaJukebox.MJPlaylistsAutomation) g_MJ.GetPlaylists();
   
    // go through each playlist
    for (int z = 0; z < MJPlaylists.GetNumberPlaylists() - 1; z++){
      // get the playlist
      MediaJukebox.MJPlaylistAutomation MJPlaylist = (MediaJukebox.MJPlaylistAutomation) MJPlaylists.GetPlaylist(z);
 
      // get the playlist's full path
      string strFullPath = MJPlaylist.Path;
      if (strFullPath != "") {
        strFullPath = strFullPath + "\\";
      }
      strFullPath = strFullPath + MJPlaylist.Name;
     
      // add the playlist to the list
      outputTextBox.AppendText("\r\n"+ strFullPath);
    }
  } // end ListPlayLists

  static public void ListPlayingNow(MediaJukebox.MJAutomation g_MJ, System.Windows.Forms.TextBox outputTextBox)
  {   
    // get the current playlist object
    MediaJukebox.MJCurPlaylistAutomation MJCurPlaylist = (MediaJukebox.MJCurPlaylistAutomation) g_MJ.GetCurPlaylist();
   
    // go through each file
    for (int z = 0; z < MJCurPlaylist.GetNumberFiles() - 1; z++){
        // get the file
        MediaJukebox.MJFileAutomation MJFile = (MediaJukebox.MJFileAutomation)MJCurPlaylist.GetFile(z);
        // add the file to the list
        outputTextBox.AppendText("\r\n"+ MJFile.Filename);
    }
  } // end ListPlayingNow
 
  static public void  PlayRandomTracks(MediaJukebox.MJAutomation g_MJ, System.Windows.Forms.TextBox outputTextBox)
  {
    // get the current playlist object
    MediaJukebox.MJCurPlaylistAutomation MJCurPlaylist = (MediaJukebox.MJCurPlaylistAutomation)g_MJ.GetCurPlaylist();
   
    // remove all the existing tracks
    MJCurPlaylist.RemoveAllFiles();
   
    // add 10 random files
    // get all the files in the library
    MediaJukebox.MJFilesAutomation MJFiles = (MediaJukebox.MJFilesAutomation) g_MJ.Search("");
    Random rand = new Random();
    // go through and add 10 files
    for (int z = 0; z < 10; z++){     
        // pick a random file
        int nFileIndex = rand.Next(MJFiles.GetNumberFiles() );
        // make sure the index is in bounds
        if (nFileIndex >= 0 && nFileIndex < MJFiles.GetNumberFiles()) {
        // get the file
        MediaJukebox.MJFileAutomation MJFile = (MediaJukebox.MJFileAutomation)MJFiles.GetFile(nFileIndex);
        // add it to playing now
        MJCurPlaylist.AddFile(MJFile.Filename, z - 1);
        }
    }
   
    // set the first file to play
    MJCurPlaylist.Position = 0;
   
    // start playback
    MediaJukebox.MJPlaybackAutomation MJPlayback = (MediaJukebox.MJPlaybackAutomation) g_MJ.GetPlayback();
    MJPlayback.Play();
   
    // output status
    outputTextBox.AppendText("\r\nPlaying random tracks from Media Library");
   
  } // end PlayRandomTracks
 
} // end script class

Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #12 on: March 10, 2006, 03:18:22 am »

Glad you like it! =)
And thanks for the example
Theoretically you shouldn't need to save/load,
unless you're working in a seperate editor.
As you type it saves.  Next time you open Media Center
the scripts will be just as you left them.

If you choose to use a seperate editor as you set
the script editor back into focus it should notice the file has changed
(this maybe tempermental let me know!).
(You can see the script files in explorer by clicking Explore Scripts).
The only thing it won't do yet is notice if you add a file in the script directory.  This is also on the cards.

I do intend to add a conventional save/load system eventually.
I'm afraid development is on hold for the time being.

I'm on the home straight of a computing degree which isn't leaving me
any time to do fun stuff like this!  Come June I'll have alot more time. (Although I'm also gonna be out getting wrecked  ;) )
I'm scraping half an hour a day at the moment to spend on my evillyrics plugin.
I also need to finish my Tabbed Web browser plugin.  So at the moment
this isn't getting a lookin.  I'll PM you next time I do a build however!
=)

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #13 on: March 12, 2006, 02:06:42 pm »

Script was placed here for out of proc stuff,
this is now Resolved.

NoCodeUK

  • Citizen of the Universe
  • *****
  • Posts: 1820
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #14 on: March 15, 2006, 09:16:52 am »

My Chriz,

I ran your script and I got an exception in the output text box...I think it may be your machine :D

Adam
Logged
"It's called No Code because it's full of code. It's misinformation." - Eddie Vedder

Mike Noe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 792
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #15 on: March 15, 2006, 12:25:06 pm »

Very nice plug-in. 

I just got it going and tried your out of Proc attempt, no joy.  Here is the error msg, I'm assuming you get the same:

Code: [Select]
System.Runtime.InteropServices.COMException (0x800401E3): Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))
   at System.Runtime.InteropServices.Marshal.GetActiveObject(Guid& rclsid, IntPtr reserved, Object& ppunk)
   at System.Runtime.InteropServices.Marshal.GetActiveObject(String progID)


Logged
openSUSE TW/Plasma5 x86_64 | Win10Pro/RX560
S.M.S.L USB-DAC => Transcendent GG Pre (kit) => Transcendent mono OTLs (kit)
(heavily modded) Hammer Dynamics Super-12s (kit)
(optionally) VonSchweikert VR8s

BlueGlow

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 331
  • Absence of alternatives clears the mind nicely.
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #16 on: March 22, 2006, 01:03:56 am »

btw, the plug-in worked beautifully for the complicated rename job I mentioned earlier. I had about 3000 tracks that I needed to be fixed and I was able to do it in about an hour of scripting. Thanks again.
Logged

LanceD

  • Recent member
  • *
  • Posts: 49
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #17 on: June 21, 2006, 12:15:10 am »

Props on the plugin ChriZ! I tried your code snippet, and it ran without  exception.

As for feature requests.... Intellisense! (yeah, I'm a big .NET wuss).
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #18 on: June 21, 2006, 04:54:28 am »

Glad you like it.
Intellisense is on the cards, but I'm going to need to spend much
more time with #Develops code, because it's something
thats integrated more into the core of the program, unlike
the editor which just easily detatched =)

I've got more time to spend on these
projects now anyhow, so may get back to it soon  :)

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
.NET Scripting Plugin On it's way!
« Reply #19 on: July 09, 2006, 05:34:53 pm »

Been working on a new version of this today
which allows VB.NET scripts.
Unfortunatley the Scripting engine I'm using
doesn't quite seem to bend in the direction
i want it to at the moment.
It will run VB.NET scripts, but not as an
integrated library.  Anyhow I've sent
about 6 emails off to the author, and hopefully
it will be resolved soon!  :)

Maybe with Olegs help if I get the VB stuff
up and running, we can increase the number of users
from 4, up to who knows maybe 5  :)

quirtep

  • Regular Member
  • Recent member
  • *
  • Posts: 44
  • I'm a llama!
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #20 on: December 10, 2006, 11:45:11 am »

The download links don't seem to be working.

Thanks.
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #21 on: December 10, 2006, 12:10:30 pm »

I'll try sort this out tomorrow.  These links timeout after 60 days.
This project kind of got neglected when I started on
Intention skin.  Hopefully by the new year when that's released I can
come back to it and do an overhaul!

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #22 on: December 12, 2006, 03:59:03 pm »

New link
uppit.com/2JJWK

I can't say this is well tested.
I noticed there is a bug in the renaming of files.

Also it gets a bit funny with the working of MC12.
You need to make sure it's installed in the MC12 directory
rather than the MC11 directory.

I started on a replacement plugin called the .NET Script Plugin,
but it's only about 70% complete.

Hopefully will revisit it after xmas.

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #23 on: December 14, 2006, 09:57:32 am »

Great plugin. Thank you very much for doing this! Looking forward to new version.

Is it possible to use this to move my album art to the new directories?
Currently they are all located in one directory but i would like move them to
the same directories where the related music files are.

What kind of bug there is in the renaming of the files?

I'm planning to make a script that
1. reads each albums image filename
2. copies file to a new location.

then maybe
3. write image's file path back to the music file (maybe it's easier to do the quick find in MC)
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: C# Scripting Plugin For Media Center 11 (Beta Version)
« Reply #24 on: December 14, 2006, 10:04:21 am »

Great plugin. Thank you very much for doing this! Looking forward to new version.
Thanks  :) I really do intend to get back to it, it's one of my favourite projects.

Is it possible to use this to move my album art to the new directories?
Currently they are all located in one directory but i would like move them to
the same directories where the related music files are.
I don't see why not.  Read the field that contains the current path,
then move them to a path of your choice using the fields of your choice.

What kind of bug there is in the renaming of the files?
Theres a textbox on each tab which shows the name of the script, you used to be
able to just edit this and it would rename the script, however this appears to have stopped working.
You can always rename the scripts in explorer, and then restart MC until it's fixed.

I'm planning to make a script that
1. reads each albums image filename
2. copies file to a new location.

then maybe
3. write image's file path back to the music file (maybe it's easier to do the quick find in MC)


Ah lol didn't read that bit, till last.
Great minds think alike!  ;)
Give it a go.
If it works there's a post some linked at the top of this one
that contains sample scripts.  Feel free to add to them!

If you need any help, just give a yell, and I'll see what I can do!
Some sample scripts are here
http://yabb.jriver.com/interact/index.php?topic=33020.0
Pages: [1]   Go Up