Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/export.py

Issue 2721023002: Javascript audio player for the exported HTML file. (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/export.py
diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/export.py b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/export.py
index 4b025023a3859d7ddafa38c864cf00653597f575..a0cb41148de31f0c2c87cce35acf1dabc80edf74 100644
--- a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/export.py
+++ b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/export.py
@@ -18,7 +18,11 @@ class HtmlExport(object):
# CSS file parameters.
_CSS_FILEPATH = os.path.join(_PATH, 'results.css')
- _INLINE_CSS = True
+ _INLINE_CSS = False
+
+ # JS file parameters.
+ _JS_FILEPATH = os.path.join(_PATH, 'results.js')
+ _INLINE_JS = False
_NEW_LINE = '\n'
@@ -43,7 +47,7 @@ class HtmlExport(object):
html = (
'<html>' +
self._build_header() +
- '<body>' +
+ '<body onload="initialize()">' +
'<h1>Results from {}</h1>'.format(self._output_filepath) +
self._NEW_LINE.join(tables) +
'</body>' +
@@ -58,19 +62,34 @@ class HtmlExport(object):
"""
html = ['<head>', '<title>Results</title>']
+ # Function to append the lines of a text file to html.
+ def _embed_file(filepath):
+ with open(filepath) as f:
+ for l in f:
+ html.append(l.strip())
+
# CSS.
if self._INLINE_CSS:
# Embed.
html.append('<style>')
- with open(self._CSS_FILEPATH) as f:
- for l in f:
- html.append(l.strip())
+ _embed_file(self._CSS_FILEPATH)
html.append('</style>')
else:
# Link.
html.append('<link rel="stylesheet" type="text/css" '
'href="file://{}?">'.format(self._CSS_FILEPATH))
+ # Javascript.
+ if self._INLINE_JS:
+ # Embed.
+ html.append('<script>')
+ _embed_file(self._JS_FILEPATH)
+ html.append('</script>')
+ else:
+ # Link.
+ html.append('<script src="file://{}?"></script>'.format(
+ self._JS_FILEPATH))
+
html.append('</head>')
return self._NEW_LINE.join(html)

Powered by Google App Engine
This is Rietveld 408576698