public static void PlayStoryboard(BeatmapFolderInfoEx info) { //init audio if (!(MusicPlayerManager.ActivityPlayer is MusicPlayer player)) { throw new Exception("Player must be MusicPlayer if you want to call PlayStoryboard()"); } player.Load(info.audio_file_path); MusicPlayerManager.ActivityPlayer?.Stop(); MusicPlayerManager.ApplyPlayer(player); //load Storyboard objects var instance = StoryboardInstance.Load(info); var auto_trigger = ToolManager.GetOrCreateTool <AutoTrigger>(); auto_trigger.Load(info); auto_trigger.Trim(); ExecutorSync.PostTask(() => { StoryboardWindow.CurrentWindow.LoadStoryboardInstance(instance); MusicPlayerManager.ActivityPlayer?.Play(); } ); }
void Awake() { // if has an instance if (instance == null) { instance = this; // gameObject is the game object this script is attached to. // method DontDestroyOnLoad makes the gameObject not be destroyed // automatically when loading a new scene. GameObject.DontDestroyOnLoad (gameObject); } else { Destroy (gameObject); print ("Destroy a Music Player since instance is not null.."); } }
void Awake() { // if has an instance if (instance == null) { instance = this; // gameObject is the game object this script is attached to. // method DontDestroyOnLoad makes the gameObject not be destroyed // automatically when loading a new scene. GameObject.DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); print("Destroy a Music Player since instance is not null.."); } }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { // Override point for customization after application launch. // If not required for your application you can safely delete this method AppleMusicManager = new AppleMusicManager(); MusicPlayerManager = new MusicPlayerManager(); AuthorizationManager = new AuthorizationManager(AppleMusicManager); MediaLibraryManager = new MediaLibraryManager(AuthorizationManager); if (TopViewController(0) is AuthorizationTableViewController authorizationTableViewController) { authorizationTableViewController.AuthorizationManager = AuthorizationManager; } else { throw new InvalidCastException($"Unable to find expected {nameof (AuthorizationTableViewController)} in at TabBar Index 0"); } if (TopViewController(1) is PlaylistTableViewController playlistTableViewController) { playlistTableViewController.AuthorizationManager = AuthorizationManager; playlistTableViewController.MediaLibraryManager = MediaLibraryManager; playlistTableViewController.MusicPlayerManager = MusicPlayerManager; } else { throw new InvalidCastException($"Unable to find expected {nameof (PlaylistTableViewController)} in at TabBar Index 1"); } if (TopViewController(2) is PlayerViewController playerViewController) { playerViewController.MusicPlayerManager = MusicPlayerManager; } else { throw new InvalidCastException($"Unable to find expected {nameof (PlayerViewController)} in at TabBar Index 2"); } if (TopViewController(3) is RecentlyPlayedTableViewController recentlyPlayedTableViewController) { recentlyPlayedTableViewController.AuthorizationManager = AuthorizationManager; recentlyPlayedTableViewController.AppleMusicManager = AppleMusicManager; recentlyPlayedTableViewController.MediaLibraryManager = MediaLibraryManager; recentlyPlayedTableViewController.MusicPlayerManager = MusicPlayerManager; } else { throw new InvalidCastException($"Unable to find expected {nameof (RecentlyPlayedTableViewController)} in at TabBar Index 3"); } if (TopViewController(4) is MediaSearchTableViewController mediaSearchTableViewController) { mediaSearchTableViewController.AuthorizationManager = AuthorizationManager; mediaSearchTableViewController.MediaLibraryManager = MediaLibraryManager; mediaSearchTableViewController.MusicPlayerManager = MusicPlayerManager; } else { throw new InvalidCastException($"Unable to find expected {nameof (MediaSearchTableViewController)} in at TabBar Index 4"); } return(true); }
public void PlayMediaItem(MediaItemTableViewCell mediaSearchTableViewCell, MediaItem mediaItem) => MusicPlayerManager.BeginPlayback(mediaItem.Id);
public static void Main(string[] argv) { //Test(); Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory; //hook Ctrl-C action for console window. SetConsoleCtrlHandler(type => { Exit(); return(true); }, false); //apply settings from file PlayerSetting.Init(); //apply settings from commandline var args = ParseProgramCommands(argv, out var beatmap_folder); //apply features and settings from diff envs EnvironmentHelper.SetupEnvironment(); //Update check and notify if (PlayerSetting.EnableUpdateCheck) { ProgramUpdater.UpdateCheck(); } //clean temp folder if updated just now. ProgramUpdater.CleanTemp(); PlayerSetting.PrintSettings(); //init window StoryboardWindow window = new StoryboardWindow(PlayerSetting.Width, PlayerSetting.Height); Log.User($"Start to parse folder :{beatmap_folder}"); if (Directory.Exists(beatmap_folder)) { var info = BeatmapFolderInfoEx.Parse(beatmap_folder, args); var instance = StoryboardInstance.Load(info); window.LoadStoryboardInstance(instance); var player = new MusicPlayer(); player.Load(info.audio_file_path); MusicPlayerManager.ApplyPlayer(player); var auto_trigger = ToolManager.GetOrCreateTool <AutoTrigger>(); auto_trigger.Load(info); auto_trigger.Trim(); } else { Exit($"You have to select a beatmap folder which contains storyboard to play"); } if (PlayerSetting.EncodingEnvironment) { //init encoding environment var encoding_opt = new EncoderOption(args); EncodingKernel encoding_kernel = new EncodingKernel(encoding_opt); EncodingProcessPlayer encoding_player = new EncodingProcessPlayer(MusicPlayerManager.ActivityPlayer.Length, encoding_opt.FPS); MusicPlayerManager.ActivityPlayer.Pause(); MusicPlayerManager.ApplyPlayer(encoding_player); ToolManager.AddTool(encoding_kernel); encoding_kernel.Start(); } #region Setup Loop Playback if ((PlayerSetting._LoopPlayStartTime != null || PlayerSetting._LoopPlayEndTime != null) && MusicPlayerManager.ActivityPlayer is MusicPlayer mp) { var len = mp.Length; LoopPlayer lp = new LoopPlayer(PlayerSetting._LoopPlayStartTime ?? 0, PlayerSetting._LoopPlayEndTime ?? len); Log.User($"Loop playback : {lp}"); MusicPlayerManager.ApplyPlayer(lp); } #endregion MusicPlayerManager.ActivityPlayer.Volume = PlayerSetting.Volume; MusicPlayerManager.ActivityPlayer?.Play(); window.Run(); /*/ 不曾设想的操作.jpg * window.IsVisible = true; * window.RefreshResize(); * * while (true) * { * UpdateKernel.Update(); * RenderKernel.Draw(); * window.SwapBuffers(); * UpdateKernel.FrameRateLimit(); * Application.DoEvents(); * } * /*/ }