Addon renamed to Extension everywhere

This commit is contained in:
Frank Skare
2019-07-25 01:34:36 +02:00
parent 005550af55
commit d96587cb7b
23 changed files with 62 additions and 237 deletions

View File

@@ -83,7 +83,7 @@
mpv.net not appearing in the 'Open with' menu of the Windows File Explorer, mpv.net not appearing in the 'Open with' menu of the Windows File Explorer,
thanks to 44vince44 for pointing this out!!! thanks to 44vince44 for pointing this out!!!
- new Python and C# script examples were added to the wiki and the scripting and - new Python and C# script examples were added to the wiki and the scripting and
add-on documentation was improved extension documentation was improved
- invalid command line arguments were ignored, now an error message is shown - invalid command line arguments were ignored, now an error message is shown
- a description on how to start mpv.net from Google Chrome was added to the - a description on how to start mpv.net from Google Chrome was added to the
manual, it's useful to play videos from sites like YouTube, find the manual, it's useful to play videos from sites like YouTube, find the

View File

@@ -37,7 +37,7 @@ Table of contents
- [Context Menu](#context-menu) - [Context Menu](#context-menu)
- [Settings](#settings) - [Settings](#settings)
- [Scripting](#scripting) - [Scripting](#scripting)
- [Add-ons](#add-ons) - [Extensions](#extensions)
- [Architecture](#architecture) - [Architecture](#architecture)
- [Support](#support) - [Support](#support)
- [Links](#links) - [Links](#links)
@@ -55,7 +55,7 @@ Table of contents
- Configuration files that are easy to read and edit - Configuration files that are easy to read and edit
- Searchable command palette to quickly launch commands and look for keys ([Screenshot](#command-palette-screenshot)) - Searchable command palette to quickly launch commands and look for keys ([Screenshot](#command-palette-screenshot))
- Modern WPF based graphical user interface with dark mode ([Screenshot](#config-editor-screenshot)) - Modern WPF based graphical user interface with dark mode ([Screenshot](#config-editor-screenshot))
- Addon/extension API for .NET languages - Extension API for .NET languages
- Scripting API for Python, C#, Lua, JavaScript and PowerShell ([Wiki](https://github.com/stax76/mpv.net/wiki/Scripting)) - Scripting API for Python, C#, Lua, JavaScript and PowerShell ([Wiki](https://github.com/stax76/mpv.net/wiki/Scripting))
- Language agnostic JSON IPC to control the player with a external programs - Language agnostic JSON IPC to control the player with a external programs
- On Screen Controler (OSC, play control buttons) - On Screen Controler (OSC, play control buttons)
@@ -167,9 +167,9 @@ mpv.net supports almost all mpv settings and features,
[Scripting wiki page](https://github.com/stax76/mpv.net/wiki/Scripting) [Scripting wiki page](https://github.com/stax76/mpv.net/wiki/Scripting)
### Add-ons ### Extensions
[Add-on wiki page](https://github.com/stax76/mpv.net/wiki/Addons) [Extensions wiki page](https://github.com/stax76/mpv.net/wiki/Extensions)
### Architecture ### Architecture
@@ -183,7 +183,7 @@ was difficult to build, the hard parts are totally covered by libmpv.
mpv.net is written in C# 7 and runs on .NET 4.7, I've not yet decided mpv.net is written in C# 7 and runs on .NET 4.7, I've not yet decided
if I will port it to C# 8 and .NET 5 once available. if I will port it to C# 8 and .NET 5 once available.
The Add-on implementation is based on the [Managed Extensibility Framework](https://docs.microsoft.com/en-us/dotnet/framework/mef/). The Extension implementation is based on the [Managed Extensibility Framework](https://docs.microsoft.com/en-us/dotnet/framework/mef/).
There are no specific extension or scripting interfaces but instead everyting There are no specific extension or scripting interfaces but instead everyting
is accessible for .NET compatible languages (C#, VB.NET, F#, Python, PowerShell), is accessible for .NET compatible languages (C#, VB.NET, F#, Python, PowerShell),

View File

@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 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("TestAddon")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestAddon")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("06f854b0-00f9-4b53-94d9-0be65a7c55d8")]
// 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 Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,27 +0,0 @@
using System.ComponentModel.Composition;
using mpvnet;
namespace TestAddon
{
[Export(typeof(IAddon))]
public class TestAddon : IAddon
{
// do some init work in constructor
public TestAddon()
{
// Observe changes of the fullscreen property.
// You can find a list of available mpv properties
// in mpv.net's wiki on github or use mpv --list-properties.
// You can test properties in mpv.net in the menu at:
// Tools > Execute mpv command
// where you can enter: show-text ${fullscreen}
mp.observe_property_bool("fullscreen", OnFullscreenChange);
}
void OnFullscreenChange(bool val)
{
mp.commandv("show-text", "fullscreen: " + val.ToString());
}
}
}

View File

@@ -1,92 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TestAddon</RootNamespace>
<AssemblyName>TestAddon</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</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\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="TestAddon.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\mpv.net\mpv.net.csproj">
<Project>{1751f378-8edf-4b62-be6d-304c7c287089}</Project>
<Name>mpv.net</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -1,4 +1,4 @@
'this addon implements the C# scripting feature of mpv.net, 'this extension implements the C# scripting feature of mpv.net,
'it is based on CS-Script: https://www.cs-script.net/ 'it is based on CS-Script: https://www.cs-script.net/
Imports System.ComponentModel.Composition Imports System.ComponentModel.Composition
@@ -9,9 +9,9 @@ Imports mpvnet
Imports CSScriptLibrary Imports CSScriptLibrary
<Export(GetType(IAddon))> <Export(GetType(IExtension))>
Public Class CSScriptAddon Public Class CSScriptExtension
Implements IAddon Implements IExtension
Sub New() Sub New()
Dim scriptFiles As New List(Of String) Dim scriptFiles As New List(Of String)

View File

@@ -6,8 +6,8 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{71808A87-8B1C-4DF8-957C-D79C3B164CCA}</ProjectGuid> <ProjectGuid>{71808A87-8B1C-4DF8-957C-D79C3B164CCA}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>CSScriptAddon</RootNamespace> <RootNamespace>CSScriptExtension</RootNamespace>
<AssemblyName>CSScriptAddon</AssemblyName> <AssemblyName>CSScriptExtension</AssemblyName>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<MyType>Windows</MyType> <MyType>Windows</MyType>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
@@ -51,7 +51,7 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DefineDebug>true</DefineDebug> <DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace> <DefineTrace>true</DefineTrace>
<OutputPath>..\..\mpv.net\bin\x86\Addons\CSScriptAddon\</OutputPath> <OutputPath>..\..\mpv.net\bin\x86\Extensions\CSScriptExtension\</OutputPath>
<NoWarn>42105,42106,42107,42353,42354,42355</NoWarn> <NoWarn>42105,42106,42107,42353,42354,42355</NoWarn>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@@ -60,7 +60,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<DefineTrace>true</DefineTrace> <DefineTrace>true</DefineTrace>
<OutputPath>..\mpv.net\bin\x86\Addons\CSScriptAddon\</OutputPath> <OutputPath>..\..\mpv.net\bin\x86\Extensions\CSScriptExtension\</OutputPath>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>42105,42106,42107,42353,42354,42355</NoWarn> <NoWarn>42105,42106,42107,42353,42354,42355</NoWarn>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -72,7 +72,7 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DefineDebug>true</DefineDebug> <DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace> <DefineTrace>true</DefineTrace>
<OutputPath>..\..\mpv.net\bin\x64\Addons\CSScriptAddon\</OutputPath> <OutputPath>..\..\mpv.net\bin\x64\Extensions\CSScriptExtension\</OutputPath>
<NoWarn>42105,42106,42107,42353,42354,42355</NoWarn> <NoWarn>42105,42106,42107,42353,42354,42355</NoWarn>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
@@ -81,7 +81,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<DefineTrace>true</DefineTrace> <DefineTrace>true</DefineTrace>
<OutputPath>..\mpv.net\bin\x64\Addons\CSScriptAddon\</OutputPath> <OutputPath>..\..\mpv.net\bin\x64\Extensions\CSScriptExtension\</OutputPath>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>42105,42106,42107,42353,42354,42355</NoWarn> <NoWarn>42105,42106,42107,42353,42354,42355</NoWarn>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -116,7 +116,7 @@
<Import Include="System.Threading.Tasks" /> <Import Include="System.Threading.Tasks" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CSScriptAddon.vb" /> <Compile Include="CSScriptExtension.vb" />
<Compile Include="My Project\AssemblyInfo.vb" /> <Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb"> <Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>

View File

@@ -8,11 +8,11 @@ Imports System.Runtime.InteropServices
' Review the values of the assembly attributes ' Review the values of the assembly attributes
<Assembly: AssemblyTitle("CSScriptAddon")> <Assembly: AssemblyTitle("CSScriptExtension")>
<Assembly: AssemblyDescription("")> <Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")> <Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("CSScriptAddon")> <Assembly: AssemblyProduct("CSScriptExtension")>
<Assembly: AssemblyCopyright("Copyright © 2019")> <Assembly: AssemblyCopyright("Copyright © 2017-2019 Frank Skare (stax76)")>
<Assembly: AssemblyTrademark("")> <Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>

View File

@@ -22,7 +22,7 @@ Namespace My.Resources
'''<summary> '''<summary>
''' A strongly-typed resource class, for looking up localized strings, etc. ''' A strongly-typed resource class, for looking up localized strings, etc.
'''</summary> '''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0"), _ <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _ Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
@@ -39,7 +39,7 @@ Namespace My.Resources
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get Get
If Object.ReferenceEquals(resourceMan, Nothing) Then If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("CSScriptAddon.Resources", GetType(Resources).Assembly) Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("CSScriptExtension.Resources", GetType(Resources).Assembly)
resourceMan = temp resourceMan = temp
End If End If
Return resourceMan Return resourceMan

View File

@@ -15,7 +15,7 @@ Option Explicit On
Namespace My Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0"), _ Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.1.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase Inherits Global.System.Configuration.ApplicationSettingsBase
@@ -64,9 +64,9 @@ Namespace My
Friend Module MySettingsProperty Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _ <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.CSScriptAddon.My.MySettings Friend ReadOnly Property Settings() As Global.CSScriptExtension.My.MySettings
Get Get
Return Global.CSScriptAddon.My.MySettings.Default Return Global.CSScriptExtension.My.MySettings.Default
End Get End Get
End Property End Property
End Module End Module

View File

@@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("RatingAddon")] [assembly: AssemblyTitle("RatingExtension")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RatingAddon")] [assembly: AssemblyProduct("RatingExtension")]
[assembly: AssemblyCopyright("Copyright © 2017")] [assembly: AssemblyCopyright("Copyright © 2017-2019 Frank Skare (stax76)")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]

View File

@@ -1,23 +1,19 @@
// sometimes the add-on don't work, it's containing a lot of trace code at the moment using System;
using System;
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using mpvnet; using mpvnet;
using System.Diagnostics;
// the assembly name must end with 'Addon' namespace RatingExtension // the assembly name must end with 'Extension'
namespace RatingAddon
{ {
[Export(typeof(IAddon))] [Export(typeof(IExtension))]
public class RatingAddon : IAddon public class RatingExtension : IExtension
{ {
// dictionory to store the filename and the rating // dictionory to store the filename and the rating
Dictionary<string, int> Dic = new Dictionary<string, int>(); Dictionary<string, int> Dic = new Dictionary<string, int>();
public RatingAddon() // plugin initialization public RatingExtension() // plugin initialization
{ {
mp.ClientMessage += ClientMessage; //handles keys defined in input.conf mp.ClientMessage += ClientMessage; //handles keys defined in input.conf
mp.Shutdown += Shutdown; // handles MPV_EVENT_SHUTDOWN mp.Shutdown += Shutdown; // handles MPV_EVENT_SHUTDOWN
@@ -26,16 +22,12 @@ namespace RatingAddon
// handles MPV_EVENT_SHUTDOWN // handles MPV_EVENT_SHUTDOWN
void Shutdown() void Shutdown()
{ {
if (App.DebugMode) Trace.WriteLine("aaa");
foreach (var i in Dic) foreach (var i in Dic)
{ {
string filepath = i.Key; string filepath = i.Key;
int rating = i.Value; int rating = i.Value;
if (App.DebugMode) Trace.WriteLine("bbb");
if (String.IsNullOrEmpty(filepath) || ! File.Exists(filepath)) if (String.IsNullOrEmpty(filepath) || ! File.Exists(filepath))
return; return;
if (App.DebugMode) Trace.WriteLine("ccc");
string basename = Path.GetFileNameWithoutExtension(filepath); string basename = Path.GetFileNameWithoutExtension(filepath);
for (int x = 0; x < 6; x++) for (int x = 0; x < 6; x++)
@@ -44,12 +36,9 @@ namespace RatingAddon
basename += $" ({rating}stars)"; basename += $" ({rating}stars)";
string newPath = Path.Combine(Path.GetDirectoryName(filepath), basename + Path.GetExtension(filepath)); string newPath = Path.Combine(Path.GetDirectoryName(filepath), basename + Path.GetExtension(filepath));
if (App.DebugMode) Trace.WriteLine("ddd");
if (filepath.ToLower() != newPath.ToLower()) if (filepath.ToLower() != newPath.ToLower())
File.Move(filepath, newPath); File.Move(filepath, newPath);
if (App.DebugMode) Trace.WriteLine("eee");
File.SetLastWriteTime(newPath, DateTime.Now); File.SetLastWriteTime(newPath, DateTime.Now);
if (App.DebugMode) Trace.WriteLine("fff");
} }
} }
@@ -66,7 +55,7 @@ namespace RatingAddon
mp.commandv("show-text", $"Rating: {rating}"); mp.commandv("show-text", $"Rating: {rating}");
} }
else if (args[1] == "about") else if (args[1] == "about")
Msg.Show("Rating Extension", "This extension writes a rating to the filename of rated videos when mpv.net shuts down.\n\nThe input.conf defaults contain key bindings for this addon to set ratings."); Msg.Show("Rating Extension", "This extension writes a rating to the filename of rated videos when mpv.net shuts down.\n\nThe input.conf defaults contain key bindings for this extension to set ratings.");
} }
} }
} }

View File

@@ -7,8 +7,8 @@
<ProjectGuid>{55C88710-539D-4402-84C8-31694841C731}</ProjectGuid> <ProjectGuid>{55C88710-539D-4402-84C8-31694841C731}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RatingAddon</RootNamespace> <RootNamespace>RatingExtension</RootNamespace>
<AssemblyName>RatingAddon</AssemblyName> <AssemblyName>RatingExtension</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
@@ -32,7 +32,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\mpv.net\bin\x86\Addons\RatingAddon\</OutputPath> <OutputPath>..\..\mpv.net\bin\x86\Extensions\RatingExtension\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@@ -40,7 +40,7 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>..\mpv.net\bin\x86\Addons\RatingAddon\</OutputPath> <OutputPath>..\..\mpv.net\bin\x86\Extensions\RatingExtension\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -50,7 +50,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\mpv.net\bin\x64\Addons\RatingAddon\</OutputPath> <OutputPath>..\..\mpv.net\bin\x64\Extensions\RatingExtension\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
@@ -58,7 +58,7 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\mpv.net\bin\x64\Addons\RatingAddon\</OutputPath> <OutputPath>..\..\mpv.net\bin\x64\Extensions\RatingExtension\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -78,7 +78,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="RatingAddon.cs" /> <Compile Include="RatingExtension.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -5,11 +5,9 @@ VisualStudioVersion = 16.0.28729.10
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mpv.net", "mpv.net\mpv.net.csproj", "{1751F378-8EDF-4B62-BE6D-304C7C287089}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mpv.net", "mpv.net\mpv.net.csproj", "{1751F378-8EDF-4B62-BE6D-304C7C287089}"
EndProject EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CSScriptAddon", "addons\CSScriptAddon\CSScriptAddon.vbproj", "{71808A87-8B1C-4DF8-957C-D79C3B164CCA}" Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CSScriptExtension", "extensions\CSScriptExtension\CSScriptExtension.vbproj", "{71808A87-8B1C-4DF8-957C-D79C3B164CCA}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RatingAddon", "addons\RatingAddon\RatingAddon.csproj", "{55C88710-539D-4402-84C8-31694841C731}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RatingExtension", "extensions\RatingExtension\RatingExtension.csproj", "{55C88710-539D-4402-84C8-31694841C731}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAddon", "addons\TestAddon\TestAddon.csproj", "{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -57,18 +55,6 @@ Global
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.Build.0 = Release|x64 {55C88710-539D-4402-84C8-31694841C731}.Release|x64.Build.0 = Release|x64
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.ActiveCfg = Release|x86 {55C88710-539D-4402-84C8-31694841C731}.Release|x86.ActiveCfg = Release|x86
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.Build.0 = Release|x86 {55C88710-539D-4402-84C8-31694841C731}.Release|x86.Build.0 = Release|x86
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Debug|x64.ActiveCfg = Debug|x64
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Debug|x64.Build.0 = Debug|x64
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Debug|x86.ActiveCfg = Debug|x86
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Debug|x86.Build.0 = Debug|x86
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Release|Any CPU.Build.0 = Release|Any CPU
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Release|x64.ActiveCfg = Release|Any CPU
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Release|x64.Build.0 = Release|Any CPU
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Release|x86.ActiveCfg = Release|Any CPU
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -7,30 +7,30 @@ using System.Windows.Forms;
namespace mpvnet namespace mpvnet
{ {
public class Addon public class Extension
{ {
[ImportMany] [ImportMany]
public IEnumerable<IAddon> Addons = null; public IEnumerable<IExtension> Extensions = null;
readonly CompositionContainer CompositionContainer; readonly CompositionContainer CompositionContainer;
public Addon() public Extension()
{ {
try try
{ {
AggregateCatalog catalog = new AggregateCatalog(); AggregateCatalog catalog = new AggregateCatalog();
string dir = Application.StartupPath + "\\Addons"; string dir = Application.StartupPath + "\\Extensions";
if (Directory.Exists(dir)) if (Directory.Exists(dir))
foreach (string i in Directory.GetDirectories(dir)) foreach (string i in Directory.GetDirectories(dir))
catalog.Catalogs.Add(new DirectoryCatalog(i, "*Addon.dll")); catalog.Catalogs.Add(new DirectoryCatalog(i, "*Extensions.dll"));
dir = mp.ConfigFolder + "\\Addons"; dir = mp.ConfigFolder + "\\Extensions";
if (Directory.Exists(dir)) if (Directory.Exists(dir))
foreach (string i in Directory.GetDirectories(dir)) foreach (string i in Directory.GetDirectories(dir))
catalog.Catalogs.Add(new DirectoryCatalog(i, "*Addon.dll")); catalog.Catalogs.Add(new DirectoryCatalog(i, "*Extension.dll"));
if (catalog.Catalogs.Count > 0) if (catalog.Catalogs.Count > 0)
{ {
@@ -45,7 +45,7 @@ namespace mpvnet
} }
} }
public interface IAddon public interface IExtension
{ {
} }
} }

View File

@@ -57,6 +57,7 @@ namespace mpvnet
if (File.Exists(filePath)) File.Delete(filePath); if (File.Exists(filePath)) File.Delete(filePath);
Trace.Listeners.Add(new TextWriterTraceListener(filePath)); Trace.Listeners.Add(new TextWriterTraceListener(filePath));
Trace.AutoFlush = true; Trace.AutoFlush = true;
//if (App.DebugMode) Trace.WriteLine("");
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -560,8 +560,12 @@ namespace mpvnet
} }
RegHelp.SetObject(App.RegPath, "Recent", RecentFiles.ToArray()); RegHelp.SetObject(App.RegPath, "Recent", RecentFiles.ToArray());
mp.commandv("quit");
mp.ShutdownAutoResetEvent.WaitOne(3000); if (mp.IsQuitNeeded)
mp.commandv("quit");
if (!mp.ShutdownAutoResetEvent.WaitOne(10000))
Msg.ShowError("Shutdown thread failed to complete within 10 seconds.");
} }
protected override void OnMouseDown(MouseEventArgs e) protected override void OnMouseDown(MouseEventArgs e)

View File

@@ -56,8 +56,9 @@ namespace mpvnet
public static IntPtr Handle { get; set; } public static IntPtr Handle { get; set; }
public static IntPtr WindowHandle { get; set; } public static IntPtr WindowHandle { get; set; }
public static Addon Addon { get; set; } public static Extension Extension { get; set; }
public static bool IsLogoVisible { set; get; } public static bool IsLogoVisible { set; get; }
public static bool IsQuitNeeded { set; get; } = true;
public static List<KeyValuePair<string, Action<bool>>> BoolPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<bool>>>(); public static List<KeyValuePair<string, Action<bool>>> BoolPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<bool>>>();
public static List<KeyValuePair<string, Action<int>>> IntPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<int>>>(); public static List<KeyValuePair<string, Action<int>>> IntPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<int>>>();
public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<string>>>(); public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<string>>>();
@@ -98,7 +99,7 @@ namespace mpvnet
ShowLogo(); ShowLogo();
ProcessCommandLine(); ProcessCommandLine();
Task.Run(() => { LoadScripts(); }); Task.Run(() => { LoadScripts(); });
Task.Run(() => { Addon = new Addon(); }); Task.Run(() => { Extension = new Extension(); });
Task.Run(() => { EventLoop(); }); Task.Run(() => { EventLoop(); });
} }
@@ -249,9 +250,8 @@ namespace mpvnet
switch (evt.event_id) switch (evt.event_id)
{ {
case mpv_event_id.MPV_EVENT_SHUTDOWN: case mpv_event_id.MPV_EVENT_SHUTDOWN:
if (App.DebugMode) Trace.WriteLine("before Shutdown.Invoke"); IsQuitNeeded = false;
Shutdown?.Invoke(); Shutdown?.Invoke();
if (App.DebugMode) Trace.WriteLine("after Shutdown.Invoke");
WriteHistory(null); WriteHistory(null);
ShutdownAutoResetEvent.Set(); ShutdownAutoResetEvent.Set();
return; return;