Example #1
0
        /// <summary>
        /// Resource management is not proper here. Suggest an improvement.
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private async Task SetSource(IStorageFile file)
        {
            var stream = await file.OpenReadAsync();

            sourceStream = stream;
            await StoreUtil.OnUiThread(() => {
                Player.SetSource(stream, stream.ContentType);
            });
        }
        public async Task UpdateProgress()
        {
            await StoreUtil.OnUiThread(() => {
                OnPropertyChanged("Status");
                OnPropertyChanged("BytesReceived");
                OnPropertyChanged("TotalBytesToReceive");
                OnPropertyChanged("TotalBytesToReceiveReadable");
            });

            //Debug.WriteLine(Progress.Status + ": " + Progress.BytesReceived + " / " + Progress.TotalBytesToReceive);
        }
Example #3
0
 private async void ws_MessageReceived(MessageWebSocket sender, MessageWebSocketMessageReceivedEventArgs args)
 {
     try {
         // throws Exception if eof is received, which is the case for example if auth fails
         var reader  = args.GetDataReader();
         var message = reader.ReadString(reader.UnconsumedBufferLength);
         await StoreUtil.OnUiThread(() => OnMessageReceived(message));
     } catch (Exception) {
         // assumes eof has been received i.e. the server has closed the connection
         // http://msdn.microsoft.com/en-US/library/windows/apps/hh701366
         ws.Close(1005, String.Empty);
     }
 }
Example #4
0
 // When operations happen on a background thread we have to marshal UI updates back to the UI thread.
 private void MarshalLog(string value)
 {
     StoreUtil.OnUiThread(() => Log(value));
 }
Example #5
0
 public Task Pause()
 {
     return(StoreUtil.OnUiThread(Player.Pause));
 }
Example #6
0
 public Task Play()
 {
     return(StoreUtil.OnUiThread(Player.Play));
 }
Example #7
0
 public Task Stop()
 {
     return(StoreUtil.OnUiThread(Player.Stop));
 }
Example #8
0
 private static Task OnUi(Task t)
 {
     return(StoreUtil.OnUiThread(async() => await t));
 }
Example #9
0
 async void webSocket_MessageReceived(MessageWebSocket sender, MessageWebSocketMessageReceivedEventArgs args)
 {
     var reader = args.GetDataReader();
     var msg    = reader.ReadString(reader.UnconsumedBufferLength);
     await StoreUtil.OnUiThread(() => Output = msg);
 }
Example #10
0
 //public async Task TestWebSocketsWrapper() {
 //    await ws.Connect();
 //    ws.Opened += () => SetOutput("Opened!");
 //    ws.MessageReceived += msg => SetOutput("Got msg: " + msg);
 //    ws.Closed += reason => SetOutput("Closed. " + reason);
 //    Output = "Connected.";
 //    //await ws.Send(@"{""cmd"":""status""}");
 //    //Output = "Sent message";
 //}
 private async void SetOutput(string msg)
 {
     await StoreUtil.OnUiThread(() => Output = msg);
 }