mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-28 09:15:46 +02:00
Remove audio library
This commit is contained in:
parent
bd92fc6ee0
commit
6e59dfddcc
@ -8,8 +8,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweetDuck.Browser", "subpro
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "tests\UnitTests.csproj", "{A958FA7A-4A2C-42A7-BFA0-159343483F4E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweetLib.Audio", "lib\TweetLib.Audio\TweetLib.Audio.csproj", "{E9E1FD1B-F480-45B7-9970-BE2ECFD309AC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweetDuck.Video", "video\TweetDuck.Video.csproj", "{278B2D11-402D-44B6-B6A1-8FA67DB65565}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweetLib.Communication", "lib\TweetLib.Communication\TweetLib.Communication.csproj", "{72473763-4B9D-4FB6-A923-9364B2680F06}"
|
||||
@ -32,10 +30,6 @@ Global
|
||||
{A958FA7A-4A2C-42A7-BFA0-159343483F4E}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{A958FA7A-4A2C-42A7-BFA0-159343483F4E}.Debug|x86.Build.0 = Debug|x86
|
||||
{A958FA7A-4A2C-42A7-BFA0-159343483F4E}.Release|x86.ActiveCfg = Release|x86
|
||||
{E9E1FD1B-F480-45B7-9970-BE2ECFD309AC}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{E9E1FD1B-F480-45B7-9970-BE2ECFD309AC}.Debug|x86.Build.0 = Debug|x86
|
||||
{E9E1FD1B-F480-45B7-9970-BE2ECFD309AC}.Release|x86.ActiveCfg = Release|x86
|
||||
{E9E1FD1B-F480-45B7-9970-BE2ECFD309AC}.Release|x86.Build.0 = Release|x86
|
||||
{278B2D11-402D-44B6-B6A1-8FA67DB65565}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{278B2D11-402D-44B6-B6A1-8FA67DB65565}.Debug|x86.Build.0 = Debug|x86
|
||||
{278B2D11-402D-44B6-B6A1-8FA67DB65565}.Release|x86.ActiveCfg = Release|x86
|
||||
|
@ -59,6 +59,7 @@ Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\Cache"
|
||||
Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\GPUCache"
|
||||
|
||||
[InstallDelete]
|
||||
Type: files; Name: "{app}\TweetLib.Audio.dll"
|
||||
Type: filesandordirs; Name: "{app}\plugins\official"
|
||||
Type: files; Name: "{app}\locales\am.pak"
|
||||
Type: files; Name: "{app}\locales\ar.pak"
|
||||
|
@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using TweetLib.Audio.Impl;
|
||||
|
||||
namespace TweetLib.Audio{
|
||||
public abstract class AudioPlayer : IDisposable{
|
||||
private static bool? IsWMPAvailable;
|
||||
|
||||
public static AudioPlayer New(){
|
||||
if (IsWMPAvailable.HasValue){
|
||||
if (IsWMPAvailable.Value){
|
||||
return new SoundPlayerImplWMP();
|
||||
}
|
||||
else{
|
||||
return new SoundPlayerImplFallback();
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
SoundPlayerImplWMP implWMP = new SoundPlayerImplWMP();
|
||||
IsWMPAvailable = true;
|
||||
return implWMP;
|
||||
}catch(COMException){
|
||||
IsWMPAvailable = false;
|
||||
return new SoundPlayerImplFallback();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract string SupportedFormats { get; }
|
||||
public abstract event EventHandler<PlaybackErrorEventArgs> PlaybackError;
|
||||
|
||||
public abstract void Play(string file);
|
||||
public abstract bool SetVolume(int volume);
|
||||
protected abstract void Dispose(bool disposing);
|
||||
|
||||
public void Dispose(){
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Media;
|
||||
|
||||
namespace TweetLib.Audio.Impl{
|
||||
sealed class SoundPlayerImplFallback : AudioPlayer{
|
||||
public override string SupportedFormats => "*.wav";
|
||||
|
||||
public override event EventHandler<PlaybackErrorEventArgs> PlaybackError;
|
||||
|
||||
private readonly SoundPlayer player;
|
||||
private bool ignorePlaybackError;
|
||||
|
||||
public SoundPlayerImplFallback(){
|
||||
player = new SoundPlayer{
|
||||
LoadTimeout = 5000
|
||||
};
|
||||
}
|
||||
|
||||
public override void Play(string file){
|
||||
if (player.SoundLocation != file){
|
||||
player.SoundLocation = file;
|
||||
ignorePlaybackError = false;
|
||||
}
|
||||
|
||||
try{
|
||||
player.Play();
|
||||
}catch(FileNotFoundException e){
|
||||
OnNotificationSoundError("File not found: "+e.FileName);
|
||||
}catch(InvalidOperationException){
|
||||
OnNotificationSoundError("File format was not recognized.");
|
||||
}catch(TimeoutException){
|
||||
OnNotificationSoundError("File took too long to load.");
|
||||
}
|
||||
}
|
||||
|
||||
public override bool SetVolume(int volume){
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing){
|
||||
player.Dispose();
|
||||
}
|
||||
|
||||
private void OnNotificationSoundError(string message){
|
||||
if (!ignorePlaybackError){
|
||||
PlaybackErrorEventArgs args = new PlaybackErrorEventArgs(message);
|
||||
PlaybackError?.Invoke(this, args);
|
||||
ignorePlaybackError = args.Ignore;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,124 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using WMPLib;
|
||||
|
||||
namespace TweetLib.Audio.Impl{
|
||||
sealed class SoundPlayerImplWMP : AudioPlayer{
|
||||
public override string SupportedFormats => "*.wav;*.mp3;*.mp2;*.m4a;*.mid;*.midi;*.rmi;*.wma;*.aif;*.aifc;*.aiff;*.snd;*.au";
|
||||
|
||||
public override event EventHandler<PlaybackErrorEventArgs> PlaybackError;
|
||||
|
||||
private readonly Form owner;
|
||||
private readonly ControlWMP wmp;
|
||||
private bool wasTryingToPlay;
|
||||
private bool ignorePlaybackError;
|
||||
|
||||
private WindowsMediaPlayer Player => wmp.Ocx;
|
||||
|
||||
public SoundPlayerImplWMP(){
|
||||
owner = new Form();
|
||||
wmp = new ControlWMP();
|
||||
wmp.BeginInit();
|
||||
owner.Controls.Add(wmp);
|
||||
wmp.EndInit();
|
||||
|
||||
Player.uiMode = "none";
|
||||
Player.settings.autoStart = false;
|
||||
Player.settings.enableErrorDialogs = false;
|
||||
Player.settings.invokeURLs = false;
|
||||
Player.settings.volume = 0;
|
||||
Player.MediaChange += player_MediaChange;
|
||||
Player.MediaError += player_MediaError;
|
||||
}
|
||||
|
||||
public override void Play(string file){
|
||||
wasTryingToPlay = true;
|
||||
|
||||
try{
|
||||
if (Player.URL != file){
|
||||
Player.close();
|
||||
Player.URL = file;
|
||||
ignorePlaybackError = false;
|
||||
}
|
||||
else{
|
||||
Player.controls.stop();
|
||||
}
|
||||
|
||||
Player.controls.play();
|
||||
}catch(Exception e){
|
||||
OnNotificationSoundError("An error occurred in Windows Media Player: "+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool SetVolume(int volume){
|
||||
Player.settings.volume = volume;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing){
|
||||
wmp.Dispose();
|
||||
owner.Dispose();
|
||||
}
|
||||
|
||||
private void player_MediaChange(object item){
|
||||
IWMPMedia2 media = item as IWMPMedia2;
|
||||
|
||||
if (media == null){
|
||||
OnNotificationSoundError("Unknown error.");
|
||||
return;
|
||||
}
|
||||
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
||||
else if (media.Error == null && media.duration == 0.0){
|
||||
OnNotificationSoundError("File does not contain an audio track.");
|
||||
}
|
||||
else if (media.Error != null){
|
||||
OnNotificationSoundError(media.Error);
|
||||
}
|
||||
|
||||
Marshal.ReleaseComObject(media);
|
||||
}
|
||||
|
||||
private void player_MediaError(object pMediaObject){
|
||||
IWMPMedia2 media = pMediaObject as IWMPMedia2;
|
||||
|
||||
if (media == null){
|
||||
OnNotificationSoundError("Unknown error.");
|
||||
return;
|
||||
}
|
||||
else if (media.Error != null){
|
||||
OnNotificationSoundError(media.Error);
|
||||
}
|
||||
|
||||
Marshal.ReleaseComObject(media);
|
||||
}
|
||||
|
||||
private void OnNotificationSoundError(IWMPErrorItem error){
|
||||
OnNotificationSoundError(error.errorCode == -1072885353 ? "Invalid media file." : error.errorDescription);
|
||||
Marshal.ReleaseComObject(error);
|
||||
}
|
||||
|
||||
private void OnNotificationSoundError(string message){
|
||||
if (wasTryingToPlay){
|
||||
wasTryingToPlay = false;
|
||||
|
||||
if (!ignorePlaybackError){
|
||||
PlaybackErrorEventArgs args = new PlaybackErrorEventArgs(message);
|
||||
PlaybackError?.Invoke(this, args);
|
||||
ignorePlaybackError = args.Ignore;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Clsid("{6bf52a52-394a-11d3-b153-00c04f79faa6}")]
|
||||
private sealed class ControlWMP : AxHost{
|
||||
public WindowsMediaPlayer Ocx { get; private set; }
|
||||
|
||||
public ControlWMP() : base("6bf52a52-394a-11d3-b153-00c04f79faa6"){}
|
||||
|
||||
protected override void AttachInterfaces(){
|
||||
Ocx = (WindowsMediaPlayer)GetOcx();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace TweetLib.Audio{
|
||||
public sealed class PlaybackErrorEventArgs : EventArgs{
|
||||
public string Message { get; }
|
||||
public bool Ignore { get; set; }
|
||||
|
||||
public PlaybackErrorEventArgs(string message){
|
||||
this.Message = message;
|
||||
this.Ignore = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
using System.Reflection;
|
||||
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("TweetDuck Audio Library")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TweetDuck Audio Library")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[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("e9e1fd1b-f480-45b7-9970-be2ecfd309ac")]
|
||||
|
||||
// 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.1.1.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.1.0")]
|
@ -1,50 +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)' == '' ">x86</Platform>
|
||||
<ProjectGuid>{E9E1FD1B-F480-45B7-9970-BE2ECFD309AC}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TweetLib.Audio</RootNamespace>
|
||||
<AssemblyName>TweetLib.Audio</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ResolveComReferenceSilent>True</ResolveComReferenceSilent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<Optimize>true</Optimize>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AudioPlayer.cs" />
|
||||
<Compile Include="PlaybackErrorEventArgs.cs" />
|
||||
<Compile Include="Impl\SoundPlayerImplFallback.cs" />
|
||||
<Compile Include="Impl\SoundPlayerImplWMP.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<COMReference Include="WMPLib">
|
||||
<Guid>{6BF52A50-394A-11D3-B153-00C04F79FAA6}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user