Hide context to the environment

develop
LEdoian 3 years ago
parent a5edd77760
commit 71abb3fcd8

@ -25,11 +25,8 @@ namespace QuickPlay
/// Since this operation can be asynchronous, we cannot put it in th /// Since this operation can be asynchronous, we cannot put it in th
/// constructor. And this allows for some tweaks before connecting. /// constructor. And this allows for some tweaks before connecting.
/// </summary> /// </summary>
/// <param name="context">
/// Context to run possible services from.
/// </param>
/// <returns></returns> /// <returns></returns>
Task ConnectAsync(Context context); Task ConnectAsync();
} }
/// <summary> /// <summary>
/// A simple dataclass to hold auxiliary data of the Playable objects. /// A simple dataclass to hold auxiliary data of the Playable objects.

@ -40,7 +40,7 @@ namespace QuickPlay
currentPlayer = playerConfig.GetPlayer(); currentPlayer = playerConfig.GetPlayer();
try try
{ {
await currentPlayer.ConnectAsync(this); await currentPlayer.ConnectAsync();
} catch (CannotConnectException e) } catch (CannotConnectException e)
{ {
//TODO: View a toast with details and change some colors? //TODO: View a toast with details and change some colors?

@ -17,6 +17,7 @@ namespace QuickPlay
public override void OnCreate() public override void OnCreate()
{ {
base.OnCreate(); base.OnCreate();
// TODO: Create the watching thread
} }
public override IBinder OnBind(Intent intent) public override IBinder OnBind(Intent intent)
{ {

@ -16,7 +16,6 @@ namespace QuickPlay
class MpdPlayer: IPlayer class MpdPlayer: IPlayer
{ {
MpcCoreClient mpd; MpcCoreClient mpd;
Thread serviceThread;
// MpcCore uses strings, so be it // MpcCore uses strings, so be it
string mpdIP, mpdPort; string mpdIP, mpdPort;
@ -49,7 +48,7 @@ namespace QuickPlay
mpdPort = connDetails.Length >=2 ? connDetails[1] : "6600"; // XXX: Unneccessary default here... mpdPort = connDetails.Length >=2 ? connDetails[1] : "6600"; // XXX: Unneccessary default here...
// Connecting and monitoring remote player is done in ConnectAsync. // Connecting and monitoring remote player is done in ConnectAsync.
} }
public async Task ConnectAsync(Context ctx) public async Task ConnectAsync()
{ {
// Create a persistent connection // Create a persistent connection
var conn = new MpcCoreConnection(mpdIP, mpdPort); var conn = new MpcCoreConnection(mpdIP, mpdPort);
@ -62,12 +61,8 @@ namespace QuickPlay
throw new CannotConnectException("MPD connect failed", e); throw new CannotConnectException("MPD connect failed", e);
} }
// Start the monitoring service // Start the monitoring service
Console.WriteLine("Hello! Will run thr."); var ctx = Android.App.Application.Context;
serviceThread = new Thread(() =>
{
var intent = new Intent(ctx, typeof(MpdMonitorService)); var intent = new Intent(ctx, typeof(MpdMonitorService));
});
Console.WriteLine("Thread possibly started");
} }
} }
} }
Loading…
Cancel
Save