void PlayerUpdate(BeepPlayer sender, TimeSpan elapsed) { if (!UpdatingStatus) { PlaybackSliderProgrammatically = true; Dispatcher.Invoke(() => { PlaybackSlider.Value = elapsed.Ticks / (double)sender.Duration.Ticks * PlaybackSlider.Maximum + PlaybackSlider.Minimum; StatusLabel.Content = elapsed.ToString(@"h\:mm\:ss\:fff"); }); } }
void PlaybackSlider_DragCompleted(object sender, DragCompletedEventArgs e) { UpdatingStatus = false; BeepPlayer player = PlaybackEngine.Player; if (player != null && player.Playing) { TimeSpan seekTime = new TimeSpan((long)(player.PlaybackTime().Ticks *((PlaybackSlider.Value - PlaybackSlider.Minimum) / PlaybackSlider.Maximum))); player.Seek(seekTime); } }
void PlaybackSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (PlaybackSliderProgrammatically) { return; } BeepPlayer player = PlaybackEngine.Player; if (player != null && player.Playing) { UpdatingStatus = true; TimeSpan display = new TimeSpan((long)(player.PlaybackTime().Ticks *((PlaybackSlider.Value - PlaybackSlider.Minimum) / PlaybackSlider.Maximum))); StatusLabel.Content = display; } }
void ButtonPlay_Click(object sender, RoutedEventArgs e) { BeepPlayer player = PlaybackEngine.Player; bool playing = player != null && player.Playing; switch (playing) { case true: PlaybackEngine.Stop(); //If playing, stop break; case false: BrowseAndPlay(); //If not playing, start break; } }
void UpdateUI() { BeepPlayer player = PlaybackEngine.Player; bool playing = player != null && player.Playing; Dispatcher.Invoke(() => { Title = (player == null || string.IsNullOrEmpty(player.Title)) ? "ABC Player" : player.Title; ButtonPlay.Visibility = playing ? Visibility.Collapsed : Visibility.Visible; ButtonStop.Visibility = playing ? Visibility.Visible : Visibility.Collapsed; VolumeButtonIcon.Opacity = GetVolume() > 0 ? 1 : 0.2; VolumeSliderLabel.Content = GetVolume().ToString("P"); if (playing) { PlaybackEngine.Volume = GetSafeVolume(); StatusLabel.Content = player.Duration.ToString(@"h\:mm\:ss\:fff"); } }); }
static void Main(string[] args) { const ushort controlPortStarting = 5061; var settingsManager = new CommandLineClientSettingsReader(); if (!settingsManager.ParseArgs(args)) { return; } var settings = settingsManager.ClientSettings; var webClient = new RopuWebClient("https://192.168.1.9:5001/", settingsManager); var keysClient = new KeysClient(webClient, false, encryptionKey => new CachedEncryptionKey(encryptionKey, key => new AesGcmWrapper(key))); var packetEncryption = new PacketEncryption(keysClient); var protocolSwitch = new ProtocolSwitch(controlPortStarting, new PortFinder(), packetEncryption, keysClient, settings); var servingNodeClient = new ServingNodeClient(protocolSwitch); IAudioSource audioSource = settings.FileMediaSource != null ? (IAudioSource) new FileAudioSource(settings.FileMediaSource) : (IAudioSource) new PulseAudioSimple(StreamDirection.Record, "RopuInput"); var audioPlayer = new PulseAudioSimple(StreamDirection.Playback, "RopuOutput"); var audioCodec = new OpusCodec(); var jitterBuffer = new AdaptiveJitterBuffer(2, 50); var mediaClient = new MediaClient(protocolSwitch, audioSource, audioPlayer, audioCodec, jitterBuffer, settings); var callManagementProtocol = new LoadBalancerProtocol(new PortFinder(), 5079, packetEncryption, keysClient); var beepPlayer = new BeepPlayer(new PulseAudioSimple(StreamDirection.Playback, "RopuBeeps")); var ropuClient = new RopuClient(protocolSwitch, servingNodeClient, mediaClient, callManagementProtocol, settings, beepPlayer, webClient, keysClient); var application = new RopuApplication(ropuClient); var imageService = new ImageService(); //TODO: get web address from config var imageClient = new ImageClient(webClient); var groupsClient = new GroupsClient(webClient, imageClient); var usersClient = new UsersClient(webClient); //settings.UserId = usersClient.GetCurrentUser().Result.Id; var pttPage = new PttPage(imageService); var navigator = new Navigator(); var colorService = new ColorService(); navigator.Register <LoginViewModel, LoginView>(() => new LoginView(new LoginViewModel(navigator, webClient, settingsManager), imageService)); navigator.Register <SignupViewModel, SignupPage>(() => new SignupPage(new SignupViewModel(navigator, usersClient), imageService)); Action <Func <Task> > invoke = toDo => Application.Instance.Invoke(toDo); var permissionServices = new PermissionServices(); var pttView = new PttView(new PttViewModel <Color>(ropuClient, settingsManager, groupsClient, usersClient, imageClient, colorService, invoke, permissionServices, webClient, navigator), pttPage); navigator.Register <PttViewModel <Color>, PttView>(() => pttView); navigator.RegisterView("HomeRightPanel", "PttView", () => pttView); var homeView = new HomeView(new HomeViewModel(navigator), navigator, colorService); navigator.Register <HomeViewModel, HomeView>(() => homeView); var browseGroupsView = new BrowseGroupsView(new BrowseGroupsViewModel(groupsClient, navigator)); navigator.Register <BrowseGroupsViewModel, BrowseGroupsView>(() => browseGroupsView); Func <Group, BrowseGroupView> browseGroupViewBuilder = group => new BrowseGroupView(new BrowseGroupViewModel(group, groupsClient, settings, navigator), imageService, navigator, colorService); navigator.Register <BrowseGroupViewModel, BrowseGroupView, Group>(group => browseGroupViewBuilder(group)); var selectIdleGroupView = new SelectIdleGroupView(new SelectGroupViewModel(groupsClient, navigator, ropuClient)); navigator.RegisterView("HomeRightPanel", "SelectIdleGroupView", () => selectIdleGroupView); var mainForm = new MainView(navigator, new MainViewModel(settings, navigator)); mainForm.Icon = imageService.Ropu; var ignore = navigator.ShowModal <HomeViewModel>(); ignore = navigator.ShowPttView(); application.Run(mainForm); }
void PlayerStop(BeepPlayer player, bool finished) { player.OnUpdate -= PlayerUpdate; }
void PlayerStart(BeepPlayer player) { player.OnUpdate += PlayerUpdate; }