Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
erp5
Commits
722dbdeb
Commit
722dbdeb
authored
May 02, 2018
by
Mukul
Committed by
Xiaowu Zhang
May 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_multimedia] Add clickable progress bar feature in officejs media player
parent
385c4c30
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
15 deletions
+82
-15
bt5/erp5_multimedia/SkinTemplateItem/portal_skins/erp5_multimedia/gadget_custom_player.js.js
...m/portal_skins/erp5_multimedia/gadget_custom_player.js.js
+21
-0
bt5/erp5_multimedia/SkinTemplateItem/portal_skins/erp5_multimedia/gadget_custom_player_controller.js.js
...ins/erp5_multimedia/gadget_custom_player_controller.js.js
+57
-15
bt5/erp5_multimedia/SkinTemplateItem/portal_skins/erp5_multimedia/gadget_custom_player_controller_fallback.js.js
...multimedia/gadget_custom_player_controller_fallback.js.js
+4
-0
No files found.
bt5/erp5_multimedia/SkinTemplateItem/portal_skins/erp5_multimedia/gadget_custom_player.js.js
View file @
722dbdeb
...
@@ -119,6 +119,27 @@
...
@@ -119,6 +119,27 @@
controller_fallback
:
false
controller_fallback
:
false
};
};
})
})
.
declareService
(
function
()
{
var
gadget
=
this
,
progress_bar
=
gadget
.
element
.
querySelector
(
'
progress
'
);
return
loopEventListener
(
progress_bar
,
'
click
'
,
false
,
function
(
event
)
{
return
gadget
.
getDeclaredGadget
(
gadget
.
params
.
scope
)
.
push
(
function
(
controller
)
{
var
percentage
=
event
.
offsetX
/
progress_bar
.
offsetWidth
;
return
controller
.
updateAudioElementCurrentTime
(
percentage
*
progress_bar
.
max
,
progress_bar
.
max
)
.
push
(
function
()
{
return
gadget
.
togglePlayPause
(
gadget
.
state
.
play
);
});
});
},
true
);
})
.
declareService
(
function
()
{
.
declareService
(
function
()
{
var
gadget
=
this
;
var
gadget
=
this
;
...
...
bt5/erp5_multimedia/SkinTemplateItem/portal_skins/erp5_multimedia/gadget_custom_player_controller.js.js
View file @
722dbdeb
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
.
declareMethod
(
'
getAudioChunk
'
,
function
()
{
.
declareMethod
(
'
getAudioChunk
'
,
function
()
{
var
gadget
=
this
,
start
,
end
;
var
gadget
=
this
,
start
,
end
;
start
=
gadget
.
params
.
index
;
start
=
gadget
.
params
.
index
;
if
(
gadget
.
params
.
end
)
{
if
(
gadget
.
params
.
end
||
gadget
.
params
.
mediaSource
.
sourceBuffers
.
length
===
0
)
{
return
;
return
;
}
}
...
@@ -56,6 +56,35 @@
...
@@ -56,6 +56,35 @@
});
});
});
});
})
})
.
declareMethod
(
'
updateAudioElementCurrentTime
'
,
function
(
time
,
max
)
{
var
gadget
=
this
;
// If there is no data in sourceBuffer return from here.
if
(
gadget
.
params
.
sourceBuffer
.
buffered
.
length
===
0
)
{
return
;
}
// If time is in range of buffered data, just update the current time of audio.
if
(
time
>
gadget
.
params
.
sourceBuffer
.
buffered
.
start
(
0
)
&&
time
<
gadget
.
params
.
sourceBuffer
.
buffered
.
end
(
0
))
{
gadget
.
element
.
querySelector
(
'
audio
'
).
currentTime
=
time
;
return
gadget
.
updateCurrentTime
(
time
);
}
gadget
.
params
.
index
=
Math
.
floor
((
gadget
.
params
.
index
/
max
)
*
time
)
-
1000
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
gadget
.
params
.
sourceBuffer
.
abort
();
gadget
.
params
.
sourceBuffer
.
timestampOffset
=
time
;
gadget
.
params
.
sourceBuffer
.
remove
(
gadget
.
params
.
sourceBuffer
.
buffered
.
start
(
0
),
gadget
.
params
.
sourceBuffer
.
buffered
.
end
(
0
)
);
return
gadget
.
setUpdateEvent
();
})
.
push
(
function
()
{
gadget
.
element
.
querySelector
(
'
audio
'
).
currentTime
=
time
;
return
gadget
.
updateCurrentTime
(
time
);
});
})
.
declareMethod
(
'
handlePlayPause
'
,
function
(
play
)
{
.
declareMethod
(
'
handlePlayPause
'
,
function
(
play
)
{
var
audio
=
this
.
element
.
querySelector
(
'
audio
'
);
var
audio
=
this
.
element
.
querySelector
(
'
audio
'
);
...
@@ -81,17 +110,19 @@
...
@@ -81,17 +110,19 @@
.
push
(
function
(
buffer
)
{
.
push
(
function
(
buffer
)
{
if
(
buffer
instanceof
ArrayBuffer
&&
!
gadget
.
params
.
sourceBuffer
.
updating
)
{
if
(
buffer
instanceof
ArrayBuffer
&&
!
gadget
.
params
.
sourceBuffer
.
updating
)
{
gadget
.
params
.
sourceBuffer
.
appendBuffer
(
buffer
);
gadget
.
params
.
sourceBuffer
.
appendBuffer
(
buffer
);
gadget
.
params
.
sourceBuffer
.
onupdateend
=
function
()
{
return
new
RSVP
.
Queue
()
this
.
updateTotalTime
(
this
.
params
.
sourceBuffer
.
timestampOffset
);
.
push
(
function
()
{
}.
bind
(
gadget
);
return
promiseEventListener
(
gadget
.
params
.
sourceBuffer
,
'
updateend
'
,
false
);
})
.
push
(
function
()
{
gadget
.
params
.
max_progress_time
=
gadget
.
params
.
max_progress_time
>
gadget
.
params
.
sourceBuffer
.
timestampOffset
?
gadget
.
params
.
max_progress_time
:
gadget
.
params
.
sourceBuffer
.
timestampOffset
;
return
gadget
.
updateTotalTime
(
gadget
.
params
.
max_progress_time
);
});
}
}
if
(
buffer
===
undefined
&&
gadget
.
params
.
mediaSource
.
readyState
===
'
open
'
)
{
if
(
buffer
===
undefined
&&
gadget
.
params
.
mediaSource
.
readyState
===
'
open
'
)
{
gadget
.
params
.
mediaSource
.
endOfStream
();
gadget
.
params
.
mediaSource
.
endOfStream
();
}
}
if
(
gadget
.
params
.
replay
)
{
gadget
.
element
.
querySelector
(
'
audio
'
).
play
();
gadget
.
params
.
replay
=
false
;
}
});
});
})
})
...
@@ -103,7 +134,7 @@
...
@@ -103,7 +134,7 @@
gadget
.
params
.
name
=
params
.
name
;
gadget
.
params
.
name
=
params
.
name
;
gadget
.
params
.
end
=
false
;
gadget
.
params
.
end
=
false
;
gadget
.
params
.
index
=
0
;
gadget
.
params
.
index
=
0
;
gadget
.
time_offset
=
0
;
gadget
.
params
.
max_progress_time
=
0
;
gadget
.
params
.
mediaSource
=
new
MediaSource
();
gadget
.
params
.
mediaSource
=
new
MediaSource
();
audio
.
src
=
URL
.
createObjectURL
(
gadget
.
params
.
mediaSource
);
audio
.
src
=
URL
.
createObjectURL
(
gadget
.
params
.
mediaSource
);
...
@@ -161,7 +192,12 @@
...
@@ -161,7 +192,12 @@
}
}
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
changeState
({
currentTime
:
gadget
.
element
.
querySelector
(
'
audio
'
).
currentTime
});
return
promiseEventListener
(
gadget
.
params
.
sourceBuffer
,
'
updateend
'
,
false
);
})
.
push
(
function
()
{
gadget
.
params
.
max_progress_time
=
gadget
.
params
.
max_progress_time
>
gadget
.
params
.
sourceBuffer
.
timestampOffset
?
gadget
.
params
.
max_progress_time
:
gadget
.
params
.
sourceBuffer
.
timestampOffset
;
return
gadget
.
updateTotalTime
(
gadget
.
params
.
max_progress_time
);
});
});
})
})
...
@@ -174,11 +210,17 @@
...
@@ -174,11 +210,17 @@
'
timeupdate
'
,
'
timeupdate
'
,
false
,
false
,
function
()
{
function
()
{
if
(((
gadget
.
params
.
sourceBuffer
.
timestampOffset
+
gadget
.
params
.
time_offset
)
-
audio
.
currentTime
)
<
10
&&
!
gadget
.
params
.
requested
)
{
return
new
RSVP
.
Queue
()
gadget
.
params
.
requested
=
true
;
.
push
(
function
()
{
return
gadget
.
requestChunk
();
if
((
gadget
.
params
.
sourceBuffer
.
timestampOffset
-
audio
.
currentTime
)
<
10
&&
}
!
gadget
.
params
.
requested
)
{
return
gadget
.
changeState
({
currentTime
:
audio
.
currentTime
});
gadget
.
params
.
requested
=
true
;
return
gadget
.
requestChunk
();
}
})
.
push
(
function
()
{
return
gadget
.
changeState
({
currentTime
:
audio
.
currentTime
});
});
},
},
true
true
);
);
...
...
bt5/erp5_multimedia/SkinTemplateItem/portal_skins/erp5_multimedia/gadget_custom_player_controller_fallback.js.js
View file @
722dbdeb
...
@@ -39,6 +39,10 @@
...
@@ -39,6 +39,10 @@
throw
error
;
throw
error
;
});
});
})
})
.
declareMethod
(
'
updateAudioElementCurrentTime
'
,
function
(
time
)
{
this
.
element
.
querySelector
(
'
audio
'
).
currentTime
=
time
;
})
.
declareMethod
(
'
handlePlayPause
'
,
function
(
play
)
{
.
declareMethod
(
'
handlePlayPause
'
,
function
(
play
)
{
var
audio
=
this
.
element
.
querySelector
(
'
audio
'
);
var
audio
=
this
.
element
.
querySelector
(
'
audio
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment