From: Latif Khalifa Date: Wed, 9 Sep 2009 06:46:18 +0000 (+0000) Subject: RAD-21: Added parcel audio stream player (windows only for now) X-Git-Tag: release-1.9~119 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4b67a9905af431272c1ae6fcbe5ed8283dbd26c0;p=radegast%2Fradegast.git RAD-21: Added parcel audio stream player (windows only for now) git-svn-id: https://radegast.googlecode.com/svn/trunk@211 f7a694da-4d33-11de-9ad6-1127a62b9fcd --- diff --git a/Radegast/Core/Media/MediaManager.cs b/Radegast/Core/Media/MediaManager.cs index ad5e5cc..f9cf85a 100644 --- a/Radegast/Core/Media/MediaManager.cs +++ b/Radegast/Core/Media/MediaManager.cs @@ -49,13 +49,13 @@ namespace Radegast.Media /// /// Parcel music stream player /// - public Sound ParcelMusic { get { return parcelMusic; } } + public Sound ParcelMusic { get { return parcelMusic; } set { parcelMusic = value; } } private Sound parcelMusic; public MediaManager(RadegastInstance instance) : base(null) { - if (instance.MonoRuntime) return; + if (Environment.OSVersion.Platform == PlatformID.Unix) return; try { @@ -66,11 +66,11 @@ namespace Radegast.Media if (version < FMOD.VERSION.number) throw new MediaException("You are using an old version of FMOD " + version.ToString("X") + ". This program requires " + FMOD.VERSION.number.ToString("X") + "."); + if (Environment.OSVersion.Platform == PlatformID.Unix) + FMODExec(system.setOutput(FMOD.OUTPUTTYPE.ESD)); FMODExec(system.init(100, FMOD.INITFLAG.NORMAL, (IntPtr)null)); FMODExec(system.setStreamBufferSize(64 * 1024, FMOD.TIMEUNIT.RAWBYTES)); - parcelMusic = new Sound(system); - soundSystemAvailable = true; Logger.Log("Initialized FMOD Ex", Helpers.LogLevel.Debug); } diff --git a/Radegast/Core/Media/MediaObject.cs b/Radegast/Core/Media/MediaObject.cs index c59b447..f83c9bb 100644 --- a/Radegast/Core/Media/MediaObject.cs +++ b/Radegast/Core/Media/MediaObject.cs @@ -55,11 +55,6 @@ namespace Radegast.Media public virtual void Dispose() { - if (system != null) - { - system.release(); - system = null; - } disposed = true; } } diff --git a/Radegast/Core/Media/Sound.cs b/Radegast/Core/Media/Sound.cs index 4abbffa..37020b6 100644 --- a/Radegast/Core/Media/Sound.cs +++ b/Radegast/Core/Media/Sound.cs @@ -37,6 +37,17 @@ using System.Runtime.InteropServices; namespace Radegast.Media { + public class StreamInfoArgs : EventArgs + { + public string Key; + public string Value; + + public StreamInfoArgs(string key, string value) + { + Key = key; + Value = value; + } + } public class Sound : MediaObject { @@ -70,6 +81,18 @@ namespace Radegast.Media public bool Paused { get { return paused; } } private bool paused = false; + /// + /// Fired when a stream meta data is received + /// + /// Sender + /// Key, value are sent in e + public delegate void StreamInfoCallback(object sender, StreamInfoArgs e); + + /// + /// Fired when a stream meta data is received + /// + public event StreamInfoCallback OnStreamInfo; + private bool soundcreated = false; private System.Timers.Timer timer; @@ -81,7 +104,7 @@ namespace Radegast.Media :base(system) { timer = new System.Timers.Timer(); - timer.Interval = 100d; + timer.Interval = 500d; timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); timer.Enabled = false; } @@ -115,9 +138,10 @@ namespace Radegast.Media { if (!soundcreated) { - system.createSound(url, (FMOD.MODE.HARDWARE | FMOD.MODE._2D | FMOD.MODE.CREATESTREAM | FMOD.MODE.NONBLOCKING), ref sound); + MediaManager.FMODExec(system.createSound(url, (FMOD.MODE.HARDWARE | FMOD.MODE._2D | FMOD.MODE.CREATESTREAM | FMOD.MODE.NONBLOCKING), ref sound)); soundcreated = true; timer.Enabled = true; + timer_Elapsed(null, null); } } @@ -133,6 +157,17 @@ namespace Radegast.Media } } + /// + /// Set or get current volume for this sound in range 0.0 - 1.0 + /// + public float Volume + { + set { volume = value; } + get { return volume; } + } + private float volume = 0.5f; + private float currentVolume; + void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { FMOD.OPENSTATE openstate = 0; @@ -148,11 +183,19 @@ namespace Radegast.Media if (openstate == FMOD.OPENSTATE.READY && channel == null) { MediaManager.FMODExec(system.playSound(FMOD.CHANNELINDEX.FREE, sound, false, ref channel)); + MediaManager.FMODExec(channel.setVolume(volume)); + currentVolume = volume; } } if (channel != null) { + if (currentVolume != volume) + { + currentVolume = volume; + MediaManager.FMODExec(channel.setVolume(volume)); + } + for (; ; ) { FMOD.TAG tag = new FMOD.TAG(); @@ -166,7 +209,9 @@ namespace Radegast.Media } else { - Logger.DebugLog("n" + tag.name + " = " + Marshal.PtrToStringAnsi(tag.data)); + if (OnStreamInfo != null) + try { OnStreamInfo(this, new StreamInfoArgs(tag.name.ToLower(), Marshal.PtrToStringAnsi(tag.data))); } + catch (Exception) { } } } diff --git a/Radegast/Core/Types/DettachableControl.cs b/Radegast/Core/Types/DettachableControl.cs index 4f03586..b3266d7 100644 --- a/Radegast/Core/Types/DettachableControl.cs +++ b/Radegast/Core/Types/DettachableControl.cs @@ -47,6 +47,11 @@ namespace Radegast protected Control OriginalParent; protected Size AttachedSize; + /// + /// If in detached state and detached form is closing and we have no parent + /// do we dispose ourselves + public bool DisposeOnDetachedClose = true; + public DettachableControl() : base() { @@ -145,16 +150,17 @@ namespace Radegast { OriginalParent.ControlAdded -= new ControlEventHandler(originalParent_ControlAdded); Size = AttachedSize; - Parent = OriginalParent; } + Parent = OriginalParent; + if (detachedForm != null) { detachedForm.Dispose(); detachedForm = null; } - if (OriginalParent == null) + if (OriginalParent == null && DisposeOnDetachedClose) { Dispose(); } diff --git a/Radegast/GUI/Consoles/MediaConsole.Designer.cs b/Radegast/GUI/Consoles/MediaConsole.Designer.cs index 28e3147..69c19c6 100644 --- a/Radegast/GUI/Consoles/MediaConsole.Designer.cs +++ b/Radegast/GUI/Consoles/MediaConsole.Designer.cs @@ -1,4 +1,34 @@ -namespace Radegast +// +// Radegast Metaverse Client +// Copyright (c) 2009, Radegast Development Team +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the application "Radegast", nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// $Id: Sound.cs 208 2009-09-08 03:37:37Z latifer@gmail.com $ +// +namespace Radegast { partial class MediaConsole { @@ -31,7 +61,6 @@ this.components = new System.ComponentModel.Container(); this.volAudioStream = new System.Windows.Forms.TrackBar(); this.pnlParcelAudio = new System.Windows.Forms.GroupBox(); - this.pbAudioVolume = new System.Windows.Forms.ProgressBar(); this.btnStop = new System.Windows.Forms.Button(); this.btnPlay = new System.Windows.Forms.Button(); this.cbKeep = new System.Windows.Forms.CheckBox(); @@ -41,24 +70,25 @@ this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.lblStation = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.volAudioStream)).BeginInit(); this.pnlParcelAudio.SuspendLayout(); this.SuspendLayout(); // // volAudioStream // - this.volAudioStream.LargeChange = 25; + this.volAudioStream.LargeChange = 10; this.volAudioStream.Location = new System.Drawing.Point(6, 19); this.volAudioStream.Maximum = 50; this.volAudioStream.Name = "volAudioStream"; this.volAudioStream.Size = new System.Drawing.Size(347, 45); - this.volAudioStream.SmallChange = 10; + this.volAudioStream.SmallChange = 2; this.volAudioStream.TabIndex = 1; this.volAudioStream.Value = 25; // // pnlParcelAudio // - this.pnlParcelAudio.Controls.Add(this.pbAudioVolume); + this.pnlParcelAudio.Controls.Add(this.lblStation); this.pnlParcelAudio.Controls.Add(this.btnStop); this.pnlParcelAudio.Controls.Add(this.btnPlay); this.pnlParcelAudio.Controls.Add(this.cbKeep); @@ -70,45 +100,40 @@ this.pnlParcelAudio.Controls.Add(this.volAudioStream); this.pnlParcelAudio.Location = new System.Drawing.Point(3, 3); this.pnlParcelAudio.Name = "pnlParcelAudio"; - this.pnlParcelAudio.Size = new System.Drawing.Size(359, 157); + this.pnlParcelAudio.Size = new System.Drawing.Size(359, 138); this.pnlParcelAudio.TabIndex = 2; this.pnlParcelAudio.TabStop = false; - this.pnlParcelAudio.Text = "Audio Stream"; - // - // pbAudioVolume - // - this.pbAudioVolume.Location = new System.Drawing.Point(9, 96); - this.pbAudioVolume.Name = "pbAudioVolume"; - this.pbAudioVolume.Size = new System.Drawing.Size(344, 14); - this.pbAudioVolume.TabIndex = 6; + this.pnlParcelAudio.Text = "Parcel Audio Stream"; // // btnStop // this.btnStop.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.btnStop.Image = global::Radegast.Properties.Resources.btn_stop; - this.btnStop.Location = new System.Drawing.Point(36, 119); + this.btnStop.Location = new System.Drawing.Point(37, 99); this.btnStop.Margin = new System.Windows.Forms.Padding(0); this.btnStop.Name = "btnStop"; this.btnStop.Size = new System.Drawing.Size(25, 25); this.btnStop.TabIndex = 5; this.btnStop.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage; this.btnStop.UseVisualStyleBackColor = true; + this.btnStop.Click += new System.EventHandler(this.btnStop_Click); // // btnPlay // this.btnPlay.Image = global::Radegast.Properties.Resources.btn_play; - this.btnPlay.Location = new System.Drawing.Point(9, 119); + this.btnPlay.Location = new System.Drawing.Point(10, 99); this.btnPlay.Margin = new System.Windows.Forms.Padding(0); this.btnPlay.Name = "btnPlay"; this.btnPlay.Size = new System.Drawing.Size(25, 25); this.btnPlay.TabIndex = 5; this.btnPlay.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage; this.btnPlay.UseVisualStyleBackColor = true; + this.btnPlay.Click += new System.EventHandler(this.btnPlay_Click); // // cbKeep // this.cbKeep.AutoSize = true; - this.cbKeep.Location = new System.Drawing.Point(232, 124); + this.cbKeep.Location = new System.Drawing.Point(232, 109); this.cbKeep.Name = "cbKeep"; this.cbKeep.Size = new System.Drawing.Size(121, 17); this.cbKeep.TabIndex = 4; @@ -120,28 +145,28 @@ // cbPlayAudioStream // this.cbPlayAudioStream.AutoSize = true; - this.cbPlayAudioStream.Location = new System.Drawing.Point(87, 124); + this.cbPlayAudioStream.Location = new System.Drawing.Point(79, 109); this.cbPlayAudioStream.Name = "cbPlayAudioStream"; - this.cbPlayAudioStream.Size = new System.Drawing.Size(141, 17); + this.cbPlayAudioStream.Size = new System.Drawing.Size(108, 17); this.cbPlayAudioStream.TabIndex = 4; - this.cbPlayAudioStream.Text = "Play parcel audio stream"; + this.cbPlayAudioStream.Text = "Auto start at login"; this.cbPlayAudioStream.UseVisualStyleBackColor = true; // // txtSongTitle // this.txtSongTitle.BackColor = System.Drawing.SystemColors.Control; - this.txtSongTitle.Location = new System.Drawing.Point(41, 70); + this.txtSongTitle.Location = new System.Drawing.Point(49, 70); this.txtSongTitle.Name = "txtSongTitle"; this.txtSongTitle.ReadOnly = true; - this.txtSongTitle.Size = new System.Drawing.Size(312, 20); + this.txtSongTitle.Size = new System.Drawing.Size(304, 20); this.txtSongTitle.TabIndex = 3; // // txtAudioURL // this.txtAudioURL.BackColor = System.Drawing.SystemColors.Control; - this.txtAudioURL.Location = new System.Drawing.Point(41, 48); + this.txtAudioURL.Location = new System.Drawing.Point(49, 48); this.txtAudioURL.Name = "txtAudioURL"; - this.txtAudioURL.Size = new System.Drawing.Size(312, 20); + this.txtAudioURL.Size = new System.Drawing.Size(304, 20); this.txtAudioURL.TabIndex = 3; // // label2 @@ -158,9 +183,19 @@ this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 51); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(29, 13); + this.label1.Size = new System.Drawing.Size(40, 13); this.label1.TabIndex = 2; - this.label1.Text = "URL"; + this.label1.Text = "Stream"; + // + // lblStation + // + this.lblStation.AutoSize = true; + this.lblStation.ForeColor = System.Drawing.Color.Blue; + this.lblStation.Location = new System.Drawing.Point(76, 93); + this.lblStation.Name = "lblStation"; + this.lblStation.Size = new System.Drawing.Size(40, 13); + this.lblStation.TabIndex = 6; + this.lblStation.Text = "Station"; // // MediaConsole // @@ -168,7 +203,7 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.pnlParcelAudio); this.Name = "MediaConsole"; - this.Size = new System.Drawing.Size(423, 279); + this.Size = new System.Drawing.Size(368, 147); ((System.ComponentModel.ISupportInitialize)(this.volAudioStream)).EndInit(); this.pnlParcelAudio.ResumeLayout(false); this.pnlParcelAudio.PerformLayout(); @@ -188,7 +223,7 @@ private System.Windows.Forms.Button btnStop; private System.Windows.Forms.TextBox txtSongTitle; private System.Windows.Forms.Label label2; - private System.Windows.Forms.ProgressBar pbAudioVolume; private System.Windows.Forms.ToolTip toolTip1; + private System.Windows.Forms.Label lblStation; } } diff --git a/Radegast/GUI/Consoles/MediaConsole.cs b/Radegast/GUI/Consoles/MediaConsole.cs index 7abb6e7..c6aae58 100644 --- a/Radegast/GUI/Consoles/MediaConsole.cs +++ b/Radegast/GUI/Consoles/MediaConsole.cs @@ -7,6 +7,7 @@ using System.Text; using System.Windows.Forms; using OpenMetaverse; using OpenMetaverse.StructuredData; +using Radegast.Media; namespace Radegast { @@ -19,42 +20,215 @@ namespace Radegast { get { - return 50f / volAudioStream.Value; + return volAudioStream.Value / 50f; } set { - if (value >= 0f && value <0f) + if (value >= 0f && value < 1f) { volAudioStream.Value = (int)(50f * value); } } } + private System.Threading.Timer configTimer; + private const int saveConfigTimeout = 3000; + private bool playing; + private string currentURL; + private MediaManager mngr; public MediaConsole(RadegastInstance instance) { InitializeComponent(); + DisposeOnDetachedClose = false; + Text = "Media"; + Disposed += new EventHandler(MediaConsole_Disposed); this.instance = instance; + this.mngr = instance.MediaManager; + s = instance.GlobalSettings; // Restore settings if (s["parcel_audio_url"].Type != OSDType.Unknown) txtAudioURL.Text = s["parcel_audio_url"].AsString(); if (s["parcel_audio_vol"].Type != OSDType.Unknown) - audioVolume = (float)s["parcel_audio_url"].AsReal(); + audioVolume = (float)s["parcel_audio_vol"].AsReal(); if (s["parcel_audio_play"].Type != OSDType.Unknown) cbPlayAudioStream.Checked = s["parcel_audio_play"].AsBoolean(); if (s["parcel_audio_keep_url"].Type != OSDType.Unknown) - cbPlayAudioStream.Checked = s["parcel_audio_keep_url"].AsBoolean(); + cbKeep.Checked = s["parcel_audio_keep_url"].AsBoolean(); + + configTimer = new System.Threading.Timer(SaveConfig, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); + + if (!instance.MediaManager.SoundSystemAvailable) + { + foreach (Control c in pnlParcelAudio.Controls) + c.Enabled = false; + } + + // GUI Events + volAudioStream.Scroll += new EventHandler(volAudioStream_Scroll); + txtAudioURL.TextChanged += new EventHandler(txtAudioURL_TextChanged); + cbKeep.CheckedChanged += new EventHandler(cbKeep_CheckedChanged); + cbPlayAudioStream.CheckedChanged += new EventHandler(cbPlayAudioStream_CheckedChanged); + lblStation.Tag = lblStation.Text = string.Empty; + lblStation.Click += new EventHandler(lblStation_Click); + + // Network callbacks + client.Parcels.OnParcelProperties += new ParcelManager.ParcelPropertiesCallback(Parcels_OnParcelProperties); + } + + private void MediaConsole_Disposed(object sender, EventArgs e) + { + Stop(); + + client.Parcels.OnParcelProperties -= new ParcelManager.ParcelPropertiesCallback(Parcels_OnParcelProperties); + + if (configTimer != null) + { + configTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); + configTimer.Dispose(); + configTimer = null; + } + } + + void Parcels_OnParcelProperties(Simulator simulator, Parcel parcel, ParcelResult result, int selectedPrims, int sequenceID, bool snapSelection) + { + if (cbKeep.Checked || result != ParcelResult.Single) return; + + if (InvokeRequired) + { + BeginInvoke(new MethodInvoker(() => Parcels_OnParcelProperties(simulator, parcel, result, selectedPrims, sequenceID, snapSelection))); + return; + } + + txtAudioURL.Text = parcel.MusicURL; + if (playing) + { + if (currentURL != txtAudioURL.Text) + { + currentURL = txtAudioURL.Text; + Play(); + } + } + else if (cbPlayAudioStream.Checked) + { + currentURL = txtAudioURL.Text; + Play(); + } } - void MediaConsole_Disposed(object sender, EventArgs e) + private void Stop() { + playing = false; + if (mngr.ParcelMusic != null) + mngr.ParcelMusic.Dispose(); + mngr.ParcelMusic = null; + lblStation.Tag = lblStation.Text = string.Empty; + txtSongTitle.Text = string.Empty; + } + + private void Play() + { + Stop(); + playing = true; + mngr.ParcelMusic = new Sound(mngr.FMODSystem); + mngr.ParcelMusic.Volume = audioVolume; + mngr.ParcelMusic.PlayStream(currentURL); + mngr.ParcelMusic.OnStreamInfo += new Sound.StreamInfoCallback(ParcelMusic_OnStreamInfo); + } + + void ParcelMusic_OnStreamInfo(object sender, StreamInfoArgs e) + { + if (InvokeRequired) + { + BeginInvoke(new MethodInvoker(() => ParcelMusic_OnStreamInfo(sender, e))); + return; + } + + switch (e.Key) + { + case "artist": + txtSongTitle.Text = e.Value; + break; + + case "title": + txtSongTitle.Text += " - " + e.Value; + break; + + case "icy-name": + lblStation.Text = e.Value; + break; + + case "icy-url": + lblStation.Tag = e.Value; + break; + } + } + + private void SaveConfig(object state) + { + if (InvokeRequired) + { + BeginInvoke(new MethodInvoker(() => SaveConfig(state))); + return; + } + s["parcel_audio_url"] = OSD.FromString(txtAudioURL.Text); s["parcel_audio_vol"] = OSD.FromReal(audioVolume); s["parcel_audio_play"] = OSD.FromBoolean(cbPlayAudioStream.Checked); s["parcel_audio_keep_url"] = OSD.FromBoolean(cbKeep.Checked); } + + #region GUI event handlers + void lblStation_Click(object sender, EventArgs e) + { + if (lblStation.ToString() != string.Empty) + { + instance.MainForm.ProcessLink(lblStation.Tag.ToString()); + } + } + + private void volAudioStream_Scroll(object sender, EventArgs e) + { + configTimer.Change(saveConfigTimeout, System.Threading.Timeout.Infinite); + if (mngr.ParcelMusic != null) + mngr.ParcelMusic.Volume = volAudioStream.Value / 50f; + } + + private void txtAudioURL_TextChanged(object sender, EventArgs e) + { + configTimer.Change(saveConfigTimeout, System.Threading.Timeout.Infinite); + } + + void cbPlayAudioStream_CheckedChanged(object sender, EventArgs e) + { + configTimer.Change(saveConfigTimeout, System.Threading.Timeout.Infinite); + } + + void cbKeep_CheckedChanged(object sender, EventArgs e) + { + configTimer.Change(saveConfigTimeout, System.Threading.Timeout.Infinite); + } + + private void btnPlay_Click(object sender, EventArgs e) + { + if (!playing) + { + currentURL = txtAudioURL.Text; + Play(); + } + } + + private void btnStop_Click(object sender, EventArgs e) + { + if (playing) + { + currentURL = string.Empty; + Stop(); + } + } + #endregion GUI event handlers } } diff --git a/Radegast/GUI/Consoles/MediaConsole.resx b/Radegast/GUI/Consoles/MediaConsole.resx index 7ce03af..e641aef 100644 --- a/Radegast/GUI/Consoles/MediaConsole.resx +++ b/Radegast/GUI/Consoles/MediaConsole.resx @@ -120,4 +120,7 @@ 17, 17 + + 17, 17 + \ No newline at end of file diff --git a/Radegast/GUI/Dialogs/MainForm.Designer.cs b/Radegast/GUI/Dialogs/MainForm.Designer.cs index 51d769b..5b7f3f2 100644 --- a/Radegast/GUI/Dialogs/MainForm.Designer.cs +++ b/Radegast/GUI/Dialogs/MainForm.Designer.cs @@ -81,7 +81,6 @@ namespace Radegast this.tmnuPrefs = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); this.tmnuExit = new System.Windows.Forms.ToolStripMenuItem(); - this.mediaConsoleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.tbtnDebug = new System.Windows.Forms.ToolStripDropDownButton(); this.tmnuDebugLog = new System.Windows.Forms.ToolStripMenuItem(); @@ -127,6 +126,7 @@ namespace Radegast this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); this.pnlDialog = new System.Windows.Forms.Panel(); this.timerWorldClock = new System.Windows.Forms.Timer(this.components); + this.tbtnMedia = new System.Windows.Forms.ToolStripButton(); this.toolStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); @@ -147,7 +147,8 @@ namespace Radegast this.tbnPlugins, this.tbnObjects, this.tbtnGroups, - this.lblTime}); + this.lblTime, + this.tbtnMedia}); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(738, 25); @@ -166,8 +167,7 @@ namespace Radegast this.toolStripMenuItem3, this.tmnuPrefs, this.toolStripMenuItem2, - this.tmnuExit, - this.mediaConsoleToolStripMenuItem}); + this.tmnuExit}); this.tbtnSLeek.Image = global::Radegast.Properties.Resources.computer_16; this.tbtnSLeek.ImageTransparentColor = System.Drawing.Color.Magenta; this.tbtnSLeek.Name = "tbtnSLeek"; @@ -220,14 +220,6 @@ namespace Radegast this.tmnuExit.Text = "E&xit"; this.tmnuExit.Click += new System.EventHandler(this.tmnuExit_Click); // - // mediaConsoleToolStripMenuItem - // - this.mediaConsoleToolStripMenuItem.Name = "mediaConsoleToolStripMenuItem"; - this.mediaConsoleToolStripMenuItem.Size = new System.Drawing.Size(162, 22); - this.mediaConsoleToolStripMenuItem.Text = "Media Console..."; - this.mediaConsoleToolStripMenuItem.Visible = false; - this.mediaConsoleToolStripMenuItem.Click += new System.EventHandler(this.mediaConsoleToolStripMenuItem_Click); - // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; @@ -645,6 +637,17 @@ namespace Radegast this.timerWorldClock.Interval = 1000; this.timerWorldClock.Tick += new System.EventHandler(this.timerWorldClock_Tick); // + // tbtnMedia + // + this.tbtnMedia.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.tbtnMedia.Image = ((System.Drawing.Image)(resources.GetObject("tbtnMedia.Image"))); + this.tbtnMedia.ImageTransparentColor = System.Drawing.Color.Magenta; + this.tbtnMedia.Name = "tbtnMedia"; + this.tbtnMedia.Size = new System.Drawing.Size(44, 22); + this.tbtnMedia.Text = "Media"; + this.tbtnMedia.Visible = false; + this.tbtnMedia.Click += new System.EventHandler(this.tbtnMedia_Click); + // // frmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -732,7 +735,7 @@ namespace Radegast private System.Windows.Forms.ToolStripMenuItem tmnuTeleportHome; private System.Windows.Forms.ToolStripLabel lblTime; private System.Windows.Forms.Timer timerWorldClock; - private System.Windows.Forms.ToolStripMenuItem mediaConsoleToolStripMenuItem; + private System.Windows.Forms.ToolStripButton tbtnMedia; } } diff --git a/Radegast/GUI/Dialogs/MainForm.cs b/Radegast/GUI/Dialogs/MainForm.cs index 8afcc41..c4526a1 100644 --- a/Radegast/GUI/Dialogs/MainForm.cs +++ b/Radegast/GUI/Dialogs/MainForm.cs @@ -173,7 +173,11 @@ namespace Radegast { InitializeTabsConsole(); InitializeDebugLogForm(); - mediaConsole = new MediaConsole(instance); + if (instance.MediaManager.SoundSystemAvailable) + { + mediaConsole = new MediaConsole(instance); + tbtnMedia.Visible = true; + } } private void netcom_ClientLoginStatus(object sender, ClientLoginEventArgs e) @@ -907,11 +911,14 @@ namespace Radegast lblTime.Text = now.ToString("h:mm tt", System.Globalization.CultureInfo.InvariantCulture); } - #endregion - - private void mediaConsoleToolStripMenuItem_Click(object sender, EventArgs e) + private void tbtnMedia_Click(object sender, EventArgs e) { - this.MediaConsole.Detached = true; + if (!mediaConsole.Detached) + mediaConsole.Detached = true; + else + mediaConsole.Focus(); } + + #endregion } } \ No newline at end of file diff --git a/Radegast/GUI/Dialogs/MainForm.resx b/Radegast/GUI/Dialogs/MainForm.resx index 4cb03aa..453e9ca 100644 --- a/Radegast/GUI/Dialogs/MainForm.resx +++ b/Radegast/GUI/Dialogs/MainForm.resx @@ -211,6 +211,21 @@ KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI + ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 + HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN + rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K + TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx + oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 + 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI + xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX + LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd + KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC + + 116, 17