From: <che...@us...> - 2010-11-14 15:51:59
|
Revision: 3935 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3935&view=rev Author: chef_koch Date: 2010-11-14 15:51:46 +0000 (Sun, 14 Nov 2010) Log Message: ----------- added foobar (external player) plugin from official MP Added Paths: ----------- trunk/plugins/FoobarExternalPlayers/ trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/ trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarConfigForm.cs trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarConfigForm.resx trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarExternalPlayers.csproj trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarPlugin.cs trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/Properties/ trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/Properties/AssemblyInfo.cs trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/foobarlogo.png trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/foobarlogodisabled.png trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers.sln Property changes on: trunk/plugins/FoobarExternalPlayers ___________________________________________________________________ Added: svn:ignore + *.suo *.user _ReSharper.FoobarExternalPlayers Property changes on: trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers ___________________________________________________________________ Added: svn:ignore + bin obj Added: trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarConfigForm.cs =================================================================== --- trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarConfigForm.cs (rev 0) +++ trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarConfigForm.cs 2010-11-14 15:51:46 UTC (rev 3935) @@ -0,0 +1,481 @@ +#region Copyright (C) 2005-2010 Team MediaPortal + +// Copyright (C) 2005-2010 Team MediaPortal +// http://www.team-mediaportal.com +// +// MediaPortal is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// MediaPortal is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. + +#endregion + +using System; +using System.ComponentModel; +using System.IO; +using System.Text; +using System.Windows.Forms; +using MediaPortal.Configuration; +using MediaPortal.Profile; +using MediaPortal.UserInterface.Controls; +using Microsoft.Win32; + +namespace MediaPortal.FoobarPlugin +{ + /// <summary> + /// Summary description for FoobarConfigForm. + /// </summary> + public class FoobarConfigForm : MPConfigForm + { + private LinkLabel linkLabelPluginSource; + private GroupBox groupBoxFoobarLocation; + private MPLabel labelPortNumber; + private MPTextBox textBoxPortNumber; + private MPTextBox textBoxHostname; + private MPButton buttonBrowseFoobarLoc; + private MPTextBox textBoxFoobarPath; + private MPLabel labelHostname; + private MPLabel labelLocation; + private GroupBox groupBoxFoobarSettings; + private MPTextBox textBoxFoobarExtensions; + private MPLabel labelFoobarFileTypes; + private LinkLabel linkLabelStartupParameter; + private TextBox textBoxStartupParameter; + private MPButton btnOK; + private MPButton btnCancel; + + /// <summary> + /// Required designer variable. + /// </summary> + private Container components = null; + + public FoobarConfigForm() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + LoadSettings(); + } + + /// <summary> + /// Clean up any resources being used. + /// </summary> + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.linkLabelPluginSource = new System.Windows.Forms.LinkLabel(); + this.groupBoxFoobarLocation = new System.Windows.Forms.GroupBox(); + this.labelPortNumber = new MediaPortal.UserInterface.Controls.MPLabel(); + this.textBoxPortNumber = new MediaPortal.UserInterface.Controls.MPTextBox(); + this.textBoxHostname = new MediaPortal.UserInterface.Controls.MPTextBox(); + this.buttonBrowseFoobarLoc = new MediaPortal.UserInterface.Controls.MPButton(); + this.textBoxFoobarPath = new MediaPortal.UserInterface.Controls.MPTextBox(); + this.labelHostname = new MediaPortal.UserInterface.Controls.MPLabel(); + this.labelLocation = new MediaPortal.UserInterface.Controls.MPLabel(); + this.groupBoxFoobarSettings = new System.Windows.Forms.GroupBox(); + this.linkLabelStartupParameter = new System.Windows.Forms.LinkLabel(); + this.textBoxStartupParameter = new System.Windows.Forms.TextBox(); + this.textBoxFoobarExtensions = new MediaPortal.UserInterface.Controls.MPTextBox(); + this.labelFoobarFileTypes = new MediaPortal.UserInterface.Controls.MPLabel(); + this.btnOK = new MediaPortal.UserInterface.Controls.MPButton(); + this.btnCancel = new MediaPortal.UserInterface.Controls.MPButton(); + this.groupBoxFoobarLocation.SuspendLayout(); + this.groupBoxFoobarSettings.SuspendLayout(); + this.SuspendLayout(); + // + // linkLabelPluginSource + // + this.linkLabelPluginSource.Anchor = + ((System.Windows.Forms.AnchorStyles) + (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.linkLabelPluginSource.LinkArea = new System.Windows.Forms.LinkArea(37, 19); + this.linkLabelPluginSource.Location = new System.Drawing.Point(12, 254); + this.linkLabelPluginSource.Name = "linkLabelPluginSource"; + this.linkLabelPluginSource.Size = new System.Drawing.Size(392, 32); + this.linkLabelPluginSource.TabIndex = 5; + this.linkLabelPluginSource.TabStop = true; + this.linkLabelPluginSource.Text = + "NOTE: Remember to install and setup foo_httpserver_ctrl (version B1) in your foo" + + "bar\\components directory."; + this.linkLabelPluginSource.UseCompatibleTextRendering = true; + this.linkLabelPluginSource.LinkClicked += + new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelPluginSource_LinkClicked); + // + // groupBoxFoobarLocation + // + this.groupBoxFoobarLocation.Anchor = + ((System.Windows.Forms.AnchorStyles) + (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFoobarLocation.Controls.Add(this.labelPortNumber); + this.groupBoxFoobarLocation.Controls.Add(this.textBoxPortNumber); + this.groupBoxFoobarLocation.Controls.Add(this.textBoxHostname); + this.groupBoxFoobarLocation.Controls.Add(this.buttonBrowseFoobarLoc); + this.groupBoxFoobarLocation.Controls.Add(this.textBoxFoobarPath); + this.groupBoxFoobarLocation.Controls.Add(this.labelHostname); + this.groupBoxFoobarLocation.Controls.Add(this.labelLocation); + this.groupBoxFoobarLocation.Location = new System.Drawing.Point(12, 12); + this.groupBoxFoobarLocation.Name = "groupBoxFoobarLocation"; + this.groupBoxFoobarLocation.Size = new System.Drawing.Size(392, 91); + this.groupBoxFoobarLocation.TabIndex = 7; + this.groupBoxFoobarLocation.TabStop = false; + this.groupBoxFoobarLocation.Text = "Location"; + // + // labelPortNumber + // + this.labelPortNumber.Anchor = + ((System.Windows.Forms.AnchorStyles) + ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelPortNumber.AutoSize = true; + this.labelPortNumber.Location = new System.Drawing.Point(293, 57); + this.labelPortNumber.Name = "labelPortNumber"; + this.labelPortNumber.Size = new System.Drawing.Size(26, 13); + this.labelPortNumber.TabIndex = 13; + this.labelPortNumber.Text = "Port"; + // + // textBoxPortNumber + // + this.textBoxPortNumber.Anchor = + ((System.Windows.Forms.AnchorStyles) + ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxPortNumber.BorderColor = System.Drawing.Color.Empty; + this.textBoxPortNumber.Enabled = false; + this.textBoxPortNumber.Location = new System.Drawing.Point(326, 54); + this.textBoxPortNumber.Name = "textBoxPortNumber"; + this.textBoxPortNumber.Size = new System.Drawing.Size(54, 20); + this.textBoxPortNumber.TabIndex = 11; + this.textBoxPortNumber.Text = "8989"; + this.textBoxPortNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // textBoxHostname + // + this.textBoxHostname.Anchor = + ((System.Windows.Forms.AnchorStyles) + (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxHostname.BorderColor = System.Drawing.Color.Empty; + this.textBoxHostname.Enabled = false; + this.textBoxHostname.Location = new System.Drawing.Point(92, 54); + this.textBoxHostname.Name = "textBoxHostname"; + this.textBoxHostname.Size = new System.Drawing.Size(195, 20); + this.textBoxHostname.TabIndex = 10; + this.textBoxHostname.Text = "localhost"; + // + // buttonBrowseFoobarLoc + // + this.buttonBrowseFoobarLoc.Anchor = + ((System.Windows.Forms.AnchorStyles) + ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonBrowseFoobarLoc.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonBrowseFoobarLoc.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.buttonBrowseFoobarLoc.Location = new System.Drawing.Point(356, 19); + this.buttonBrowseFoobarLoc.Name = "buttonBrowseFoobarLoc"; + this.buttonBrowseFoobarLoc.Size = new System.Drawing.Size(24, 23); + this.buttonBrowseFoobarLoc.TabIndex = 8; + this.buttonBrowseFoobarLoc.Text = "..."; + this.buttonBrowseFoobarLoc.UseVisualStyleBackColor = true; + this.buttonBrowseFoobarLoc.Click += new System.EventHandler(this.buttonBrowseFoobarLoc_Click); + // + // textBoxFoobarPath + // + this.textBoxFoobarPath.Anchor = + ((System.Windows.Forms.AnchorStyles) + (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxFoobarPath.BorderColor = System.Drawing.Color.Empty; + this.textBoxFoobarPath.Enabled = false; + this.textBoxFoobarPath.Location = new System.Drawing.Point(92, 21); + this.textBoxFoobarPath.Name = "textBoxFoobarPath"; + this.textBoxFoobarPath.Size = new System.Drawing.Size(252, 20); + this.textBoxFoobarPath.TabIndex = 12; + // + // labelHostname + // + this.labelHostname.AutoSize = true; + this.labelHostname.Location = new System.Drawing.Point(10, 57); + this.labelHostname.Name = "labelHostname"; + this.labelHostname.Size = new System.Drawing.Size(55, 13); + this.labelHostname.TabIndex = 9; + this.labelHostname.Text = "Hostname"; + // + // labelLocation + // + this.labelLocation.AutoSize = true; + this.labelLocation.Location = new System.Drawing.Point(10, 24); + this.labelLocation.Name = "labelLocation"; + this.labelLocation.Size = new System.Drawing.Size(76, 13); + this.labelLocation.TabIndex = 7; + this.labelLocation.Text = "foobar2k v.8.3"; + // + // groupBoxFoobarSettings + // + this.groupBoxFoobarSettings.Anchor = + ((System.Windows.Forms.AnchorStyles) + (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFoobarSettings.Controls.Add(this.linkLabelStartupParameter); + this.groupBoxFoobarSettings.Controls.Add(this.textBoxStartupParameter); + this.groupBoxFoobarSettings.Controls.Add(this.textBoxFoobarExtensions); + this.groupBoxFoobarSettings.Controls.Add(this.labelFoobarFileTypes); + this.groupBoxFoobarSettings.Location = new System.Drawing.Point(12, 109); + this.groupBoxFoobarSettings.Name = "groupBoxFoobarSettings"; + this.groupBoxFoobarSettings.Size = new System.Drawing.Size(392, 132); + this.groupBoxFoobarSettings.TabIndex = 8; + this.groupBoxFoobarSettings.TabStop = false; + this.groupBoxFoobarSettings.Text = "Settings"; + // + // linkLabelStartupParameter + // + this.linkLabelStartupParameter.AutoSize = true; + this.linkLabelStartupParameter.LinkArea = new System.Windows.Forms.LinkArea(8, 9); + this.linkLabelStartupParameter.Location = new System.Drawing.Point(13, 25); + this.linkLabelStartupParameter.Name = "linkLabelStartupParameter"; + this.linkLabelStartupParameter.Size = new System.Drawing.Size(95, 17); + this.linkLabelStartupParameter.TabIndex = 9; + this.linkLabelStartupParameter.TabStop = true; + this.linkLabelStartupParameter.Text = "Startup parameter"; + this.linkLabelStartupParameter.UseCompatibleTextRendering = true; + this.linkLabelStartupParameter.LinkClicked += + new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelStartupParameter_LinkClicked); + // + // textBoxStartupParameter + // + this.textBoxStartupParameter.Anchor = + ((System.Windows.Forms.AnchorStyles) + (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxStartupParameter.Location = new System.Drawing.Point(13, 45); + this.textBoxStartupParameter.Name = "textBoxStartupParameter"; + this.textBoxStartupParameter.Size = new System.Drawing.Size(367, 20); + this.textBoxStartupParameter.TabIndex = 7; + this.textBoxStartupParameter.Text = "/hide /command:\"Playback/Order/Default\""; + // + // textBoxFoobarExtensions + // + this.textBoxFoobarExtensions.Anchor = + ((System.Windows.Forms.AnchorStyles) + (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxFoobarExtensions.BorderColor = System.Drawing.Color.Empty; + this.textBoxFoobarExtensions.Location = new System.Drawing.Point(13, 93); + this.textBoxFoobarExtensions.Name = "textBoxFoobarExtensions"; + this.textBoxFoobarExtensions.Size = new System.Drawing.Size(367, 20); + this.textBoxFoobarExtensions.TabIndex = 6; + this.textBoxFoobarExtensions.Text = ".cda,.mp3,.mid,.wav,.mpc,.aac,.shn,.wma,.ac3,.ogg"; + // + // labelFoobarFileTypes + // + this.labelFoobarFileTypes.AutoSize = true; + this.labelFoobarFileTypes.Location = new System.Drawing.Point(10, 77); + this.labelFoobarFileTypes.Name = "labelFoobarFileTypes"; + this.labelFoobarFileTypes.Size = new System.Drawing.Size(328, 13); + this.labelFoobarFileTypes.TabIndex = 5; + this.labelFoobarFileTypes.Text = "Supported file types (other files will be played by MP\'s internal player)"; + // + // btnOK + // + this.btnOK.Location = new System.Drawing.Point(248, 291); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(75, 23); + this.btnOK.TabIndex = 9; + this.btnOK.Text = "&OK"; + this.btnOK.UseVisualStyleBackColor = true; + this.btnOK.Click += new System.EventHandler(this.btnOK_Click); + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(329, 291); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 10; + this.btnCancel.Text = "&Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // FoobarConfigForm + // + this.AcceptButton = this.btnOK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(416, 326); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOK); + this.Controls.Add(this.groupBoxFoobarSettings); + this.Controls.Add(this.groupBoxFoobarLocation); + this.Controls.Add(this.linkLabelPluginSource); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "FoobarConfigForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Foobar2000 - Setup"; + this.groupBoxFoobarLocation.ResumeLayout(false); + this.groupBoxFoobarLocation.PerformLayout(); + this.groupBoxFoobarSettings.ResumeLayout(false); + this.groupBoxFoobarSettings.PerformLayout(); + this.ResumeLayout(false); + } + + #endregion + + /// <summary> + /// This method is called whenever the browse button is clicked + /// </summary> + /// <param name="sender">the sender instance</param> + /// <param name="e">the event. In this case click!</param> + private void buttonBrowseFoobarLoc_Click(object sender, EventArgs e) + { + string curDir = Directory.GetCurrentDirectory(); + // The filter for the dialog window is foobar2000.exe + OpenFileDialog dlg = new OpenFileDialog(); + dlg.AddExtension = true; + dlg.Filter = "Foobar2000 (Foobar2000.exe)|Foobar2000.exe|All files (*.*)|*.*"; + // start in media folder + //dlg.InitialDirectory = @"C:\"; + // open dialog + if (dlg.ShowDialog(this) == DialogResult.OK) + { + textBoxFoobarPath.Text = dlg.FileName; + } + Directory.SetCurrentDirectory(curDir); + } + + /// <summary> + /// When this form loads, read the configuration file for the variables that this + /// form sets up + /// </summary> + private void LoadSettings() + { + using (Settings xmlreader = new MPSettings()) + { + textBoxFoobarExtensions.Text = xmlreader.GetValueAsString("foobarplugin", "enabledextensions", + ".cda,.mp3,.mid,.wav,.mpc,.aac,.shn,.wma,.ac3,.ogg"); + textBoxPortNumber.Text = xmlreader.GetValueAsString("foobarplugin", "port", "8989"); + textBoxHostname.Text = xmlreader.GetValueAsString("foobarplugin", "host", "localhost"); + textBoxFoobarPath.Text = xmlreader.GetValueAsString("foobarplugin", "path", ""); + textBoxStartupParameter.Text = xmlreader.GetValueAsString("foobarplugin", "startupparameter", + "/hide /command:\"Playback/Order/Default\""); + } + if (textBoxFoobarPath.Text.Equals(String.Empty)) + { + using (RegistryKey pRegKey = Registry.CurrentUser) + { + using (RegistryKey subkey = pRegKey.OpenSubKey("Software\\foobar2000")) + { + if (subkey != null) + { + Object val = subkey.GetValue("InstallDir"); + if (val.ToString().Trim().Length > 0) + { + textBoxFoobarPath.Text = val.ToString() + "\\foobar2000.exe"; + } + } + else + { + MessageBox.Show( + "Foobar2000 is not installed on your system!\r\nPlease install it first before actually trying to use this plugin!", + "Foobar2000 plugin error", MessageBoxButtons.OK, MessageBoxIcon.Error); + Close(); + } + } + } + } + } + + /// <summary> + /// Write the variables from the form to the configuration file when this form closes + /// </summary> + private void SaveSettings() + { + using (Settings xmlWriter = new MPSettings()) + { + xmlWriter.SetValue("foobarplugin", "port", textBoxPortNumber.Text); + xmlWriter.SetValue("foobarplugin", "host", textBoxHostname.Text); + xmlWriter.SetValue("foobarplugin", "path", textBoxFoobarPath.Text); + xmlWriter.SetValue("foobarplugin", "startupparameter", textBoxStartupParameter.Text); + // make sure all the extensions starts with "." If not, add it in... + string[] exts = textBoxFoobarExtensions.Text.Split(new char[] {','}); + StringBuilder buff = new StringBuilder(); + foreach (string ext in exts) + { + if (buff.Length != 0) + { + buff.Append(','); + } + if (!ext.StartsWith(".")) + { + buff.Append('.'); + } + buff.Append(ext); + } + xmlWriter.SetValue("foobarplugin", "enabledextensions", buff.ToString()); + } + } + + private void linkLabelStartupParameter_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + // Determine which link was clicked within the LinkLabel. + this.linkLabelStartupParameter.Links[linkLabelStartupParameter.Links.IndexOf(e.Link)].Visited = true; + try + { + Help.ShowHelp(this, "http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Commandline_Guide"); + } + catch {} + } + + /// <summary> + /// The link will open the link on a browser to get the foobar plugin from the source + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void linkLabelPluginSource_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + // Determine which link was clicked within the LinkLabel. + this.linkLabelPluginSource.Links[linkLabelPluginSource.Links.IndexOf(e.Link)].Visited = true; + try + { + Help.ShowHelp(this, "http://sourceforge.net/projects/foohttpserver"); + } + catch {} + } + + private void btnOK_Click(object sender, EventArgs e) + { + SaveSettings(); + this.Close(); + } + + private void btnCancel_Click(object sender, EventArgs e) + { + LoadSettings(); + this.Close(); + } + } +} \ No newline at end of file Added: trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarConfigForm.resx =================================================================== --- trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarConfigForm.resx (rev 0) +++ trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarConfigForm.resx 2010-11-14 15:51:46 UTC (rev 3935) @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file Added: trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarExternalPlayers.csproj =================================================================== --- trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarExternalPlayers.csproj (rev 0) +++ trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarExternalPlayers.csproj 2010-11-14 15:51:46 UTC (rev 3935) @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{D4BB2A55-2F02-4AB2-B86C-891388E3C616}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>FoobarExternalPlayers</RootNamespace> + <AssemblyName>FoobarExternalPlayers</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Compile Include="FoobarConfigForm.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="FoobarPlugin.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <Content Include="foobarlogo.png" /> + <Content Include="foobarlogodisabled.png" /> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="FoobarConfigForm.resx"> + <DependentUpon>FoobarConfigForm.cs</DependentUpon> + </EmbeddedResource> + </ItemGroup> + <ItemGroup> + <Reference Include="Core"> + <HintPath>..\..\..\..\..\MediaPortal\trunk\mediaportal\Core\bin\Release\Core.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Net" /> + <Reference Include="System.Web" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="Utils"> + <HintPath>..\..\..\..\..\MediaPortal\trunk\mediaportal\Utils\bin\Release\Utils.dll</HintPath> + </Reference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Added: trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarPlugin.cs =================================================================== --- trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarPlugin.cs (rev 0) +++ trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/FoobarPlugin.cs 2010-11-14 15:51:46 UTC (rev 3935) @@ -0,0 +1,773 @@ +#region Copyright (C) 2005-2010 Team MediaPortal + +// Copyright (C) 2005-2010 Team MediaPortal +// http://www.team-mediaportal.com +// +// MediaPortal is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// MediaPortal is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. + +#endregion + +using System; +using System.Diagnostics; +using System.IO; +using System.Net; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Web; +using MediaPortal.Configuration; +using MediaPortal.GUI.Library; +using MediaPortal.Player; +using MediaPortal.Profile; +using MediaPortal.Util; + +namespace MediaPortal.FoobarPlugin +{ + /// <summary> + /// Foobar plugin class + /// </summary> + [PluginIcons("ExternalPlayers.Foobar.foobarlogo.png", "ExternalPlayers.Foobar.foobarlogodisabled.png")] + public class FoobarPlugin : IExternalPlayer + { + private const int WM_HTTPSERVER_MSG_CMD = 0x8898; + private const int WM_HTTPSERVER_MSG_GETSTATE = 0x00; + private const int WM_HTTPSERVER_MSG_GETPLAYLENGTH = 0x01; + private const int WM_HTTPSERVER_MSG_GETPLAYBACKTIME = 0x02; + private const int WM_HTTPSERVER_MSG_STOP = 0x03; + private const int WM_HTTPSERVER_MSG_PAUSE = 0x04; + private const int WM_HTTPSERVER_MSG_SETVOLUME = 0x05; + private const int WM_HTTPSERVER_MSG_GETVOLUME = 0x06; + private const int WM_HTTPSERVER_MSG_SEEK = 0x07; + private const int WM_HTTPSERVER_MSG_SETACTIVEPLAYLIST = 0x08; + private const int WM_HTTPSERVER_MSG_CLEARPLAYLIST = 0x09; + private const int WM_COPYDATA = 0x004a; + + private const string m_author = "int_20h/rtv"; + private const string m_player = "Foobar2000"; + private const string m_version = "2.0b"; + + // set in configuration + private string[] m_supportedExtensions = new string[0]; + private string m_execPath = null; + private string m_hostname = "localhost"; + private int m_port = 8989; + private string m_startupparameter = null; + private string m_windowName = null; + + // internally maintain + private string m_strCurrentFile = null; + + private Process m_foobarProcess = null; + private IntPtr m_hwnd = IntPtr.Zero; + private IntPtr m_hwndPlugin = IntPtr.Zero; + private bool m_bStoppedManualy = false; + private bool _notifyPlaying = false; + private bool _isCDA = false; + + /// <summary> + /// Empty constructor. Nothing to initialize + /// </summary> + public FoobarPlugin() + { + //Thread.CurrentThread.Name = "FoobarPlugin"; + // empty constructor + } + + /// <summary> + /// Starts the player if it is not running... + /// </summary> + private void startPlayerIfNecessary() + { + if (m_execPath != null && m_execPath.Length > 0) + { + if (!string.IsNullOrEmpty(m_windowName)) + { + m_hwnd = Win32API.FindWindow(null, m_windowName); + m_hwndPlugin = Win32API.FindWindow("foo_httpserver_ctrl", null); + } + if (m_hwnd.ToInt32() <= 0) // try to find it and start it since it's not found + { + IntPtr mpHwnd = Win32API.GetActiveWindow(); + RunProgram(m_execPath, m_startupparameter); + Log.Info("ExternalPlayers: Started foobar2000 with {0}", m_startupparameter); + Win32API.ShowWindow(mpHwnd, Win32API.ShowWindowFlags.Restore); + Win32API.SetForegroundWindow(mpHwnd); + m_hwnd = Win32API.FindWindow(null, m_windowName); + m_hwndPlugin = Win32API.FindWindow("foo_httpserver_ctrl", null); + } + } + } + + + /// <summary> + /// Runs a particular program in the local file system + /// </summary> + /// <param name="exeName"></param> + /// <param name="argsLine"></param> + private void RunProgram(string exeName, string argsLine) + { + ProcessStartInfo psI = new ProcessStartInfo(exeName, argsLine); + Process newProcess = new Process(); + try + { + newProcess.StartInfo.FileName = exeName; + newProcess.StartInfo.Arguments = argsLine; + newProcess.StartInfo.UseShellExecute = true; + newProcess.StartInfo.CreateNoWindow = true; + newProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; + newProcess.Start(); + + IntPtr httpPluginWindow; + for (int i = 0; i < (2 * 6); i++) // wait 6 seconds for Foobar2k to start. + { + Thread.Sleep(500); + httpPluginWindow = Win32API.FindWindow("foo_httpserver_ctrl", null); + if (httpPluginWindow.ToInt32() > 0) // window handle was found + { + break; + } + } + m_foobarProcess = newProcess; + } + catch (Exception ex) + { + throw ex; + } + } + + /// <summary> + /// Read the configuration file for parameters needed for the plugin to function correctly + /// </summary> + private void readConfig() + { + string strExt = null; + string execPath = null; + string hostname = null; + string port = null; + string windowName = null; + string startupparameter = null; + + using (Settings xmlreader = new MPSettings()) + { + // extensions to play by this player + strExt = xmlreader.GetValueAsString("foobarplugin", "enabledextensions", ""); + // where is foobar executable + execPath = xmlreader.GetValueAsString("foobarplugin", "path", ""); + // which host to talk to + hostname = xmlreader.GetValueAsString("foobarplugin", "host", "localhost"); + // which port to talk to + port = xmlreader.GetValueAsString("foobarplugin", "port", "8989"); + // what's the window name of the program + windowName = xmlreader.GetValueAsString("foobarplugin", "windowname", ""); + // additional startup options + startupparameter = xmlreader.GetValueAsString("foobarplugin", "startupparameter", + " /hide /command:\"Playback/ReplayGain/Album\""); + } + if (strExt != null && strExt.Length > 0) + { + m_supportedExtensions = strExt.Split(new char[] { ',' }); + } + if (execPath != null && execPath.Length > 0) + { + m_execPath = execPath; + } + if (hostname != null && hostname.Length > 0) + { + m_hostname = hostname; + } + if (port != null && port.Length > 0) + { + try + { + m_port = Convert.ToInt32(port); + } + catch { } + } + if (startupparameter != null && startupparameter.Length > 0) + { + m_startupparameter = startupparameter; + } + if (windowName != null && windowName.Length > 0) + { + m_windowName = windowName; + } + else + { + // lets figure it out by openning the installer.ini file and look at the version. + // The window name is "foobar2000 v<version>" so, if we need to find the window, + // we need the version number! + StringBuilder buff = new StringBuilder(); + StreamReader sr = null; + string version = null; + + try + { + string path = m_execPath.ToLower(); + int index = path.LastIndexOf("foobar"); + string iniFile = m_execPath.Substring(0, index) + "installer.ini"; + + //Pass the file path and file name to the StreamReader constructor + using (sr = new StreamReader(iniFile)) + { + //Read the first line of text + string line = sr.ReadLine(); + //Continue to read until you reach end of file + + while (line != null) + { + if (line.ToLower().Trim().StartsWith("version")) + { + index = line.IndexOf("="); + version = line.Substring(index + 1).Trim(); + } + //Read the next line + line = sr.ReadLine(); + } + //close the file + sr.Close(); + } + } + catch (Exception e) + { + Console.WriteLine("Exception: " + e.Message); + } + if (sr != null) + { + sr.Close(); + sr = null; + } + + if (version != null) + { + m_windowName = "foobar2000 v" + version; + } + } + } + + /// <summary> + /// This method performs the GET method via HTTP to request a specific page + /// </summary> + /// <param name="strURL">The URL to get a request from</param> + /// <returns></returns> + private string GetHTTP(string strURL) + { + string retval = null; + + // Initialize the WebRequest. + WebRequest myRequest = WebRequest.Create(strURL); + try + { + // Use the current user in case an NTLM Proxy or similar is used. + // wr.Proxy = WebProxy.GetDefaultProxy(); + myRequest.Proxy.Credentials = CredentialCache.DefaultCredentials; + } + catch (Exception) { } + + // Return the response. + WebResponse myResponse = myRequest.GetResponse(); + + Stream ReceiveStream = myResponse.GetResponseStream(); + + // 1252 is encoding for Windows format + Encoding encode = Encoding.GetEncoding(1252); + using (StreamReader sr = new StreamReader(ReceiveStream, encode)) + { + retval = sr.ReadToEnd(); + } + + + // Close the response to free resources. + myResponse.Close(); + + return retval; + } + + /// <summary> + /// Executes the given command and pass the given parameters to the foobar httpserver plugin + /// </summary> + /// <param name="command">The command to execute in foobar</param> + /// <param name="param1">The first parameter if necessary</param> + /// <param name="param2">The second parameter if necessary</param> + /// <returns></returns> + private string ExecuteCommand(string command, string param1, string param2) + { + if (command == null || command.Length == 0) + { + return ""; + } + if (m_execPath == null || m_execPath.Length == 0) + { + return "ERROR: MP plugin not configured"; + } + + string retval = null; + string url = "http://" + m_hostname + ":" + m_port + "/?cmd=" + command + "¶m1=" + param1 + "¶m2=" + + param2; + string response = GetHTTP(url); + + // the command is good and was executed correctly + if (response.IndexOf("cmd=" + command) != -1) + { + string val = "retval="; + int cmdValueIndex = response.IndexOf(val) + val.Length; + retval = response.Substring(cmdValueIndex).Trim(); + } + else + { + retval = "ERROR: mismatch command"; + } + return retval; + } + + /// <summary> + /// Supported extensions are defined in the configuration of the plugin. Therefore, + /// this is taken from the configuration file of MediaPortal to what the user + /// defines it + /// </summary> + /// <returns>A string array of all the extensions supported (i.e. .mp3 .cda .mid</returns> + public override string[] GetAllSupportedExtensions() + { + readConfig(); + return m_supportedExtensions; + } + + /// <summary> + /// This method is called by the plugin screen to show the configuration for the foobar plugin + /// </summary> + public override void ShowPlugin() + { + FoobarConfigForm confForm = new FoobarConfigForm(); + confForm.ShowDialog(); + } + + /// <summary> + /// Description property + /// </summary> + /// <returns></returns> + public override string Description() + { + if (m_supportedExtensions.Length == 0) + { + return "Advanced audio player - http://www.foobar2000.org"; + } + return base.Description(); + } + + /// <summary> + /// Author property. Only Get is defined. + /// </summary> + public override string AuthorName + { + get { return m_author; } + } + + + /// <summary> + /// Player name property. Only Get is defined. + /// </summary> + public override string PlayerName + { + get { return m_player; } + } + + /// <summary> + /// Version number property + /// </summary> + public override string VersionNumber + { + get { return m_version; } + } + + /// <summary> + /// This method is called to find out if this plugin supports a given filename. The + /// method uses the extension to figure out if it supports it + /// </summary> + /// <param name="filename">The filename to check if the plugin supports it.</param> + /// <returns>True or false depending if the file is supported or not</returns> + public override bool SupportsFile(string filename) + { + readConfig(); + string ext = null; + int dot = filename.LastIndexOf("."); // couldn't find the dot to get the extension + if (dot == -1) + { + return false; + } + + ext = filename.Substring(dot).Trim(); + if (ext.Length == 0) + { + return false; // no extension so return false; + } + + ext = ext.ToLower(); + + for (int i = 0; i < m_supportedExtensions.Length; i++) + { + if (m_supportedExtensions[i].Equals(ext)) + { + return true; + } + } + // could not match the extension, so return false; + return false; + } + + /// <summary> + /// Play the given file + /// </summary> + /// <param name="strFile"></param> + /// <returns></returns> + public override bool Play(string strFile) + { + // stop other media which might be active until now. + if (g_Player.Playing) + { + g_Player.Stop(); + } + + + _isCDA = false; + if (strFile.IndexOf(".cda") >= 0) + { + string strTrack = ""; + int pos = strFile.IndexOf(".cda"); + if (pos >= 0) + { + pos--; + while (Char.IsDigit(strFile[pos]) && pos > 0) + { + strTrack = strFile[pos] + strTrack; + pos--; + } + } + + string strDrive = strFile.Substring(0, 1); + strDrive += ":"; + strFile = String.Format("{0}Track{1}.cda", strDrive, strTrack); + _isCDA = true; + } + try + { + m_bStoppedManualy = false; + // check if the player is running, if not run it. + startPlayerIfNecessary(); + + string playListName = "MPPlaylist"; + Win32API.COPYDATASTRUCT cds; + cds.dwData = (IntPtr)1; // find/create playlist + cds.lpData = Marshal.StringToCoTaskMemAnsi(playListName); + cds.cbData = playListName.Length + 1; + + // create the playlist or switch to it if there + int index = Win32API.SendMessage(m_hwndPlugin, WM_COPYDATA, 0, ref cds); + Marshal.FreeCoTaskMem(cds.lpData); + + // set the playlist as the active one + Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_SETACTIVEPLAYLIST, index); + + // Clear playlist + Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_CLEARPLAYLIST, 0); + + + Encoding encode = Encoding.Default; + // Let's encode the filename so any extended ASCII character is played correctly + // by the Foobar Plugin + byte[] byData = encode.GetBytes(HttpUtility.UrlEncode(strFile).Replace("+", "%20")); + cds.dwData = (IntPtr)0; // Play song + cds.lpData = Marshal.AllocCoTaskMem(byData.Length + 1); + cds.cbData = byData.Length + 1; + // write all the bytes to the lpData byte by byte + for (int i = 0; i < byData.Length; ++i) + { + Marshal.WriteByte(cds.lpData, i, byData[i]); + } + // write the end of string '\0' + Marshal.WriteByte(cds.lpData, byData.Length, (byte)0); + if (Win32API.SendMessage(m_hwndPlugin, WM_COPYDATA, 0, ref cds) == 0) + { + Marshal.FreeCoTaskMem(cds.lpData); + Thread.Sleep(1000); // wait for 1 secs so that foobar starts playing + m_strCurrentFile = strFile; + _notifyPlaying = true; + return true; + } + else + { + _notifyPlaying = false; + Marshal.FreeCoTaskMem(cds.lpData); + return false; + } + } + catch + { + return false; + } + } + + /// <summary> + /// This method returns the Duration of the current song that is been played + /// </summary> + public override double Duration + { + get { return Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_GETPLAYLENGTH, 0); } + } + + /// <summary> + /// This method returns the current play back time of the song + /// </summary> + public override double CurrentPosition + { + get { return Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_GETPLAYBACKTIME, 0); } + } + + + /// <summary> + /// This method pauses the currently played song + /// </summary> + public override void Pause() + { + // pause + Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_PAUSE, 0); + } + + /// <summary> + /// This method returns if the player is in paused state + /// </summary> + public override bool Paused + { + get + { + int state = Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_GETSTATE, 0); + return (state == 1); + } + } + + + /// <summary> + /// This method returns if the player is in playing state + /// </summary> + public override bool Playing + { + get + { + int state = Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_GETSTATE, 0); + return (state == 0); + } + } + + + public override bool Ended + { + get + { + if (m_bStoppedManualy) + { + return false; + } + + int state = Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_GETSTATE, 0); + return (state == 2); + } + } + + public override void Dispose() + { + + } + + + /// <summary> + /// This method returns if the player is in stop state + /// </summary> + public override bool Stopped + { + get + { + if (!m_bStoppedManualy) + { + return false; + } + int state = Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_GETSTATE, 0); + return (state == 2); + } + } + + + /// <summary> + /// This method returns the file that is been played + /// </summary> + public override string CurrentFile + { + get { return m_strCurrentFile; } + } + + /// <summary> + /// This method stops the player from the played song + /// </summary> + public override void Stop() + { + m_bStoppedManualy = true; + Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_STOP, 0); + _notifyPlaying = false; + } + + + /// <summary> + /// Volume property for the player + /// </summary> + public override int Volume + { + // GetVolume + get + { + return Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_GETVOLUME, 0); + } + set + { + Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_SETVOLUME, value); + } + } + + /// <summary> + /// Seek a relative time in the song from the current position + /// </summary> + /// <param name="dTime">time in seconds</param> + public override void SeekRelative(double dTime) + { + try + { + double dCurTime = CurrentPosition; + dTime = dCurTime + dTime; + if (dTime < 0.0d) + { + dTime = 0.0d; + } + if (dTime < Duration) + { + Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_SEEK, (int)dTime); + } + } + catch { } + } + + /// <summary> + /// Seek a time in the song from the beginning of the song + /// </summary> + /// <param name="dTime">time in seconds</param> + public override void SeekAbsolute(double dTime) + { + try + { + // seek + if (dTime < 0.0d) + { + dTime = 0.0d; + } + if (dTime < Duration) + { + Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_SEEK, (int)dTime); + } + } + catch { } + } + + /// <summary> + /// Seek a relative time in the song from the current position as a percentage + /// </summary> + /// <param name="iPercentage">percentage amount</param> + public override void SeekRelativePercentage(int iPercentage) + { + double dCurrentPos = CurrentPosition; + double dDuration = Duration; + + double fCurPercent = (dCurrentPos / Duration) * 100.0d; + double fOnePercent = Duration / 100.0d; + fCurPercent = fCurPercent + (double)iPercentage; + fCurPercent *= fOnePercent; + if (fCurPercent < 0.0d) + { + fCurPercent = 0.0d; + } + if (fCurPercent < Duration) + { + try + { + Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_SEEK, (int)fCurPercent); + } + catch { } + } + } + + /// <summary> + /// Seek a time in the song from the beginning of the song as a percentage + /// </summary> + /// <param name="iPercentage">percentage amount</param> + public override void SeekAsolutePercentage(int iPercentage) + { + if (iPercentage < 0) + { + iPercentage = 0; + } + if (iPercentage >= 100) + { + iPercentage = 100; + } + double fPercent = Duration / 100.0f; + fPercent *= (double)iPercentage; + try + { + Win32API.SendMessageA(m_hwndPlugin, WM_HTTPSERVER_MSG_CMD, WM_HTTPSERVER_MSG_SEEK, (int)fPercent); + } + catch { } + } + + + /// <summary> + /// The main entry point for testing this class stand alone. + /// </summary> + [STAThread] + private static void Main(string[] args) + { + // + // TODO: Add code to start application here + // + FoobarPlugin plugin = new FoobarPlugin(); + plugin.Stop(); + } + + public override void Process() + { + if (!Playing) + { + return; + } + + if (_notifyPlaying && CurrentPosition >= 10.0) + { + _notifyPlaying = false; + GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYING_10SEC, 0, 0, 0, 0, 0, null); + msg.Label = CurrentFile; + GUIWindowManager.SendThreadMessage(msg); + } + } + + public override bool IsCDA + { + get { return _isCDA; } + } + } + + // public class FoobarPlugin : MediaPortal.Player.IExternalPlayer +} \ No newline at end of file Added: trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/Properties/AssemblyInfo.cs (rev 0) +++ trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/Properties/AssemblyInfo.cs 2010-11-14 15:51:46 UTC (rev 3935) @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die mit einer Assembly verknüpft sind. +[assembly: AssemblyTitle("FoobarExternalPlayers")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("FoobarExternalPlayers")] +[assembly: AssemblyCopyright("Copyright © 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar +// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von +// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("af1e0c52-abc6-4685-9a4f-af6d6c9a59a6")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Added: trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/foobarlogo.png =================================================================== (Binary files differ) Property changes on: trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/foobarlogo.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/foobarlogodisabled.png =================================================================== (Binary files differ) Property changes on: trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers/foobarlogodisabled.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers.sln =================================================================== --- trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers.sln (rev 0) +++ trunk/plugins/FoobarExternalPlayers/FoobarExternalPlayers.sln 2010-11-14 15:51:46 UTC (rev 3935) @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoobarExternalPlayers", "FoobarExternalPlayers\FoobarExternalPlayers.csproj", "{D4BB2A55-2F02-4AB2-B86C-891388E3C616}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSect... [truncated message content] |