From: <an...@us...> - 2007-07-01 14:32:12
|
Revision: 661 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=661&view=rev Author: and-81 Date: 2007-07-01 07:32:00 -0700 (Sun, 01 Jul 2007) Log Message: ----------- Plays RAR files, but needs a lot of improvement Added Paths: ----------- trunk/plugins/RarPlayer/ trunk/plugins/RarPlayer/AssemblyInfo.cs trunk/plugins/RarPlayer/RarPlayer Plugin.csproj trunk/plugins/RarPlayer/RarPlayer.cs trunk/plugins/RarPlayer/ReadMe.txt Added: trunk/plugins/RarPlayer/AssemblyInfo.cs =================================================================== --- trunk/plugins/RarPlayer/AssemblyInfo.cs (rev 0) +++ trunk/plugins/RarPlayer/AssemblyInfo.cs 2007-07-01 14:32:00 UTC (rev 661) @@ -0,0 +1,63 @@ +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security.Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("RarPlayer Plugin")] +[assembly: AssemblyDescription("Decompresses RAR files for playback")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("and-81")] +[assembly: AssemblyProduct("MediaPortal")] +[assembly: AssemblyCopyright("Aaron Dinnage")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.2.0")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\<setupForm>. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] +[assembly: ComVisibleAttribute(false)] +[assembly: AssemblyFileVersionAttribute("1.0.2.0")] Added: trunk/plugins/RarPlayer/RarPlayer Plugin.csproj =================================================================== --- trunk/plugins/RarPlayer/RarPlayer Plugin.csproj (rev 0) +++ trunk/plugins/RarPlayer/RarPlayer Plugin.csproj 2007-07-01 14:32:00 UTC (rev 661) @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{88520E4C-5C49-478A-8AFA-959B45075922}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>MediaPortal.Plugins</RootNamespace> + <AssemblyName>RarPlayer</AssemblyName> + <StartupObject> + </StartupObject> + <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>false</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <UseVSHostingProcess>false</UseVSHostingProcess> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>none</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants> + </DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <UseVSHostingProcess>false</UseVSHostingProcess> + </PropertyGroup> + <Import Project="$(MSBuildBinPath)\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> + --> + <ItemGroup> + <Compile Include="AssemblyInfo.cs" /> + <Compile Include="RarPlayer.cs" /> + </ItemGroup> + <ItemGroup> + <Reference Include="Core, Version=0.2.2.9991, Culture=neutral, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\MediaPortal 0.2.3.0\Core.DLL</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + <Reference Include="Utils, Version=0.2.2.9991, Culture=neutral, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\MediaPortal 0.2.3.0\Utils.DLL</HintPath> + <Private>False</Private> + </Reference> + </ItemGroup> + <PropertyGroup> + <PostBuildEvent>copy "*.*" "\MediaPortal Development\Plugin Releases\RarPlayer Plugin\Release\"</PostBuildEvent> + </PropertyGroup> +</Project> \ No newline at end of file Added: trunk/plugins/RarPlayer/RarPlayer.cs =================================================================== --- trunk/plugins/RarPlayer/RarPlayer.cs (rev 0) +++ trunk/plugins/RarPlayer/RarPlayer.cs 2007-07-01 14:32:00 UTC (rev 661) @@ -0,0 +1,117 @@ +using System; +using System.IO; +using System.Diagnostics; + +using MediaPortal.Player; +using MediaPortal.GUI.Library; +using MediaPortal.Util; + +namespace MediaPortal.Plugins +{ + + public class RarPlayerPlugin : IExternalPlayer, ISetupForm + { + + #region Variables + + string _currentPlayedFile = null; + + #endregion Variables + + #region IExternalPlayer Members + + public override string AuthorName { get { return "and-81"; } } + public override string[] GetAllSupportedExtensions() { return new string[] { ".rar" }; } + public override string PlayerName { get { return "RarPlayer"; } } + public override bool SupportsFile(string filename) { return filename.EndsWith(".rar", StringComparison.InvariantCultureIgnoreCase); } + public override string VersionNumber { get { return "1.0.3.2"; } } + + #endregion IExternalPlayer Members + + #region ISetupForm Members + + public new bool CanEnable() { return true; } + public new bool DefaultEnabled() { return true; } + public override string Description() { return "Decompresses RAR files for playback"; } + public new bool HasSetup() { return false; } + public override void ShowPlugin() { } + + #endregion + + #region IPlayer Members + + public override bool Play(string strFile) + { + string tempFolder = Path.GetTempPath(); + + UnRar(strFile, tempFolder); + + string movieFilename = Path.Combine(tempFolder, Path.GetFileNameWithoutExtension(strFile)); + + if (File.Exists(movieFilename)) + { + _currentPlayedFile = movieFilename; + GUIWindowManager.Receivers += new SendMessageHandler(GUIWindowManager_Receivers); + + PlayFile(movieFilename); + } + + return false; + } + + #endregion IPlayer Members + + #region Implementation + + void GUIWindowManager_Receivers(GUIMessage message) + { + if (message.Message == GUIMessage.MessageType.GUI_MSG_PLAYBACK_STOPPED) + { + if (!String.IsNullOrEmpty(_currentPlayedFile)) + { + Log.Info("RarPlayer: Deleting file {0}", _currentPlayedFile); + + File.Delete(_currentPlayedFile); + + _currentPlayedFile = null; + } + + GUIWindowManager.Receivers -= new SendMessageHandler(GUIWindowManager_Receivers); + } + } + + void UnRar(string filename, string outputFolder) + { + Log.Info("RarPlayer: UnRar file {0}", filename); + + string arguments = String.Format("e \"{0}\" -y -ep -o+ -- \"{1}\"", filename, outputFolder); + + Process process = new Process(); + process.StartInfo.FileName = "UnRAR.exe"; + process.StartInfo.WorkingDirectory = "."; + process.StartInfo.Arguments = arguments; + process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; + process.StartInfo.CreateNoWindow = true; + process.StartInfo.UseShellExecute = false; + + process.Start(); + + process.WaitForExit(); + } + + void PlayFile(string movieFilename) + { + Log.Info("RarPlayer: Play file {0}", movieFilename); + + GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAY_FILE, 0, 0, 0, 0, 0, null); + message.Label = movieFilename; + + GUIGraphicsContext.ResetLastActivity(); + GUIWindowManager.SendThreadMessage(message); + } + + #endregion Implementation + + } + +} Added: trunk/plugins/RarPlayer/ReadMe.txt =================================================================== --- trunk/plugins/RarPlayer/ReadMe.txt (rev 0) +++ trunk/plugins/RarPlayer/ReadMe.txt 2007-07-01 14:32:00 UTC (rev 661) @@ -0,0 +1,45 @@ +RarPlayer plugin +----------------------- +by and-81 + +This is a simple plugin that extracts a RAR file to a temporary location +for playback in MediaPortal. + +This is not a perfect solution. It does not play the file from within the +archive, it temporarily extracts it. It requires particular file naming +to work. + +I can improve it, but I don't really want to because I don't use RAR files. + +I am willing to make changes and improvements, but I'd prefer someone else +picked up the source code and made their own improvements. + +Source code is located in MediaPortal's plugin SVN. + + +Details: +===================== + +Here is an example of how the RAR file must be named: + +Movie.avi.rar + +With the file inside to play named "Movie.avi". + +I know this is a silly restriction, and I'll try to fix it later, but for +now you'll just have to deal with it. + + + +Installation: +===================== + +Copy RarPlayer.dll to "Team MediaPortal\MediaPortal\Plugins\ExternalPlayers\". +Copy UnRar.exe to "Team MediaPortal\MediaPortal\". +Go to MediaPortal Configuration and add ".rar" to the list of movie file extensions. + + + +Good luck, + + - Aaron. \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |