Skip to content

Commit

Permalink
iOS: Bug fixes in SelectPlaylistViewController and preferences-relate…
Browse files Browse the repository at this point in the history
…d ViewControllers. Fixed player bug on iOS where the reported position of the next song was wrong in most cases.
  • Loading branch information
ycastonguay committed Nov 17, 2013
1 parent 2e4dd1f commit fee4c97
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 21 deletions.
8 changes: 4 additions & 4 deletions MPfm/MPfm.Player/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1869,8 +1869,8 @@ internal int StreamCallback(int handle, IntPtr buffer, int length, IntPtr user)

Tracing.Log("StreamCallback -- Getting main channel position...");
long position = _mixerChannel.GetPosition(_fxChannel.Handle);
if (_useFloatingPoint)
position /= 2;
// if (_useFloatingPoint)
// position /= 2;

// Get remanining data in buffer
Tracing.Log("StreamCallback -- Getting BASS_DATA_AVAILABLE...");
Expand Down Expand Up @@ -1984,8 +1984,8 @@ internal void PlayerSyncProc(int handle, int channel, int data, IntPtr user)

_mixerChannel.Lock(true);
long position = _mixerChannel.GetPosition();
if (_useFloatingPoint)
position /= 2;
// if (_useFloatingPoint)
// position /= 2;

// Get remanining data in buffer
//int buffered = mainChannel.GetData(IntPtr.Zero, (int)BASSData.BASS_DATA_AVAILABLE);
Expand Down
8 changes: 0 additions & 8 deletions MPfm/MPfm.Sound/Playlists/PlaylistItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,7 @@ public void Load(bool useFloatingPoint)

// Check if a channel already exists
if(channel != null)
{
// Dispose channel
Dispose();
}

// Load channel
channel = Channel.CreateFileStreamForDecoding(audioFile.FilePath, useFloatingPoint);
Expand All @@ -271,16 +268,11 @@ public void Load(bool useFloatingPoint)

// Check if the channel is using floating point
if (channel.IsFloatingPoint)
{
// Divide value by 2
lengthBytes /= 2;
}

// Check if this is a FLAC file over 44100Hz
if (audioFile.FileType == AudioFileFormat.FLAC && audioFile.SampleRate > 44100)
{
lengthBytes = (long)((float)lengthBytes * 1.5f);
}

lengthSamples = ConvertAudio.ToPCM(lengthBytes, (uint)audioFile.BitsPerSample, 2);
lengthMilliseconds = (int)ConvertAudio.ToMS(lengthSamples, (uint)audioFile.SampleRate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ private void GenerateItems()
_items.Add(new PreferenceCellItem()
{
Id = "update_frequency_song_position",
CellType = PreferenceCellType.Frequency,
CellType = PreferenceCellType.Slider,
HeaderTitle = "Update Frequency",
Title = "Song Position"
});
_items.Add(new PreferenceCellItem()
{
Id = "update_frequency_output_meter",
CellType = PreferenceCellType.Frequency,
CellType = PreferenceCellType.Slider,
HeaderTitle = "Update Frequency",
Title = "Output Meter",
FooterTitle = "Warning: Lower values require more CPU and memory."
Expand Down
6 changes: 3 additions & 3 deletions MPfm/MPfm.iOS/Classes/Controllers/PlayerViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ public void AddScrollView(UIViewController viewController)
{
viewController.View.Frame = new RectangleF(scrollSubviewsLength * scrollView.Frame.Width, 0, scrollView.Frame.Width, scrollView.Frame.Height);
scrollView.AddSubview(viewController.View);
//pageControl.Pages = scrollSubviewsLength;
pageControl.Pages = 5;
scrollView.ContentSize = new SizeF(scrollSubviewsLength * scrollView.Frame.Width, scrollView.Frame.Height);
pageControl.Pages = scrollSubviewsLength + 1;
//pageControl.Pages = 5;
scrollView.ContentSize = new SizeF((scrollSubviewsLength + 1) * scrollView.Frame.Width, scrollView.Frame.Height);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ namespace MPfm.iOS
public partial class SelectPlaylistViewController : BaseViewController, ISelectPlaylistView
{
List<PlaylistEntity> _items;
LibraryBrowserEntity _item;

string _cellIdentifier = "SelectPlaylistCell";

public SelectPlaylistViewController()
public SelectPlaylistViewController(LibraryBrowserEntity item)
: base (UserInterfaceIdiomIsPhone ? "SelectPlaylistViewController_iPhone" : "SelectPlaylistViewController_iPad", null)
{
_item = item;
}

public override void ViewDidLoad()
Expand All @@ -55,7 +57,7 @@ public override void ViewDidLoad()
base.ViewDidLoad();

var navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
//navigationManager.BindSelectPlaylistView(this, );
navigationManager.BindSelectPlaylistView(this, _item);
}

partial void actionAddNewPlaylist(NSObject sender)
Expand Down
5 changes: 4 additions & 1 deletion MPfm/MPfm.iOS/Classes/Objects/PreferenceCellItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ public class PreferenceCellItem
public string FooterTitle { get; set; }
public string Description { get; set; }
public string IconName { get; set; }
public object Value { get; set; }
public bool Enabled { get; set; }

public object Value { get; set; }
public int MinValue { get; set; }
public int MaxValue { get; set; }

public PreferenceCellItem()
{
Enabled = true;
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.iOS/Classes/Objects/PreferenceCellType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public enum PreferenceCellType
Boolean = 2,
String = 3,
Integer = 4,
Frequency = 5
Slider = 5
}
}

0 comments on commit fee4c97

Please sign in to comment.