|
1 | 1 | <link rel="import" href="../paper-material/paper-material.html" /> |
2 | 2 | <link rel="import" href="../paper-fab/paper-fab.html" /> |
3 | 3 | <link rel="import" href="../paper-icon-button/paper-icon-button.html" /> |
| 4 | +<link rel="import" href="../paper-button/paper-button.html" /> |
4 | 5 | <link rel="import" href="../iron-icons/iron-icons.html" /> |
5 | 6 | <link rel="import" href="../iron-icons/av-icons.html" /> |
6 | 7 | <link rel="import" href="../neon-animation/neon-shared-element-animatable-behavior.html"> |
| 8 | +<link rel="import" href="../paper-progress/paper-progress.html" /> |
7 | 9 | <link rel="import" href="../neon-animation/neon-animated-pages.html" /> |
8 | 10 | <link rel="import" href="../neon-animation/neon-animations.html" /> |
9 | 11 |
|
|
13 | 15 | width: 100%; |
14 | 16 | height: 100%; |
15 | 17 | } |
| 18 | + paper-progress { |
| 19 | + position: absolute; |
| 20 | + top: 1px; |
| 21 | + width: 100%; |
| 22 | + z-index: 5; |
| 23 | + --paper-progress-active-color: var(--text-primary-color); |
| 24 | + --paper-progress-container-color: transparent; |
| 25 | + } |
16 | 26 | paper-material#container { |
17 | 27 | height: 100%; |
18 | 28 | background: var(--accent-color); |
|
21 | 31 | opacity: 0; |
22 | 32 | transition: opacity 0.5s; |
23 | 33 | } |
| 34 | + #controls { |
| 35 | + text-align: center; |
| 36 | + opacity: 0; |
| 37 | + transition: opacity 1s; |
| 38 | + } |
| 39 | + paper-icon-button::shadow #icon { |
| 40 | + width: 30px; |
| 41 | + height: 30px; |
| 42 | + } |
| 43 | + paper-icon-button[toggles] { |
| 44 | + transition: background-color 0.3s; |
| 45 | + } |
| 46 | + paper-icon-button[toggles][active] { |
| 47 | + background-color: rgba(0, 0, 0, 0.25); |
| 48 | + } |
| 49 | + @media (min-width: 600px) { |
| 50 | + #container { |
| 51 | + display: block; |
| 52 | + } |
| 53 | + #wavecontainer { |
| 54 | + opacity: 0; |
| 55 | + width: 70%; |
| 56 | + display: inline-block; |
| 57 | + vertical-align: middle; |
| 58 | + margin: 25px 0; |
| 59 | + } |
| 60 | + #controls { |
| 61 | + opacity: 0; |
| 62 | + width: 29%; |
| 63 | + display: inline-block; |
| 64 | + vertical-align: middle; |
| 65 | + } |
| 66 | + } |
24 | 67 | </style> |
25 | 68 | <template> |
| 69 | + <paper-progress id="loadmeter" value="{{loadingval}}"></paper-progress> |
26 | 70 | <paper-material id="container" elevation="0"> |
27 | 71 | <paper-material id="wavecontainer" elevation="0"> |
28 | 72 | </paper-material> |
29 | | - <div id="controls"> |
30 | | - <paper-icon-button id='pausebutton' icon="av:pause" on-click="togglePlay"></paper-icon-button> |
| 73 | + <div id="controls" class="horizontal layout"> |
| 74 | + <paper-icon-button class="flex" id='replaybutton' icon="av:replay-30" on-click="replay"></paper-icon-button> |
| 75 | + <paper-icon-button class="flex" id='pausebutton' icon="av:pause" on-click="togglePlay"></paper-icon-button> |
| 76 | + <paper-icon-button class="flex" id='mutebutton' icon="av:volume-off" on-click="mute" toggles></paper-icon-button> |
31 | 77 | </div> |
32 | 78 | </paper-material> |
33 | | - |
34 | 79 | </template> |
35 | 80 | </dom-module> |
36 | 81 | <script> |
|
60 | 105 | value: '#CFD8DC', |
61 | 106 | notify: true |
62 | 107 | }, |
| 108 | + loadingval: { |
| 109 | + type: String, |
| 110 | + value: 0 |
| 111 | + }, |
63 | 112 | sharedElements: { |
64 | 113 | value: function() { |
65 | 114 | return { |
|
93 | 142 | }, |
94 | 143 | togglePlay: function() { |
95 | 144 | this.$.wavecontainer.style.opacity = 0; |
| 145 | + this.$.controls.style.opacity = 0; |
96 | 146 | this.wavesurfer.pause(); |
97 | 147 | this.fire('pause-click'); |
98 | 148 | }, |
99 | 149 | initWaveSurfer: function() { |
100 | 150 | var self = this; |
| 151 | + this.$.controls.style.opacity = 0; |
| 152 | + |
101 | 153 | this.wavesurfer.init({ |
102 | 154 | container: this.$.wavecontainer, |
103 | 155 | waveColor: this.wavecolor, |
104 | 156 | progressColor: this.progresscolor, // --primary-background-color |
105 | 157 | fillParent: true, |
106 | 158 | height: 100 |
107 | 159 | }); |
| 160 | + |
108 | 161 | this.wavesurfer.on('ready', function () { |
109 | 162 | self.wavesurfer.play(); |
110 | 163 | }); |
111 | 164 | this.wavesurfer.load(this.src); |
| 165 | + |
| 166 | + this.wavesurfer.on('finish', function () { |
| 167 | + self.togglePlay(); |
| 168 | + }); |
| 169 | + |
| 170 | + this.wavesurfer.on('loading', function (e) { |
| 171 | + self.loadingval = e; |
| 172 | + if(e == 100) { |
| 173 | + self.$.controls.style.opacity = 1; |
| 174 | + self.$.loadmeter.style.display = "none"; |
| 175 | + } else { |
| 176 | + self.$.controls.style.opacity = 0; |
| 177 | + } |
| 178 | + }); |
112 | 179 | }, |
113 | 180 | updateWavesurfer: function() { |
114 | 181 | this.wavesurfer = Object.create(WaveSurfer); |
115 | 182 | }, |
116 | 183 | play: function() { |
117 | 184 | this.wavesurfer.play(); |
| 185 | + }, |
| 186 | + mute: function() { |
| 187 | + this.wavesurfer.toggleMute(); |
| 188 | + }, |
| 189 | + replay: function() { |
| 190 | + this.wavesurfer.skip(-30); |
118 | 191 | } |
119 | 192 | }); |
120 | 193 | })(); |
|
0 commit comments