index.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <script src="./opensheetmusicdisplay.min.js"></script>
  9. <style>
  10. * {
  11. margin: 0;
  12. padding: 0;
  13. }
  14. body {
  15. padding-bottom: 60px;
  16. height: 600px;
  17. overflow: hidden;
  18. }
  19. .vf-text {
  20. display: none;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <div id="osmdContainer" />
  26. <script>
  27. var osmd = new opensheetmusicdisplay.OpenSheetMusicDisplay("osmdContainer");
  28. osmd.setOptions({
  29. backend: "svg",
  30. drawTitle: false,
  31. drawPartNames: true,
  32. // drawingParameters: "compacttight" // don't display title, composer etc., smaller margins
  33. });
  34. function render(){
  35. osmd.render();
  36. window.parent.postMessage({
  37. api: 'musicStaffRender',
  38. loading: false
  39. }, '*');
  40. }
  41. function renderXml(xmlUrl, partIndex) {
  42. osmd
  43. .load(xmlUrl)
  44. .then(
  45. function () {
  46. for (let i = 0; i < osmd.Sheet.Instruments.length; i++) {
  47. // console.log(osmd.Sheet.Instruments[i].Name);
  48. osmd.Sheet.Instruments[i].Visible = i === partIndex;
  49. }
  50. osmd.zoom = .5
  51. render();
  52. }
  53. );
  54. }
  55. function resetRender(partIndex) {
  56. for (let i = 0; i < osmd.Sheet.Instruments.length; i++) {
  57. // console.log(osmd.Sheet.Instruments[i].Name);
  58. osmd.Sheet.Instruments[i].Visible = i === partIndex;
  59. }
  60. render();
  61. }
  62. </script>
  63. </body>
  64. </html>