Skip to content

Commit df46eb1

Browse files
authored
Support for browsers to play video streams (#994)
* Installs libavcodec-extra package for Firefox images. * Adds support for a PulseAudio virtual sink * Implement a test to validate if images can play video
1 parent 6fae7f2 commit df46eb1

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

NodeBase/Dockerfile.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ USER root
66
RUN apt-get update -qqy \
77
&& apt-get -qqy install \
88
xvfb \
9+
pulseaudio \
910
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
1011

1112
#==============================

NodeBase/start-selenium-node.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ if [ ! -e /opt/selenium/config.json ]; then
77
exit 1
88
fi
99

10+
# Start the pulseaudio server
11+
pulseaudio -D --exit-idle-time=-1
12+
13+
# Load the virtual sink and set it as default
14+
pacmd load-module module-virtual-sink sink_name=v1
15+
pacmd set-default-sink v1
16+
17+
# set the monitor of v1 sink to be the default source
18+
pacmd set-default-source v1.monitor
19+
1020
# In the long term the idea is to remove $HUB_PORT_4444_TCP_ADDR and $HUB_PORT_4444_TCP_PORT and only work with
1121
# $HUB_HOST and $HUB_PORT
1222
if [ ! -z "$HUB_HOST" ]; then

NodeFirefox/Dockerfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ USER root
66
ARG FIREFOX_VERSION=latest
77
RUN FIREFOX_DOWNLOAD_URL=$(if [ $FIREFOX_VERSION = "latest" ] || [ $FIREFOX_VERSION = "nightly-latest" ] || [ $FIREFOX_VERSION = "devedition-latest" ]; then echo "https://download.mozilla.org/?product=firefox-$FIREFOX_VERSION-ssl&os=linux64&lang=en-US"; else echo "https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2"; fi) \
88
&& apt-get update -qqy \
9-
&& apt-get -qqy --no-install-recommends install firefox \
9+
&& apt-get -qqy --no-install-recommends install firefox libavcodec-extra \
1010
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
1111
&& wget --no-verbose -O /tmp/firefox.tar.bz2 $FIREFOX_DOWNLOAD_URL \
1212
&& apt-get -y purge firefox \

tests/SeleniumTests/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import unittest
22
from selenium import webdriver
3+
from selenium.webdriver.common.by import By
4+
from selenium.webdriver.support.ui import WebDriverWait
5+
from selenium.webdriver.support import expected_conditions as EC
36
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
47

58

@@ -39,6 +42,20 @@ def test_visit_basic_auth_secured_page(self):
3942
page_message = driver.find_element_by_css_selector('.example p').text
4043
self.assertTrue(page_message == 'Congratulations! You must have the proper credentials.')
4144

45+
def test_play_video(self):
46+
driver = self.driver
47+
driver.get('https://hls-js.netlify.com/demo/')
48+
wait = WebDriverWait(driver, 30)
49+
video = wait.until(
50+
EC.element_to_be_clickable((By.TAG_NAME, 'video'))
51+
)
52+
video.click()
53+
wait.until(
54+
lambda d: d.find_element_by_tag_name('video').get_property('currentTime')
55+
)
56+
paused = video.get_property('paused')
57+
self.assertFalse(paused)
58+
4259
def tearDown(self):
4360
self.driver.quit()
4461

0 commit comments

Comments
 (0)