-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3605d9e
commit 2af3cdf
Showing
5 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export default class extends window.Controller { | ||
connect() { | ||
const audio = this.element.querySelector('audio') | ||
|
||
$(audio).on('ended', (event) => { | ||
const controlPlayBtn = $(this.element.querySelector('.control-play')) | ||
const controlPauseBtn = $(this.element.querySelector('.control-pause')) | ||
|
||
controlPlayBtn.removeClass('d-none') | ||
controlPauseBtn.addClass('d-none') | ||
}) | ||
} | ||
|
||
audio_play_pause() { | ||
const audio = this.element.querySelector('audio') | ||
const button = $(this.element.querySelector('button')) | ||
const controlPlayBtn = button.find('.control-play') | ||
const controlPauseBtn = button.find('.control-pause') | ||
|
||
if (audio.paused) { | ||
controlPlayBtn.addClass('d-none') | ||
controlPauseBtn.removeClass('d-none') | ||
audio.play() | ||
} else if (audio.played) { | ||
controlPlayBtn.removeClass('d-none') | ||
controlPauseBtn.addClass('d-none') | ||
|
||
audio.pause() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import RangeController from './controllers/range_controller'; | ||
import RateController from './controllers/rate_controller'; | ||
import ImageZoomController from './controllers/image_zoom_controller'; | ||
import AudioController from './controllers/audio_controller'; | ||
|
||
application.register('range', RangeController) | ||
application.register('rate', RateController) | ||
application.register('image-zoom', ImageZoomController) | ||
application.register('audio', AudioController) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@component($typeForm, get_defined_vars()) | ||
<div data-controller="audio"> | ||
@if($attributes['value']) | ||
<div class="form-group mb-0"> | ||
<audio src='{{$attributes['value']}}' preload='{{$attributes['preload']}}'></audio> | ||
<button type="button" class='btn btn-default' data-action="click->audio#audio_play_pause"> | ||
<x-orchid-icon path="{{$attributes['playIcon']}}" class="{{$attributes['playIcon']}}"/> | ||
<x-orchid-icon path="{{$attributes['pauseIcon']}}" class="{{$attributes['pauseIcon']}} d-none"/> | ||
</button> | ||
</div> | ||
@endif | ||
</div> | ||
@endcomponent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace agoalofalife\Orchid\Fields; | ||
|
||
use Orchid\Screen\Field; | ||
|
||
/** | ||
* Class Audio | ||
* | ||
* @method Audio source($value) | ||
* @method Audio preload($value = true) | ||
* @method Audio playIcon($value = null) | ||
* @method Audio pauseIcon($value = null) | ||
*/ | ||
class Audio extends Field | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $view = 'platform-fields::fields.audio'; | ||
/** | ||
* Default attributes value. | ||
* | ||
* @var array | ||
*/ | ||
protected $attributes = [ | ||
'preload' => 'none', | ||
'playIcon' => 'control-play', | ||
'pauseIcon' => 'control-pause', | ||
]; | ||
|
||
/** | ||
* Attributes available for a particular tag. | ||
* | ||
* @var array | ||
*/ | ||
protected $inlineAttributes = [ | ||
'source', | ||
'preload', | ||
'playIcon', | ||
'pauseIcon', | ||
'value', | ||
]; | ||
} |