Skip to content

Commit

Permalink
Support for browsers to play video streams (#994)
Browse files Browse the repository at this point in the history
* Installs libavcodec-extra package for Firefox images.

* Adds support for a PulseAudio virtual sink

* Implement a test to validate if images can play video
  • Loading branch information
ehbello committed Mar 2, 2020
1 parent 6fae7f2 commit df46eb1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions NodeBase/Dockerfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ USER root
RUN apt-get update -qqy \
&& apt-get -qqy install \
xvfb \
pulseaudio \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

#==============================
Expand Down
10 changes: 10 additions & 0 deletions NodeBase/start-selenium-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ if [ ! -e /opt/selenium/config.json ]; then
exit 1
fi

# Start the pulseaudio server
pulseaudio -D --exit-idle-time=-1

# Load the virtual sink and set it as default
pacmd load-module module-virtual-sink sink_name=v1
pacmd set-default-sink v1

# set the monitor of v1 sink to be the default source
pacmd set-default-source v1.monitor

# In the long term the idea is to remove $HUB_PORT_4444_TCP_ADDR and $HUB_PORT_4444_TCP_PORT and only work with
# $HUB_HOST and $HUB_PORT
if [ ! -z "$HUB_HOST" ]; then
Expand Down
2 changes: 1 addition & 1 deletion NodeFirefox/Dockerfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ USER root
ARG FIREFOX_VERSION=latest
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) \
&& apt-get update -qqy \
&& apt-get -qqy --no-install-recommends install firefox \
&& apt-get -qqy --no-install-recommends install firefox libavcodec-extra \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
&& wget --no-verbose -O /tmp/firefox.tar.bz2 $FIREFOX_DOWNLOAD_URL \
&& apt-get -y purge firefox \
Expand Down
17 changes: 17 additions & 0 deletions tests/SeleniumTests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import unittest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities


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

def test_play_video(self):
driver = self.driver
driver.get('https://hls-js.netlify.com/demo/')
wait = WebDriverWait(driver, 30)
video = wait.until(
EC.element_to_be_clickable((By.TAG_NAME, 'video'))
)
video.click()
wait.until(
lambda d: d.find_element_by_tag_name('video').get_property('currentTime')
)
paused = video.get_property('paused')
self.assertFalse(paused)

def tearDown(self):
self.driver.quit()

Expand Down

0 comments on commit df46eb1

Please sign in to comment.