diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index f3f15ec9..00000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,937 +0,0 @@ -######################################## -# Basic Setup # -######################################## -cmake_minimum_required (VERSION 2.6) -SET(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Usr install prefix") -project (MistServer) - -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++98") - -SET(SOURCE_DIR ${PROJECT_SOURCE_DIR}) -SET(BINARY_DIR ${PROJECT_BINARY_DIR}) -set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) #For YCM support -include_directories(${SOURCE_DIR}) -include_directories(${BINARY_DIR} ${BINARY_DIR}/generated) - -option(BUILD_SHARED_LIBS "Build the libraries as shared (default = static)") - -######################################## -# Testing - Enable Tests # -######################################## -enable_testing() -include(CTest) - -######################################## -# Build Variables - Install Prefix # -######################################## -if (NOT CMAKE_INSTALL_PREFIX) - set (CMAKE_INSTALL_PREFIX /usr) -endif() - -######################################## -# Build Variables - Release # -######################################## -if (RELEASE) - set (RELEASE_RAW ${RELEASE}) -else() -#get the bitlength of this system - execute_process(COMMAND getconf LONG_BIT OUTPUT_VARIABLE RELEASE_RAW ) - set(RELEASE_RAW "Generic_${RELEASE_RAW}" ) -endif() -string(STRIP ${RELEASE_RAW} RELEASE) -set(RELEASE \"${RELEASE}\" ) - -######################################## -# Build Variables - Package Version # -######################################## -#See if we have a git repo to get the version from -execute_process(COMMAND git describe --tags OUTPUT_VARIABLE PACKAGE_VERSION_RAW ERROR_QUIET) -if (NOT PACKAGE_VERSION_RAW) - execute_process(COMMAND cat VERSION OUTPUT_VARIABLE PACKAGE_VERSION_RAW ERROR_QUIET) -endif() -if (NOT PACKAGE_VERSION_RAW) - set(PACKAGE_VERSION_RAW Unknown) -endif() -#strip off the trailing spaces and newline -string(STRIP "${PACKAGE_VERSION_RAW}" PACKAGE_VERSION) -set(PACKAGE_VERSION \"${PACKAGE_VERSION}\" ) - -######################################## -# Build Variables - Everything else # -######################################## -if (NOT DEBUG) - set(DEBUG 4) -endif() - -option(NOSHM "Disabled shared memory (falling back to shared temporary files)") -if (NOT NOSHM) - add_definitions(-DSHM_ENABLED=1) -else() - message("Shared memory use is turned OFF") -endif() - -if (FILLER_DATA AND SHARED_SECRET AND SUPER_SECRET) -add_definitions(-DFILLER_DATA="${FILLER_DATA}" -DSHARED_SECRET="${SHARED_SECRET}" -DSUPER_SECRET="${SUPER_SECRET}")#LTS -endif() - -option(NOSSL "Disable SSL/TLS support") -if (NOT NOSSL) - add_definitions(-DSSL=1) -else() - message("SSL/TLS support is turned OFF") -endif() - -if (DEFINED DATASIZE ) - add_definitions(-DSHM_DATASIZE=${DATASIZE}) -endif() - -if (DEFINED STAT_CUTOFF ) - add_definitions(-DSTAT_CUTOFF=${STAT_CUTOFF}) -endif() - -option(NOUPDATE "Disable the updater") -if (NOT NOUPDATE) - add_definitions(-DUPDATER=1) -endif() - -option(NOAUTH "Disable API authentication entirely (insecure!)") -if (NOAUTH) - add_definitions(-DNOAUTH=1) -endif() - -if (DEFINED UDP_API_HOST ) - add_definitions(-DUDP_API_HOST=${UDP_API_HOST}) -endif() - -if (DEFINED UDP_API_PORT ) - add_definitions(-DUDP_API_PORT=${UDP_API_PORT}) -endif() - -set(APPNAME "MistServer" CACHE STRING "Name of the application, as used in user agent strings and the like") -add_definitions(-DAPPNAME="${APPNAME}") - -set(DISKSERIAL "" CACHE STRING "Lock application to given disk serial number") -if (DISKSERIAL) - add_definitions(-DDISKSERIAL="${DISKSERIAL}") -endif() - -option(WITH_THREADNAMES "Enable fancy names for threads (not supported on all platforms)") -if (WITH_THREADNAMES) - add_definitions(-DWITH_THREADNAMES=1) -endif() - -if (DEFINED STATS_DELAY) - add_definitions(-DSTATS_DELAY=${STATS_DELAY}) -endif() - -option(NOLLHLS "Disable LLHLS") -if (NOLLHLS) - add_definitions(-DNOLLHLS=1) -endif() - -######################################## -# Build Variables - Prepare for Build # -######################################## -message("Builing release ${RELEASE} for version ${PACKAGE_VERSION} @ debug level ${DEBUG}") -add_definitions(-g -funsigned-char -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUG=${DEBUG} -DPACKAGE_VERSION=${PACKAGE_VERSION} -DRELEASE=${RELEASE}) -add_definitions(-Wall -Wno-sign-compare -Wparentheses) - -option(NOSRT "Disable building native SRT support, regardless of library being present (by default SRT is enabled if libraries are installed)") -if (NOT NOSRT) - find_library(SRT_LIB srt) - if(SRT_LIB) - add_definitions(-DWITH_SRT=1) - message("Building with SRT") - else() - message("Building without native SRT support") - endif() -else() - message("Building without native SRT support") -endif() - -option(NORIST "Disable building RIST support, regardless of library being present (by default RIST is enabled if libraries are installed)") -if (NOT NORIST) - find_library(RIST_LIB rist) - if(RIST_LIB) - add_definitions(-DWITH_RIST=1) - message("Building with RIST") - else() - message("Building without RIST support") - endif() -else() - message("Building without RIST support") -endif() - - -######################################## -# MistLib - Header Files # -######################################## -set(libHeaders - lib/adts.h - lib/amf.h - lib/auth.h - lib/encode.h - lib/bitfields.h - lib/bitstream.h - lib/certificate.h - lib/checksum.h - lib/cmaf.h - lib/comms.h - lib/config.h - lib/defines.h - lib/dtls_srtp_handshake.h - lib/dtsc.h - lib/encryption.h - lib/flac.h - lib/flv_tag.h - lib/h264.h - lib/h265.h - lib/hls_support.h - lib/http_parser.h - lib/downloader.h - lib/json.h - lib/langcodes.h - lib/mp4_adobe.h - lib/mp4_dash.cpp - lib/mp4_dash.h - lib/mp4_encryption.h - lib/mp4_generic.h - lib/mp4.h - lib/mp4_ms.h - lib/mpeg.h - lib/nal.h - lib/ogg.h - lib/procs.h - lib/rtmpchunks.h - lib/rtp_fec.h - lib/rtp.h - lib/sdp.h - lib/sdp_media.h - lib/shared_memory.h - lib/socket.h - lib/stream.h - lib/stun.h - lib/theora.h - lib/timing.h - lib/tinythread.h - lib/ts_packet.h - lib/ts_stream.h - lib/util.h - lib/vorbis.h - lib/triggers.h - lib/opus.h - lib/riff.h - lib/ebml.h - lib/ebml_socketglue.h - lib/websocket.h - lib/url.h - lib/urireader.h -) - -if(SRT_LIB) - list(APPEND libHeaders lib/socket_srt.h) -endif() - -######################################## -# MistLib - Build # -######################################## -add_library (mist - ${libHeaders} - lib/adts.cpp - lib/amf.cpp - lib/auth.cpp - lib/encode.cpp - lib/bitfields.cpp - lib/bitstream.cpp - lib/cmaf.cpp - lib/comms.cpp - lib/certificate.cpp - lib/config.cpp - lib/dtls_srtp_handshake.cpp - lib/dtsc.cpp - lib/encryption.cpp - lib/flac.cpp - lib/flv_tag.cpp - lib/h264.cpp - lib/h265.cpp - lib/hls_support.cpp - lib/http_parser.cpp - lib/downloader.cpp - lib/json.cpp - lib/langcodes.cpp - lib/mp4_adobe.cpp - lib/mp4.cpp - lib/mp4_dash.cpp - lib/mp4_encryption.cpp - lib/mp4_generic.cpp - lib/mp4_ms.cpp - lib/mpeg.cpp - lib/nal.cpp - lib/ogg.cpp - lib/procs.cpp - lib/rtmpchunks.cpp - lib/rtp_fec.cpp - lib/rtp.cpp - lib/sdp.cpp - lib/sdp_media.cpp - lib/shared_memory.cpp - lib/socket.cpp - lib/stream.cpp - lib/stun.cpp - lib/theora.cpp - lib/timing.cpp - lib/tinythread.cpp - lib/ts_packet.cpp - lib/ts_stream.cpp - lib/util.cpp - lib/vorbis.cpp - lib/triggers.cpp - lib/opus.cpp - lib/riff.cpp - lib/ebml.cpp - lib/ebml_socketglue.cpp - lib/websocket.cpp - lib/url.cpp - lib/urireader.cpp -) -if (NOT APPLE) - set (LIBRT -lrt) -endif() -target_link_libraries(mist - -lpthread - ${LIBRT} -) -if (NOT NOSSL) - target_link_libraries(mist mbedtls mbedx509 mbedcrypto) -endif() -install( - FILES ${libHeaders} - DESTINATION include/mist -) -install( - TARGETS mist - DESTINATION lib -) - - -if(SRT_LIB) - add_library(mist_srt lib/socket_srt.h lib/socket_srt.cpp) - target_link_libraries(mist_srt mist srt) - install( - TARGETS mist_srt - DESTINATION lib - ) -endif() - -######################################## -# MistLib - Local Header Install # -######################################## -if (${CMAKE_VERSION} VERSION_LESS 3.3.0) -add_custom_command(OUTPUT ${BINARY_DIR}/mist/.headers - COMMAND ${CMAKE_COMMAND} - ARGS -E make_directory ${BINARY_DIR}/mist - COMMAND cp - ARGS ${libHeaders} ${BINARY_DIR}/mist - COMMAND touch - ARGS ${BINARY_DIR}/mist/.headers - WORKING_DIRECTORY ${SOURCE_DIR} - DEPENDS ${libHeaders} -) -else() -add_custom_command(OUTPUT ${BINARY_DIR}/mist/.headers - COMMAND ${CMAKE_COMMAND} - ARGS -E make_directory ${BINARY_DIR}/mist - COMMAND ${CMAKE_COMMAND} - ARGS -E copy ${libHeaders} ${BINARY_DIR}/mist - COMMAND ${CMAKE_COMMAND} - ARGS -E touch ${BINARY_DIR}/mist/.headers - WORKING_DIRECTORY ${SOURCE_DIR} - DEPENDS ${libHeaders} -) -endif() - -######################################## -# MistServer - Analysers # -######################################## -macro(makeAnalyser analyserName format) - add_executable(MistAnalyser${analyserName} - src/analysers/mist_analyse.cpp - src/analysers/analyser.cpp - src/analysers/analyser_${format}.cpp - ${BINARY_DIR}/mist/.headers - ) - set_target_properties(MistAnalyser${analyserName} - PROPERTIES COMPILE_DEFINITIONS "ANALYSERHEADER=\"analyser_${format}.h\"; ANALYSERTYPE=Analyser${analyserName}" - ) - target_link_libraries(MistAnalyser${analyserName} - mist - ) - install( - TARGETS MistAnalyser${analyserName} - DESTINATION bin - ) -endmacro() - -makeAnalyser(RTMP rtmp) -makeAnalyser(FLV flv) -makeAnalyser(DTSC dtsc) -makeAnalyser(OGG ogg) -makeAnalyser(EBML ebml) -#makeAnalyser(RTSP rtsp) #LTS #Currently broken. Horribly. -makeAnalyser(TS ts) #LTS -makeAnalyser(MP4 mp4) #LTS -makeAnalyser(H264 h264) #LTS -makeAnalyser(HLS hls) #LTS -makeAnalyser(RIFF riff) #LTS -makeAnalyser(RTSP rtsp) #LTS -makeAnalyser(FLAC flac) - -#LTS_START -######################################## -# MistServer - Utilities # -######################################## -macro(makeUtil utilName utilFile) - add_executable(MistUtil${utilName} - src/utils/util_${utilFile}.cpp - ${BINARY_DIR}/mist/.headers - ) - target_link_libraries(MistUtil${utilName} - mist - ) - install( - TARGETS MistUtil${utilName} - DESTINATION bin - ) -endmacro() - -#makeUtil(Stats stats) -makeUtil(META meta) -makeUtil(RAX rax) -makeUtil(AMF amf) -makeUtil(Certbot certbot) -makeUtil(Nuke nuke) -option(LOAD_BALANCE "Build the load balancer") -if (LOAD_BALANCE) - makeUtil(Load load) -endif() -#LTS_END - -add_executable(MistTranslateH264 - src/analysers/h264_translate.cpp - ${BINARY_DIR}/mist/.headers -) -target_link_libraries(MistTranslateH264 - mist -) - -######################################## -# MistServer - Inputs # -######################################## -macro(makeInput inputName format) - add_executable(MistIn${inputName} - src/input/mist_in.cpp - src/input/input.cpp - src/input/input_${format}.cpp - src/io.cpp - ${BINARY_DIR}/mist/.headers - ) - if (";${ARGN};" MATCHES ";with_srt;") - target_link_libraries(MistIn${inputName} mist_srt ) - endif() - if (";${ARGN};" MATCHES ";with_rist;") - target_link_libraries(MistIn${inputName} rist cjson) - endif() - - #Set compile definitions - unset(my_definitions) - list(APPEND my_definitions "INPUTTYPE=\"input_${format}.h\"") - - set_target_properties(MistIn${inputName} - PROPERTIES COMPILE_DEFINITIONS "${my_definitions}" - ) - - target_link_libraries(MistIn${inputName} mist) - install( - TARGETS MistIn${inputName} - DESTINATION bin - ) -endmacro() - -makeInput(HLS hls) -makeInput(DTSC dtsc) -makeInput(MP3 mp3) -makeInput(FLV flv) -makeInput(FLAC flac) - -option(WITH_AV "Build a generic libav-based input (not distributable!)") -makeInput(OGG ogg) -makeInput(Buffer buffer) -makeInput(H264 h264) -makeInput(EBML ebml) -makeInput(ISMV ismv)#LTS -makeInput(MP4 mp4) -makeInput(TS ts)#LTS -makeInput(Folder folder)#LTS -makeInput(Playlist playlist)#LTS -makeInput(Balancer balancer)#LTS -makeInput(RTSP rtsp)#LTS -makeInput(SubRip subrip)#LTS -makeInput(SDP sdp) - -if(SRT_LIB) - makeInput(TSSRT tssrt with_srt)#LTS -endif() -if(RIST_LIB) - makeInput(TSRIST tsrist with_rist)#LTS -endif() - -makeInput(AAC aac) -makeInput(V4L2 v4l2) - -######################################## -# MistServer - Outputs # -######################################## -macro(makeOutput outputName format) - #Parse all extra arguments, for http and ts flags - SET (tsBaseClass Output) - SET (outBaseFile src/output/mist_out.cpp) - if (";${ARGN};" MATCHES ";http;") - SET(httpOutput src/output/output_http.cpp) - if (";${ARGN};" MATCHES ";ts;") - SET(tsBaseClass HTTPOutput) - endif() - endif() - if (";${ARGN};" MATCHES ";debased;") - SET(outBaseFile "") - endif() - if (";${ARGN};" MATCHES ";ts;") - SET(tsOutput src/output/output_ts_base.cpp) - endif() - if (";${ARGN};" MATCHES ";jpg;") - SET(tsOutput generated/noffmpeg.h generated/noh264.h) - endif() - if (";${ARGN};" MATCHES ";srtp;") - SET(tsOutput src/output/output_webrtc_srtp.h src/output/output_webrtc_srtp.cpp) - endif() - add_executable(MistOut${outputName} - ${outBaseFile} - src/output/output.cpp - src/output/output_${format}.cpp - src/io.cpp - ${httpOutput} - ${tsOutput} - ${mp4Output} - ${BINARY_DIR}/mist/.headers - ) - set_target_properties(MistOut${outputName} - PROPERTIES COMPILE_DEFINITIONS "OUTPUTTYPE=\"output_${format}.h\";TS_BASECLASS=${tsBaseClass}" - ) - if (";${ARGN};" MATCHES ";with_srt;") - target_link_libraries(MistOut${outputName} mist_srt) - endif() - if (";${ARGN};" MATCHES ";with_rist;") - target_link_libraries(MistOut${outputName} rist cjson) - endif() - if (";${ARGN};" MATCHES ";srtp;") - target_link_libraries(MistOut${outputName} srtp2) - endif() - target_link_libraries(MistOut${outputName} mist ) - install( - TARGETS MistOut${outputName} - DESTINATION bin - ) -endmacro() - -makeOutput(RTMP rtmp) -makeOutput(DTSC dtsc) -makeOutput(JSONLine jsonline) -makeOutput(OGG ogg http) -makeOutput(FLV flv http) -makeOutput(HTTPMinimalServer http_minimalserver http) -makeOutput(MP4 mp4 http) -makeOutput(AAC aac http) -makeOutput(MP3 mp3 http) -makeOutput(H264 h264 http) -makeOutput(HDS hds http) -makeOutput(SubRip srt http) -makeOutput(JSON json http) -option(WITH_JPG "Build JPG thumbnailer output support") -if (WITH_JPG) - makeOutput(JPG jpg http jpg) -endif() -makeOutput(TS ts ts) -if(SRT_LIB) - makeOutput(TSSRT tssrt ts debased with_srt) -endif() -if(RIST_LIB) - makeOutput(TSRIST tsrist ts debased with_rist) -endif() -makeOutput(HTTPTS httpts http ts) -makeOutput(HLS hls http ts) -makeOutput(CMAF cmaf http)#LTS -makeOutput(EBML ebml) -makeOutput(RTSP rtsp)#LTS -makeOutput(WAV wav)#LTS -makeOutput(SDP sdp http) -makeOutput(FLAC flac http) - -add_executable(MistSession - ${BINARY_DIR}/mist/.headers - src/session.cpp -) -install( - TARGETS MistSession - DESTINATION bin -) -target_link_libraries(MistSession mist) - - -add_executable(MistProcFFMPEG - ${BINARY_DIR}/mist/.headers - src/process/process_ffmpeg.cpp - src/output/output_ebml.cpp - src/input/input_ebml.cpp - src/input/input.cpp - src/output/output_http.cpp - src/output/output.cpp - src/io.cpp -) -target_link_libraries(MistProcFFMPEG mist) - -add_executable(MistProcMKVExec - ${BINARY_DIR}/mist/.headers - src/process/process_exec.cpp - src/output/output_ebml.cpp - src/input/input_ebml.cpp - src/input/input.cpp - src/output/output_http.cpp - src/output/output.cpp - src/io.cpp -) -target_link_libraries(MistProcMKVExec mist) - -add_executable(MistProcLivepeer - ${BINARY_DIR}/mist/.headers - src/process/process_livepeer.cpp - src/input/input.cpp - src/output/output_http.cpp - src/output/output_ts_base.cpp - src/output/output.cpp - src/io.cpp -) -target_link_libraries(MistProcLivepeer mist) - -if (NOT NOSSL) - makeOutput(HTTPS https)#LTS - makeOutput(WebRTC webrtc http srtp)#LTS -endif() - -option(WITH_SANITY "Enable MistOutSanityCheck output for testing purposes") -if (WITH_SANITY) - makeOutput(SanityCheck sanitycheck)#LTS -endif() - -add_executable(MistOutHTTP - ${BINARY_DIR}/mist/.headers - src/output/mist_out.cpp - src/output/output.cpp - src/output/output_http.cpp - src/output/output_http_internal.cpp - src/io.cpp - generated/player.js.h - generated/html5.js.h - generated/flash_strobe.js.h - generated/dashjs.js.h - generated/videojs.js.h - generated/webrtc.js.h - generated/mews.js.h - generated/flv.js.h - generated/hlsjs.js.h - generated/rawws.js.h - generated/player_dash.js.h - generated/player_dash_lic.js.h - generated/player_video.js.h - generated/player_webrtc.js.h - generated/player_flv.js.h - generated/player_hlsjs.js.h - generated/player_libde265.js.h - generated/skin_default.css.h - generated/skin_dev.css.h - generated/skin_videojs.css.h -) -set_target_properties(MistOutHTTP - PROPERTIES COMPILE_DEFINITIONS "OUTPUTTYPE=\"output_http_internal.h\"" -) -target_link_libraries(MistOutHTTP mist) -install( - TARGETS MistOutHTTP - DESTINATION bin -) - -######################################## -# Documentation # -######################################## -find_package(Doxygen) -if(DOXYGEN_FOUND) - set(DOXY_LAYOUT "${SOURCE_DIR}/DoxygenLayout.xml") - set(INPUT_DIRS "${SOURCE_DIR}/src ${SOURCE_DIR}/lib") - configure_file(${SOURCE_DIR}/Doxyfile.in ${BINARY_DIR}/Doxyfile @ONLY) - add_custom_target( docs - ${DOXYGEN_EXECUTABLE} ${BINARY_DIR}/Doxyfile - COMMAND rm -rf ${BINARY_DIR}/docs - COMMAND mv ${SOURCE_DIR}/docs ${BINARY_DIR} - WORKING_DIRECTORY ${SOURCE_DIR} - COMMENT "Generating API documentation with Doxygen" - VERBATIM - ) -endif(DOXYGEN_FOUND) - -######################################## -# Sourcery # -######################################## -#If cross compiling, assume failure. -if (CMAKE_CROSSCOMPILING) - set(RUNA "1") -else() - try_run(RUNA RUNB ${BINARY_DIR}/CMakeTmp ${SOURCE_DIR}/src/sourcery.cpp ) -endif() - -if("${RUNA}" EQUAL "42") - message("Not cross compiling - building sourcery") - add_executable(sourcery - src/sourcery.cpp - ) -else() - message("Detected cross compiling") - if (EXISTS "${SOURCE_DIR}/sourcery") - if (EXISTS "${BINARY_DIR}/sourcery") - add_custom_target(sourcery ) - else() - add_custom_target(sourcery - COMMAND cp ${SOURCE_DIR}/sourcery ${BINARY_DIR}/sourcery - ) - endif() - else() - message(FATAL_ERROR "Cross compiling and no usable sourcery binary found - please supply it") - endif() -endif() - -######################################## -# Embed Code # -######################################## -# main -add_custom_command(OUTPUT generated/player.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/min/player.js player_js generated/player.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/min/player.js -) -# wrappers -add_custom_command(OUTPUT generated/html5.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/min/wrappers/html5.js html5_js generated/html5.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/min/wrappers/html5.js -) -add_custom_command(OUTPUT generated/flash_strobe.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/min/wrappers/flash_strobe.js flash_strobe_js generated/flash_strobe.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/min/wrappers/flash_strobe.js -) -add_custom_command(OUTPUT generated/dashjs.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/min/wrappers/dashjs.js dash_js generated/dashjs.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/min/wrappers/dashjs.js -) -add_custom_command(OUTPUT generated/videojs.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/min/wrappers/videojs.js video_js generated/videojs.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/min/wrappers/videojs.js -) -add_custom_command(OUTPUT generated/webrtc.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/min/wrappers/webrtc.js webrtc_js generated/webrtc.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/min/wrappers/webrtc.js -) -add_custom_command(OUTPUT generated/mews.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/min/wrappers/mews.js mews_js generated/mews.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/min/wrappers/mews.js -) -add_custom_command(OUTPUT generated/flv.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/min/wrappers/flv.js flv_js generated/flv.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/min/wrappers/flv.js -) -add_custom_command(OUTPUT generated/hlsjs.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/min/wrappers/hlsjs.js hlsjs_js generated/hlsjs.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/min/wrappers/hlsjs.js -) -add_custom_command(OUTPUT generated/rawws.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/min/wrappers/rawws.js rawws_js generated/rawws.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/min/wrappers/rawws.js -)# players -add_custom_command(OUTPUT generated/player_dash_lic.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/players/dash.js.license.js player_dash_lic_js generated/player_dash_lic.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/players/dash.js.license.js -) -add_custom_command(OUTPUT generated/player_dash.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/players/dash.all.min.js player_dash_js generated/player_dash.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/players/dash.all.min.js -) -add_custom_command(OUTPUT generated/player_video.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/players/video.min.js player_video_js generated/player_video.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/players/video.min.js -) -add_custom_command(OUTPUT generated/player_webrtc.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/players/webrtc.js player_webrtc_js generated/player_webrtc.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/players/webrtc.js -) -add_custom_command(OUTPUT generated/player_flv.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/players/flv.min.js player_flv_js generated/player_flv.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/players/flv.min.js -) -add_custom_command(OUTPUT generated/player_hlsjs.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/players/hls.js player_hlsjs_js generated/player_hlsjs.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/players/hls.js -) -add_custom_command(OUTPUT generated/player_libde265.js.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/players/libde265.min.js player_libde265_js generated/player_libde265.js.h - DEPENDS sourcery ${SOURCE_DIR}/embed/players/libde265.min.js -) -# css -add_custom_command(OUTPUT generated/skin_default.css.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/min/skins/default.css skin_default_css generated/skin_default.css.h - DEPENDS sourcery ${SOURCE_DIR}/embed/min/skins/default.css -) -add_custom_command(OUTPUT generated/skin_dev.css.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/min/skins/dev.css skin_dev_css generated/skin_dev.css.h - DEPENDS sourcery ${SOURCE_DIR}/embed/min/skins/dev.css -) -add_custom_command(OUTPUT generated/skin_videojs.css.h - COMMAND ./sourcery ${SOURCE_DIR}/embed/skins/video-js.css skin_videojs_css generated/skin_videojs.css.h - DEPENDS sourcery ${SOURCE_DIR}/embed/skins/video-js.css -) - -######################################## -# JPG output # -######################################## -add_custom_command(OUTPUT generated/noffmpeg.h - COMMAND ./sourcery ${SOURCE_DIR}/src/output/noffmpeg.jpg noffmpeg generated/noffmpeg.h - DEPENDS sourcery ${SOURCE_DIR}/src/output/noffmpeg.jpg -) -add_custom_command(OUTPUT generated/noh264.h - COMMAND ./sourcery ${SOURCE_DIR}/src/output/noh264.jpg noh264 generated/noh264.h - DEPENDS sourcery ${SOURCE_DIR}/src/output/noh264.jpg -) - -######################################## -# Local Settings Page # -######################################## -set(lspSOURCES - ${SOURCE_DIR}/lsp/plugins/jquery.js - ${SOURCE_DIR}/lsp/plugins/jquery.flot.min.js - ${SOURCE_DIR}/lsp/plugins/jquery.flot.time.min.js - ${SOURCE_DIR}/lsp/plugins/jquery.qrcode.min.js - ${SOURCE_DIR}/lsp/minified.js -) - - -option(NOGA "Disables Google Analytics entirely in the LSP") -if (NOT NOGA) - list(APPEND lspSOURCES ${SOURCE_DIR}/lsp/analytics.js) -endif() - -add_custom_command(OUTPUT ${BINARY_DIR}/generated/server.html - COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR="${SOURCE_DIR}" -DlspSOURCES="${lspSOURCES}" -P ${SOURCE_DIR}/CMakeServHtml.txt - DEPENDS ${lspSOURCES} ${SOURCE_DIR}/CMakeServHtml.txt ${SOURCE_DIR}/lsp/main.css ${SOURCE_DIR}/lsp/header.html ${SOURCE_DIR}/lsp/footer.html -) -add_custom_command(OUTPUT generated/server.html.h - COMMAND ./sourcery generated/server.html server_html generated/server.html.h - DEPENDS sourcery ${BINARY_DIR}/generated/server.html -) - -######################################## -# MistController - Build # -######################################## -add_executable(MistController - src/controller/controller_external_writers.h - src/controller/controller_limits.h - src/controller/controller_uplink.h - src/controller/controller_api.h - src/controller/controller_statistics.h - src/controller/controller_connectors.h - src/controller/controller_storage.h - src/controller/controller_updater.h - src/controller/controller_capabilities.h - src/controller/controller_streams.h - src/controller/controller_push.h - src/controller/controller_variables.h - src/controller/controller.cpp - src/controller/controller_external_writers.cpp - src/controller/controller_updater.cpp - src/controller/controller_streams.cpp - src/controller/controller_storage.cpp - src/controller/controller_connectors.cpp - src/controller/controller_statistics.cpp - src/controller/controller_limits.cpp - src/controller/controller_capabilities.cpp - src/controller/controller_uplink.cpp - src/controller/controller_api.cpp - src/controller/controller_push.cpp - src/controller/controller_variables.cpp - generated/server.html.h - ${BINARY_DIR}/mist/.headers -) -set_target_properties(MistController - PROPERTIES COMPILE_DEFINITIONS RELEASE=${RELEASE} -) -target_link_libraries(MistController - mist -) -install( - TARGETS MistController - DESTINATION bin -) - -######################################## -# Make Clean # -######################################## -add_custom_target(clean-all - COMMAND ${CMAKE_BUILD_TOOL} clean - COMMAND rm -rf ${BINARY_DIR}/CMakeCache.txt - COMMAND rm -rf ${BINARY_DIR}/cmake_install.cmake - COMMAND rm -rf ${BINARY_DIR}/Makefile - COMMAND rm -rf ${BINARY_DIR}/CMakeFiles - COMMAND rm -rf ${BINARY_DIR}/Testing - COMMAND rm -rf ${BINARY_DIR}/CTestTestfile.cmake - COMMAND rm -rf ${BINARY_DIR}/DartConfiguration.tcl - COMMAND rm -rf ${BINARY_DIR}/mist -) - -######################################## -# Tests # -######################################## -add_executable(urltest test/url.cpp ${BINARY_DIR}/mist/.headers) -target_link_libraries(urltest mist) -add_test(URLTest COMMAND urltest) -add_executable(logtest test/log.cpp ${BINARY_DIR}/mist/.headers) -target_link_libraries(logtest mist) -add_test(LOGTest COMMAND logtest) -add_executable(logconvertertest test/converter.cpp ${BINARY_DIR}/mist/.headers) -target_link_libraries(logconvertertest mist) -add_test(LOGConverterTest COMMAND logconvertertest) -add_executable(downloadertest test/downloader.cpp ${BINARY_DIR}/mist/.headers) -target_link_libraries(downloadertest mist) -add_test(DownloaderTest COMMAND downloadertest) -add_executable(urireadertest test/urireader.cpp ${BINARY_DIR}/mist/.headers) -target_link_libraries(urireadertest mist) -add_test(URIReaderTest COMMAND urireadertest) -add_executable(jsontest test/json.cpp ${BINARY_DIR}/mist/.headers) -target_link_libraries(jsontest mist) -add_test(JSONTest COMMAND jsontest) -add_executable(resolvetest test/resolve.cpp ${BINARY_DIR}/mist/.headers) -target_link_libraries(resolvetest mist) -add_executable(bitwritertest test/bitwriter.cpp ${BINARY_DIR}/mist/.headers) -target_link_libraries(bitwritertest mist) -add_test(BitWriterTest COMMAND bitwritertest) -add_executable(streamstatustest test/status.cpp ${BINARY_DIR}/mist/.headers) -target_link_libraries(streamstatustest mist) -add_executable(websockettest test/websocket.cpp ${BINARY_DIR}/mist/.headers) -target_link_libraries(websockettest mist) -add_executable(dtsc_sizing_test test/dtsc_sizing.cpp ${BINARY_DIR}/mist/.headers) -target_link_libraries(dtsc_sizing_test mist) diff --git a/CMakeServHtml.txt b/CMakeServHtml.txt deleted file mode 100644 index 96245c68..00000000 --- a/CMakeServHtml.txt +++ /dev/null @@ -1,11 +0,0 @@ -set(lspCode "") -string(REPLACE " " ";" lspLIST ${lspSOURCES}) -foreach (f ${lspLIST} ) - file (READ ${f} s) - set (lspCode "${lspCode}${s}") -endforeach() -file(READ ${SOURCE_DIR}/lsp/main.css lspCSS) -file(READ ${SOURCE_DIR}/lsp/header.html lspHeader) -file(READ ${SOURCE_DIR}/lsp/footer.html lspFooter) -file(WRITE generated/server.html "${lspHeader}${lspFooter}") - diff --git a/README.md b/README.md index 21962883..221e53e3 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ You can also manually install, full instructions can be found in our manual: htt Compile instructions ==================== -The recommended build system for compiling MistServer is Meson. +The only supported build system for compiling MistServer is Meson, since CMake support was discontinued in MistServer 3.4. The project makes full use of Meson's support for "wraps" and all dependencies can be automatically fulfilled through this system. If a system-wide library is available (and compatible), that one will be preferred. diff --git a/embed/min/player.js b/embed/min/player.js index a26da177..c5ea48bd 100644 --- a/embed/min/player.js +++ b/embed/min/player.js @@ -1 +1 @@ -var MistUtil={format:{time:function(e,t){if(isNaN(e)||!isFinite(e))return e;t||(t={});var i=e<0?" ago":"";e=Math.abs(e);var r=Math.floor(e/86400);e-=86400*r;var n=Math.floor(e/3600);e-=3600*n;var a=Math.floor(e/60),s=Math.round(e%1*1e3);e=Math.floor(e-60*a);var o=[];return r&&(r=r+" day"+(r>1?"s":"")+", "),n||r?(o.push(n),o.push(("0"+a).slice(-2))):o.push(a),o.push(("0"+Math.floor(e)).slice(-2)),t.ms&&(o[o.length-1]+="."+("000"+s).slice(-3)),(r||"")+o.join(":")+i},ago:function(e,t){if(isNaN(e.getTime()))return"";var i=t||(new Date).getTime()-e.getTime(),r="",n=i<0;return n&&(i*=-1),i<1e3?r="live":i<6e4?(r=Math.round(i/1e3)+" sec",n?r="in "+r:r+=" ago"):r=!t&&(new Date).toLocaleDateString()==e.toLocaleDateString()||t<864e5?e.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",second:"2-digit"}):i<5184e5?e.toLocaleString(void 0,{weekday:"short",hour:"numeric",minute:"2-digit",second:"2-digit"}):!t&&(new Date).getFullYear()==e.getFullYear()||t<316224e5?e.toLocaleString(void 0,{month:"short",day:"numeric",weekday:"short",hour:"numeric",minute:"2-digit",second:"2-digit"}):e.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}),r},ucFirst:function(e){return e.charAt(0).toUpperCase()+e.slice(1)},number:function(e){if(isNaN(Number(e))||0==Number(e))return e;var t=Math.max(3,Math.ceil(Math.log(e)/Math.LN10)),i=Math.pow(10,t-Math.floor(Math.log(e)/Math.LN10)-1);if((e=Math.round(e*i)/i)>=1e4){number=e.toString().split(".");for(var r=/(\d+)(\d{3})/;r.test(number[0]);)number[0]=number[0].replace(r,"$1 $2");e=number.join(".")}return e},bytes:function(e,t){if(isNaN(Number(e)))return e;var i=t?["bits","Kb","Mb","Gb","Tb","Pb"]:["bytes","KB","MB","GB","TB","PB"];if(0==e)unit=i[0];else{var r=Math.floor(Math.log(Math.abs(e))/Math.log(1024));r<0?unit=i[0]:(e/=Math.pow(1024,r),unit=i[r])}return this.number(e)+unit},bits:function(e){return this.bytes(e,!0)},mime2human:function(e){switch(e){case"html5/video/webm":return"WebM";case"html5/application/vnd.apple.mpegurl":return"HLS (TS)";case"html5/application/vnd.apple.mpegurl;version=7":return"HLS (CMAF)";case"flash/10":return"Flash (RTMP)";case"flash/11":return"Flash (HDS)";case"flash/7":return"Flash (Progressive)";case"html5/video/mpeg":return"TS";case"html5/application/vnd.ms-sstr+xml":case"html5/application/vnd.ms-ss":return"Smooth Streaming";case"dash/video/mp4":return"DASH";case"webrtc":return"WebRTC (WS)";case"whep":return"WebRTC (WHEP)";case"silverlight":return"Smooth streaming (Silverlight)";case"html5/text/vtt":return"VTT subtitles";case"html5/text/plain":return"SRT subtitles";default:return e.replace("html5/","").replace("video/","").replace("audio/","").toLocaleUpperCase()}}},class:{add:function(e,t){if("classList"in e)e.classList.add(t);else{var i=this.get(e);i.push(t),this.set(e,i)}},remove:function(e,t){if("classList"in e)e.classList.remove(t);else{for(var i=this.get(e),r=i.length-1;r>=0;r--)i[r]==t&&i.splice(r);this.set(e,i)}},get:function(e){var t=e.getAttribute("class");return t&&""!=t?t.split(" "):[]},set:function(e,t){e.setAttribute("class",t.join(" "))},has:function(e,t){return e.className.split(" ").indexOf(t)>=0}},object:{extend:function(e,t,i){for(var r in t)i&&"object"==typeof t[r]&&!("nodeType"in t[r])?(r in e||(MistUtil.array.is(t[r])?e[r]=[]:e[r]={}),this.extend(e[r],t[r],!0)):e[r]=t[r];return e},keys:function(e,t){var i=[];for(var r in e)i.push(r);return t&&("function"!=typeof t&&(t=function(e,t){return e.localeCompare(t)}),i.sort((function(i,r){return t(i,r,e[i],e[r])}))),i},values:function(e,t){var i=this.keys(e,t);for(var r in values=[],i)values.push(e[i[r]]);return values}},array:{indexOf:function(e,t){if(!(e instanceof Array))throw"Tried to use indexOf on something that is not an array";if("indexOf"in e)return e.indexOf(t);for(var i;it?1:e=0?r:i.length}if("function"==typeof e)return e(t);if("object"==typeof e){if(e instanceof Array)return i(t,e[0],e[1]);for(var r in e)return i(t,r,e[r])}if(e in t)return t[e];throw"Invalid sorting rule: "+e+". This should be a function, object or key of "+JSON.stringify(t)+"."}return e.sort((function(e,n){var a=0;for(var s in t){var o=t[s];if(0!=(a=i(r(o,e),r(o,n))))break}return a})),e}},createUnique:function(){var e="uid"+Math.random().toString().replace("0.","");return document.querySelector("."+e)?createUnique():e},http:{getpost:function(e,t,i,r,n){var a=new XMLHttpRequest;if(a.open(e,t,!0),"POST"==e&&a.setRequestHeader("Content-type","application/x-www-form-urlencoded"),n&&(a.timeout=8e3),a.onload=function(){var e=a.status;e>=200&&e<300?r(a.response):n&&n(a)},n&&(a.onerror=function(){n(a)},a.ontimeout=a.onerror),"POST"==e){var s,o=[];for(var l in i)o.push(l+"="+encodeURIComponent(i[l]));o.length&&(s=o.join("&")),a.send(s)}else a.send()},get:function(e,t,i){this.getpost("GET",e,null,t,i)},post:function(e,t,i,r){this.getpost("POST",e,t,i,r)},url:{addParam:function(e,t){var i=e.split("?"),r=[i.shift()],n=[];for(var a in i.length&&(n=i[0].split("&")),t)n.push(a+"="+t[a]);return n.length&&r.push(n.join("&")),r.join("?")},append:function(e,t){var i=document.createElement("a");return i.href=e,"?"==t[0]?""==i.search?i.search=t:i.search+="&"+t.slice(1):"&"==t[0]?""==i.search?i.search="?"+t.slice(1):i.search+=t:i.href+=t,i.href},split:function(e){var t=document.createElement("a");return t.href=e,{protocol:t.protocol,host:t.hostname,hash:t.hash,port:t.port,path:t.pathname.replace(/\/*$/,"")}},sanitizeHost:function(e){var t=MistUtil.http.url.split(e);return t.protocol+"//"+t.host+(t.port&&""!=t.port?":"+t.port:"")+(t.hash&&""!=t.hash?"#"+t.hash:"")+(t.path?"/"==t.path.charAt(0)?t.path:"/"+t.path:"")}}},css:{cache:{},load:function(e,t,i){var r=document.createElement("style");r.type="text/css",r.setAttribute("data-source",e),i&&(r.callback=i);var n=this.cache;function a(e){var i=MistUtil.css.applyColors(e,t);"callback"in r?r.callback(i):r.textContent=i}if(e in n)n[e]instanceof Array?n[e].push(a):a(n[e]);else{n[e]=[a];var s=3;!function t(){MistUtil.http.get(e,(function(t){for(var i in n[e])n[e][i](t);n[e]=t}),(function(){if(s>0)s--,setTimeout(t,2e3);else{var i="/*Failed to load*/";for(var r in n[e])n[e][r](i);n[e]=i}}))}()}return r},applyColors:function(e,t){return e.replace(/\$([^\s^;^}]*)/g,(function(e,i){var r=i.split("."),n=t;for(var a in r)n=n[r[a]];return n}))},createStyle:function(e,t,i){var r=document.createElement("style");return r.type="text/css",e&&(t&&(e=this.prependClass(e,t,i)),r.textContent=e),r},prependClass:function(e,t,i){var r=!1;"string"!=typeof e&&("unprepended"in(r=e)||(r.unprepended=r.textContent),e=r.unprepended);var n=(e=e.replace(/\/\*.*?\*\//g,"")).match(/@[^}]*}/g);for(var a in n){e=e.replace(n[a],"@@#@@");for(var s=1;s0)s=r.bps>131072?Math.round(r.bps/1024/1024*8)+"mbps":Math.round(r.bps/1024*8)+"kbps",n[a]=s;break;case"fpks":r.fpks>0&&(n[a]=r.fpks/1e3+"fps");break;case"channels":r.channels>0&&(n[a]=1==r.channels?"Mono":2==r.channels?"Stereo":"Surround ("+r.channels+"ch)");break;case"rate":n[a]=Math.round(.001*r.rate)+"Khz";break;case"language":"Undetermined"!=r[a]&&(n[a]=r[a]);break;case"codec":if("meta"==r.codec)continue;n[a]=r[a]}r.describe=n}for(var o in t){var l=!1;for(var i in t[o])if(l){if(MistUtil.object.keys(t[o]).length>1)for(var a in t[o][i].describe)l[a]!=t[o][i].describe[a]&&delete l[a]}else l=MistUtil.object.extend({},t[o][i].describe);for(var i in t[o]){var c={},d={};for(var a in t[o][i].describe)a in l?d[a]=t[o][i].describe[a]:c[a]=t[o][i].describe[a];t[o][i].different=c,t[o][i].same=d;var u=MistUtil.object.values(c);t[o][i].displayName=u.length?u.join(", "):MistUtil.object.values(t[o][i].describe).join(" ")}var p={};for(var i in t[o]){if(t[o][i].displayName in p){var h=1;for(var i in t[o])t[o][i].different.trackid=h+")",t[o][i].displayName="Track "+h+" ("+t[o][i].displayName+")",h++;break}p[t[o][i].displayName]=1}}return t},translateCodec:function(e){function t(t){return("0"+e.init.charCodeAt(t).toString(16)).slice(-2)}switch(e.codec){case"AAC":return"mp4a.40.2";case"MP3":return"mp3";case"AC3":return"ec-3";case"H264":return"avc1."+t(1)+t(2)+t(3);case"HEVC":return"hev1."+t(1)+t(6)+t(7)+t(8)+t(9)+t(10)+t(11)+t(12);default:return e.codec.toLowerCase()}}},isTouchDevice:function(){return"ontouchstart"in window||navigator.msMaxTouchPoints>0},getPos:function(e,t){e.currentStyle||window.getComputedStyle(e,null);for(var i=1,r=e;r;)r.style.zoom&&""!=r.style.zoom&&(i*=parseFloat(r.style.zoom,10)),r=r.parentElement;var n=e.getBoundingClientRect().left-(parseInt(e.borderLeftWidth,10)||0),a=e.getBoundingClientRect().width,s=Math.max(0,(t.clientX/i-n)/a);return s=Math.min(s,1)},createGraph:function(e,t){var i="http://www.w3.org/2000/svg",r=document.createElementNS(i,"svg");r.setAttributeNS(null,"height","100%"),r.setAttributeNS(null,"width","100%"),r.setAttributeNS(null,"class","mist icon graph"),r.setAttributeNS(null,"preserveAspectRatio","none");var n=e.x[0],a=e.y[0];if(t.differentiate)for(var s=1;st.x.count&&(l.shift(),d()),d(e.x-n,-1*e.y),this.setAttributeNS(null,"d","M"+l.join(" L")),h()}},r.addData=function(e){m.addData(e)},r},getBrowser:function(){var e=window.navigator.userAgent;return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0?"ie":e.indexOf("Edge/")>=0?"edge":e.indexOf("Opera")>=0||e.indexOf("OPR")>=0?"opera":e.indexOf("Chrome")>=0?"chrome":e.indexOf("Safari")>=0?"safari":e.indexOf("Firefox")>=0&&"firefox"},getAndroid:function(){var e=navigator.userAgent.toLowerCase().match(/android\s([\d\.]*)/i);return!!e&&e[1]},sources:{find:function(e,t){e:for(var i in e){for(var r in t)if("protocol"==r){if(e[i].url.slice(0,t.protocol.length)!=t.protocol)continue e}else if(e[i][r]!=t[r])continue e;return e[i]}return!1}}};if(void 0===MistSkins)var MistSkins={};if("undefined"!=typeof mistoptions&&"host"in mistoptions)var misthost=MistUtil.http.url.sanitizeHost(mistoptions.host);else misthost="..";function MistSkin(e){e.skin=this,this.applySkinOptions=function(t){var i;return"string"==typeof t&&t in MistSkins&&(t=MistUtil.object.extend({},MistSkins[t],!0)),i="inherit"in t&&t.inherit&&t.inherit in MistSkins?this.applySkinOptions(t.inherit):MistSkins.default,this.structure=MistUtil.object.extend({},i.structure),t&&"structure"in t&&MistUtil.object.extend(this.structure,t.structure),this.blueprints=MistUtil.object.extend({},i.blueprints),t&&"blueprints"in t&&MistUtil.object.extend(this.blueprints,t.blueprints),this.icons=MistUtil.object.extend({},i.icons,!0),t&&"icons"in t&&MistUtil.object.extend(this.icons.blueprints,t.icons),this.icons.build=function(t,i,r){i||(i=22);var n,a=this.blueprints[t];n="function"==typeof a.svg?a.svg.call(e,r):a.svg,"object"!=typeof i&&(i={height:i,width:i}),"object"!=typeof a.size&&(a.size={height:a.size,width:a.size}),(!("width"in i)&&"height"in i||!("height"in i)&&"width"in i)&&("width"in i&&(i.height=i.width*a.size.height/a.size.width),"height"in i&&(i.width=i.height*a.size.width/a.size.height));var s="";s+='',s+='',s+=n,s+="",s+="";var o=document.createElement("div");return o.innerHTML=s,o.firstChild},this.colors=MistUtil.object.extend({},i.colors),t&&"colors"in t&&MistUtil.object.extend(this.colors,t.colors,!0),this.css=MistUtil.object.extend({},i.css),t&&"css"in t&&MistUtil.object.extend(this.css,t.css),this},this.applySkinOptions("skin"in e.options?e.options.skin:"default");var t=[];for(var i in this.css)if("string"==typeof this.css[i]){var r=MistUtil.css.load(e.urlappend(this.css[i]),this.colors);t.push(r)}this.css=t}function MistUI(e,t){e.UI=this,this.elements=[],this.buildStructure=function(t){if("function"==typeof t&&(t=t.call(e)),"if"in t){var i=!1;if(t.if.call(e,t)?i=t.then:"else"in t&&(i=t.else),!i)return;for(var r in t)["if","then","else"].indexOf(r)<0&&(r in i?(i[r]instanceof Array||(i[r]=[i[r]]),i[r]=i[r].concat(t[r])):i[r]=t[r]);return this.buildStructure(i)}if("type"in t&&t.type in e.skin.blueprints){var n=e.skin.blueprints[t.type].call(e,t);if(!n)return;if(MistUtil.class.add(n,"mistvideo-"+t.type),"css"in t){var a=MistUtil.createUnique();for(var r in t.css=[].concat(t.css),t.css){var s=MistUtil.css.createStyle(t.css[r],a);n.appendChild(s)}MistUtil.class.add(n,a),n.uid=a}if("classes"in t)for(var r in t.classes)MistUtil.class.add(n,t.classes[r]);if("title"in t&&(n.title=t.title),"style"in t)for(var r in t.style)n.style[r]=t.style[r];if("children"in t)for(var r in t.children){var o=this.buildStructure(t.children[r]);o&&n.appendChild(o)}return e.UI.elements.push(n),n}return!1},this.build=function(){return this.buildStructure(t||e.skin.structure.main)};var i=this.build(),r=MistUtil.createUnique(),n=0;for(var a in e.skin.css.length&&(i.style.opacity=0),e.skin.css){var s=e.skin.css[a];s.callback=function(t){"/*Failed to load*/"==t?(this.textContent=t,e.showError("Failed to load CSS from "+this.getAttribute("data-source"))):this.textContent=MistUtil.css.prependClass(t,r,!0),n++,e.skin.css.length<=n&&(i.style.opacity="")},""!=s.textContent&&s.callback(s.textContent),i.appendChild(s)}MistUtil.class.add(i,r);var o=MistUtil.getBrowser();return o&&MistUtil.class.add(i,"browser-"+o),i}MistSkins.default={structure:{main:{if:function(){return!!this.info.hasVideo&&"audio"!=this.source.type.split("/")[1]},then:{type:"placeholder",classes:["mistvideo"],children:[{type:"hoverWindow",classes:["mistvideo-maincontainer"],mode:"pos",style:{position:"relative"},transition:{hide:"left: 0; right: 0; bottom: -43px;",show:"bottom: 0;",viewport:"left:0; right: 0; top: -1000px; bottom: 0;"},button:{type:"videocontainer"},children:[{type:"loading"},{type:"error"}],window:{type:"controls"}}]},else:{type:"container",classes:["mistvideo"],style:{overflow:"visible"},children:[{type:"controls",classes:["mistvideo-novideo"],style:{width:"480px"}},{type:"loading"},{type:"error"},{if:function(){return"stock"==this.options.controls},then:{type:"video",style:{position:"absolute"}},else:{type:"video",style:{position:"absolute",display:"none"}}}]}},videocontainer:{type:"container",children:[{type:"videobackground",alwaysDisplay:!1,delay:5},{type:"video"},{type:"subtitles"}]},controls:{if:function(){return!!(this.player&&this.player.api&&this.player.api.play)},then:{type:"container",classes:["mistvideo-column"],children:[{type:"progress",classes:["mistvideo-pointer"]},{type:"container",classes:["mistvideo-main","mistvideo-padding","mistvideo-row","mistvideo-background"],children:[{type:"play",classes:["mistvideo-pointer"]},{type:"currentTime"},{if:function(){return"size"in this&&this.size.width>300||!this.info.hasVideo||"audio"==this.source.type.split("/")[1]},then:{type:"totalTime"}},{type:"container",classes:["mistvideo-align-right"],children:[{type:"container",children:[{type:"container",classes:["mistvideo-volume_container"],children:[{type:"volume",mode:"horizontal",size:{height:22},classes:["mistvideo-pointer"]}]},{type:"speaker",classes:["mistvideo-pointer"],style:{"margin-left":"-2px"}}]},{if:function(){return"size"in this&&this.size.width>300||!this.info.hasVideo||"audio"==this.source.type.split("/")[1]},then:{type:"container",children:[{type:"chromecast",classes:["mistvideo-pointer"]},{type:"loop",classes:["mistvideo-pointer"]},{type:"fullscreen",classes:["mistvideo-pointer"]},{type:"picture-in-picture",classes:["mistvideo-pointer"]}]}},{type:"hoverWindow",mode:"pos",transition:{hide:"right: -1000px; bottom: 44px;",show:"right: 5px;",viewport:"right: 0; left: 0; bottom: 0; top: -1000px"},button:{type:"settings",classes:["mistvideo-pointer"]},window:{type:"submenu"}}]}]}]},else:{if:function(){return!(!this.player||!this.player.api)},then:{type:"hoverWindow",mode:"pos",transition:{hide:"right: -1000px; bottom: 44px;",show:"right: 2.5px;",viewport:"right: 0; left: -1000px; bottom: 0; top: -1000px"},style:{right:"5px",left:"auto"},button:{type:"settings",classes:["mistvideo-background","mistvideo-padding"]},window:{type:"submenu"}}}},submenu:{type:"container",style:{width:"80%",maxWidth:"25em",zIndex:2},classes:["mistvideo-padding","mistvideo-column","mistvideo-background"],children:[{type:"tracks"},{if:function(){return"size"in this&&this.size.width<=300},then:{type:"container",classes:["mistvideo-center"],children:[{type:"chromecast",classes:["mistvideo-pointer"]},{type:"loop",classes:["mistvideo-pointer"]},{type:"fullscreen",classes:["mistvideo-pointer"]},{type:"picture-in-picture",classes:["mistvideo-pointer"]}]}}]},placeholder:{type:"container",classes:["mistvideo","mistvideo-delay-display"],children:[{type:"placeholder"},{type:"loading"},{type:"error"}]},secondaryVideo:function(e){return{type:"hoverWindow",classes:["mistvideo"],mode:"pos",transition:{hide:"left: 10px; bottom: -40px;",show:"bottom: 10px;",viewport:"left: 0; right: 0; top: 0; bottom: 0"},button:{type:"container",children:[{type:"videocontainer"}]},window:{type:"switchVideo",classes:["mistvideo-controls","mistvideo-padding","mistvideo-background","mistvideo-pointer"],containers:e}}}},css:{skin:misthost+"/skins/default.css"},icons:{blueprints:{play:{size:45,svg:''},largeplay:{size:45,svg:''},pause:{size:45,svg:''},speaker:{size:45,svg:''},volume:{size:{width:100,height:45},svg:function(){var e=MistUtil.createUnique();return''}},muted:{size:45,svg:''},fullscreen:{size:45,svg:''},pip:{size:45,svg:''},loop:{size:45,svg:''},settings:{size:45,svg:''},loading:{size:100,svg:''},timeout:{size:25,svg:function(e){e&&e.delay||(e={delay:10});var t=e.delay,i=MistUtil.createUnique();return''}},popout:{size:45,svg:''},switchvideo:{size:45,svg:''}}},blueprints:{container:function(){return document.createElement("div")},video:function(){var e=this;if(MistUtil.event.addListener(e.video,"contextmenu",(function(t){t.preventDefault(),e.container.setAttribute("data-show-submenu",""),e.container.removeAttribute("data-hide-submenu"),e.container.removeAttribute("data-hidecursor");var i=function(){e.container.removeAttribute("data-show-submenu"),e.container.removeEventListener("mouseout",i)};MistUtil.event.addListener(e.container,"mouseout",i)})),e.video.hideTimer=!1,e.video.hideCursor=function(){this.hideTimer&&clearTimeout(this.hideTimer),this.hideTimer=e.timers.start((function(){e.container.setAttribute("data-hidecursor","");var t=e.container.querySelector(".mistvideo-controls");t&&t.parentNode.setAttribute("data-hidecursor","")}),3e3)},MistUtil.event.addListener(e.video,"mousemove",(function(){e.container.removeAttribute("data-hidecursor");var t=e.container.querySelector(".mistvideo-controls");t&&t.parentNode.removeAttribute("data-hidecursor"),e.video.hideCursor()})),MistUtil.event.addListener(e.video,"mouseout",(function(){e.video.hideTimer&&e.timers.stop(e.video.hideTimer)})),e.options.autoplay)var t=MistUtil.event.addListener(e.video,"canplay",(function(){if(e.player.api&&e.player.api.paused){var i=e.player.api.play();i&&i.catch((function(t){if(!e.destroyed)if(e.log("Autoplay failed. Retrying with muted audio.."),e.info.hasVideo){e.player.api.muted=!0,MistUtil.event.send("volumechange",null,e.video);var i=e.player.api.play();i&&i.then((function(){e.reporting&&(e.reporting.stats.d.autoplay="success")})).then((function(){if(!e.destroyed){e.log("Autoplay worked! Video will be unmuted on mouseover if the page has been interacted with."),e.reporting&&(e.reporting.stats.d.autoplay="muted");var t=e.skin.icons.build("muted",100);MistUtil.class.add(t,"mistvideo-pointer"),e.container.appendChild(t),MistUtil.event.addListener(t,"click",(function(){e.player.api.muted=!1,e.container.removeChild(t)}));var i=!1,r=function(){i=!0,document.body.removeEventListener("click",r)};MistUtil.event.addListener(document.body,"click",r,e.video);var n=function(){i&&(e.player.api.muted=!1,e.video.removeEventListener("mouseenter",n),e.log("Re-enabled sound"))};MistUtil.event.addListener(e.video,"mouseenter",n);var a=function(){e.player.api.muted||(t.parentNode&&e.container.removeChild(t),e.video.removeEventListener("volumechange",a),document.body.removeEventListener("click",r),e.video.removeEventListener("mouseenter",n))};MistUtil.event.addListener(e.video,"volumechange",a)}})).catch((function(){if(!e.destroyed){e.log("Autoplay failed even with muted video. Unmuting and showing play button."),e.timers.start((function(){e.player.api.paused&&(e.player.api.pause(),e.monitor&&e.monitor.destroy())}),5e3),e.reporting&&(e.reporting.stats.d.autoplay="failed"),e.player.api.muted=!1;var t=e.skin.icons.build("largeplay",150);MistUtil.class.add(t,"mistvideo-pointer"),e.container.appendChild(t),MistUtil.event.addListener(t,"click",(function(){e.player.api.paused&&e.player.api.play()}));var i=function(){e.container.removeChild(t),e.video.removeEventListener("play",i)};MistUtil.event.addListener(e.video,"play",i)}}))}else e.reporting&&(e.reporting.stats.d.autoplay="failed")}))}else e.reporting&&(e.reporting.stats.d.autoplay="success");MistUtil.event.removeListener(t)}));return this.video},videocontainer:function(){return this.UI.buildStructure(this.skin.structure.videocontainer)},secondaryVideo:function(e){e||(e={}),e.options||(e.options={});var t=this;"secondary"in t||(t.secondary=[]);var i=MistUtil.object.extend({},t.options);i=MistUtil.object.extend(i,e.options),t.secondary.push(i);var r={primary:t,secondary:!1};i.target=document.createElement("div"),delete i.container;var n={};return i.MistVideoObject=n,MistUtil.event.addListener(i.target,"initialized",(function(){var e=n.reference;i.MistVideo=e,r.secondary=e,e.player.api.muted=!0,e.player.api.loop=!1;for(var a=i.target.querySelectorAll(".mistvideo-controls"),s=0;s30)e.player.api.pausedesync=!0,e.player.api.currentTime=this.currentTime,e.log("Re-syncing with main video by seeking (desync: "+t+"s)");else if(i>.01){var r=.1;i<1&&(r=.05),(r=1+r*Math.sign(t))!=e.player.api.playbackRate&&e.log("Re-syncing by changing the playback rate (desync: "+Math.round(1e3*t)+"ms, rate: "+r+")"),e.player.api.playbackRate=r}else 1!=e.player.api.playbackRate&&(e.player.api.playbackRate=1,e.log("Sync with main video achieved (desync: "+Math.round(1e3*t)+"ms)"))}}),i.target),MistUtil.event.addListener(e.video,"seeked",(function(){e.player.api.pausedesync=!1}))})),i.skin=MistUtil.object.extend({},t.skin,!0),i.skin.structure.main=MistUtil.object.extend({},t.skin.structure.secondaryVideo(r)),mistPlay(t.stream,i),i.target},switchVideo:function(e){var t=document.createElement("div");return t.appendChild(this.skin.icons.build("switchvideo")),MistUtil.event.addListener(t,"click",(function(){var t=e.containers.primary,i=e.containers.secondary;function r(e,t){if(e.video.currentTarget==t)return e.video;if(e.secondary)for(var i=0;i300&&(e.style.zoom=1.5),e}},submenu:function(){return this.UI.buildStructure(this.skin.structure.submenu)},hoverWindow:function(e){var t={type:"container",classes:"classes"in e?e.classes:[],children:"children"in e?e.children:[]};switch(t.classes.push("hover_window_container"),"classes"in e.window||(e.window.classes=[]),e.window.classes.push("inner_window"),e.window.classes.push("mistvideo-container"),e.window={type:"container",classes:["outer_window"],children:[e.window]},"classes"in e.button||(e.button.classes=[]),e.button.classes.push("pointer"),e.mode){case"left":t.classes.push("horizontal"),t.children=[e.window,e.button];break;case"right":t.classes.push("horizontal"),t.children=[e.button,e.window];break;case"top":t.classes.push("vertical"),t.children=[e.button,e.window];break;case"bottom":t.classes.push("vertical"),t.children=[e.window,e.button];break;case"pos":t.children=[e.button,e.window],"classes"in e.window||(e.window.classes=[]);break;default:throw"Unsupported mode for structure type hoverWindow"}return"transition"in e&&("css"in t||(t.css=[]),t.css.push(".hover_window_container:hover > .outer_window:not([data-hidecursor]) > .inner_window { "+e.transition.show+" }\n.hover_window_container > .outer_window { "+e.transition.viewport+" }\n.hover_window_container > .outer_window > .inner_window { "+e.transition.hide+" }")),t.classes.push(e.mode),this.UI.buildStructure(t)},draggable:function(e){var t=this.skin.blueprints.container(e),i=this,r=this.skin.icons.build("fullscreen",16);MistUtil.class.remove(r,"fullscreen"),MistUtil.class.add(r,"draggable-icon"),t.appendChild(r),r.style.alignSelf="flex-end",r.style.position="absolute",r.style.cursor="move";var n={},a=function(e){t.style.left=e.clientX-n.x+"px",t.style.top=e.clientY-n.y+"px"},s=function(e){window.removeEventListener("mousemove",a),window.removeEventListener("click",s),MistUtil.event.addListener(r,"click",o)},o=function(e){e.stopPropagation(),r.removeEventListener("click",o),n.x=i.container.getBoundingClientRect().left-(t.getBoundingClientRect().left-e.clientX),n.y=i.container.getBoundingClientRect().top-(t.getBoundingClientRect().top-e.clientY),t.style.position="absolute",t.style.right="auto",t.style.bottom="auto",i.container.appendChild(t),a(e),MistUtil.event.addListener(window,"mousemove",a,t),MistUtil.event.addListener(window,"click",s,t)};return MistUtil.event.addListener(r,"click",o),t},progress:function(){var e=document.createElement("div"),t=document.createElement("div");e.appendChild(t),t.kids={},t.kids.bar=document.createElement("div"),t.kids.bar.className="bar",t.appendChild(t.kids.bar);var i=this.video,r=this,n=1/0;if(r.info&&r.info.meta&&r.info.meta.tracks)for(var a in r.info.meta.tracks).001*r.info.meta.tracks[a].firstms1e3?(t.updateBuffers(r.player.api.buffered),l=(new Date).getTime()):c||(c=r.timers.start((function(){e(),c=!1}),1e3))}()}),t);var d=0,u=!1;MistUtil.event.addListener(i,"timeupdate",(function(){!function e(){(new Date).getTime()-d>200&&!f?(t.updateBar(r.player.api.currentTime),d=(new Date).getTime()):u||(u=r.timers.start((function(){e(),u=!1}),1e3))}()}),t),MistUtil.event.addListener(i,"seeking",(function(){t.updateBar(r.player.api.currentTime)}),t),t.getPos=function(e){var t=isNaN(e)?MistUtil.getPos(this,e):e;return"live"==r.info.type?(t-1)*o()+r.player.api.duration:!!isFinite(r.player.api.duration)&&t*(r.player.api.duration-s())+s()},t.seek=function(e){var t=this.getPos(e);r.player.api.currentTime=t},MistUtil.event.addListener(e,"mouseup",(function(e){1==e.which&&t.seek(e)}));var p=r.UI.buildStructure({type:"tooltip"});p.style.opacity=0,t.appendChild(p),MistUtil.event.addListener(e,"mouseout",(function(){f||(p.style.opacity=0)})),t.moveTooltip=function(e){var t=this.getPos(e);if(!1!==t){p.setDisplay(t),p.style.opacity=1;var i=MistUtil.getPos(this,e),r={bottom:20};i>.5?(r.right=100*(1-i)+"%",p.triangle.setMode("bottom","right")):(r.left=100*i+"%",p.triangle.setMode("bottom","left")),p.setPos(r)}else p.style.opacity=0};var h=document.createElement("span");h.setAttribute("class","mistvideo-realtime");var m=document.createTextNode("");h.appendChild(m),p.setDisplay=function(e){if(r.options.useDateTime&&r.info&&r.info.unixoffset){var i=t.getPos(1)-t.getPos(0),n=.001*(new Date).getTime()-(.001*r.info.unixoffset+t.getPos(1)),a=Math.max(i,n),s="";if("live"==r.info.type)if(a<60)s=MistUtil.format.ago(new Date(r.info.unixoffset+1e3*e));else{var o=.001*(new Date).getTime()-(.001*r.info.unixoffset+e);o<172800&&(s+=" - "+MistUtil.format.time(o))}else s+=MistUtil.format.time(e);if(a>=60){m.nodeValue=" at "+MistUtil.format.ago(new Date(r.info.unixoffset+1e3*e),1e3*a);var l=document.createDocumentFragment();l.appendChild(document.createTextNode(s)),l.appendChild(h),p.setHtml(l)}else m.nodeValue="",p.setText(s)}else p.setText(MistUtil.format.time(e))},MistUtil.event.addListener(e,"mousemove",(function(e){t.moveTooltip(e)}));var f=!1;return MistUtil.event.addListener(e,"mousedown",(function(i){if(1==i.which){f=!0,t.updateBar(t.getPos(i));var r=MistUtil.event.addListener(document,"mousemove",(function(e){t.updateBar(t.getPos(e)),t.moveTooltip(e)}),t),n=MistUtil.event.addListener(document,"mouseup",(function(i){1==i.which&&(f=!1,MistUtil.event.removeListener(r),MistUtil.event.removeListener(n),p.style.opacity=0,(!i.path||MistUtil.array.indexOf(i.path,e)<0)&&t.seek(i))}),t)}})),e},play:function(){var e=this,t=document.createElement("div");t.appendChild(this.skin.icons.build("play")),t.appendChild(this.skin.icons.build("pause")),t.setState=function(e){this.setAttribute("data-state",e)},t.setState("paused");var i=this.video;return MistUtil.event.addListener(i,"playing",(function(){t.setState("playing"),e.options.autoplay=!0}),t),MistUtil.event.addListener(i,"pause",(function(){t.setState("paused")}),t),MistUtil.event.addListener(i,"paused",(function(){t.setState("paused")}),t),MistUtil.event.addListener(i,"ended",(function(){t.setState("paused")}),t),MistUtil.event.addListener(t,"click",(function(){e.player.api.error&&e.player.api.load(),e.player.api.paused?e.player.api.play():(e.player.api.pause(),e.options.autoplay=!1)})),e.player.api&&MistUtil.event.addListener(e.video,"click",(function(){e.player.api.paused?e.player.api.play():MistUtil.isTouchDevice()||(e.player.api.pause(),e.options.autoplay=!1)}),t),t},speaker:function(){if(!this.player.api||!("muted"in this.player.api))return!1;var e=!1,t=this.info.meta.tracks;for(var i in t)if("audio"==t[i].type){e=!0;break}if(!e)return!1;var r=this.skin.icons.build("speaker"),n=this,a=this.video;return n.player.api.volume&&!n.player.api.muted||MistUtil.class.add(r,"off"),MistUtil.event.addListener(a,"volumechange",(function(){n.player.api.volume&&!n.player.api.muted?MistUtil.class.remove(r,"off"):MistUtil.class.add(r,"off")}),r),MistUtil.event.addListener(r,"click",(function(e){n.player.api.muted=!n.player.api.muted})),r},volume:function(e){if(!this.player.api||!("volume"in this.player.api))return!1;var t=!1,i=this.info.meta.tracks;for(var r in i)if("audio"==i[r].type){t=!0;break}if(!t)return!1;var n=document.createElement("div"),a=this.skin.icons.build("volume","size"in e&&e.size);n.appendChild(a);var s=this;a.mode="mode"in e?e.mode:"vertical","vertical"==a.mode&&(a.style.transform="rotate(90deg)"),a.margin={start:.15,end:.1};var o=this.video;a.set=function(e){100!=(e=100-100*Math.pow(1-e/100,2))&&0!=e&&(e=100*this.addPadding(e/100));for(var t=a.querySelectorAll(".slider"),i=0;i6e4&&e.size.width>=600&&(n.nodeValue=" (at "+MistUtil.format.ago(o)+")")),t.setAttribute("title",MistUtil.format.ago(o,3456e7))}else r=a(s),t.setAttribute("title",r);i.nodeValue=r},t.set(),MistUtil.event.addListener(e.video,"timeupdate",(function(){t.set()}),t),MistUtil.event.addListener(e.video,"seeking",(function(){t.set()}),t),t},totalTime:function(){var e=this,t=document.createElement("div"),i=document.createTextNode("");t.appendChild(i);this.player.api;return"live"==e.info.type?(i.nodeValue="live",t.className="live"):(t.set=function(r){if(!isNaN(r)&&isFinite(r))if(this.style.display="",e.options.useDateTime&&e.info&&"live"==e.info.type&&e.info.unixoffset){var n=new Date(1e3*r+e.info.unixoffset);i.nodeValue=MistUtil.format.ago(n),t.setAttribute("title",MistUtil.format.ago(n,3456e7))}else i.nodeValue=MistUtil.format.time(r),t.setAttribute("title",i.nodeValue);else this.style.display="none"},MistUtil.event.addListener(e.video,"durationchange",(function(){var i=e.player.api.duration;t.set(i)}),t)),t},playername:function(){if(this.playerName&&this.playerName in mistplayers){var e=document.createElement("span");return e.appendChild(document.createTextNode(mistplayers[this.playerName].name)),e}},mimetype:function(){if(this.source){var e=document.createElement("a");return e.href=this.source.url,e.target="_blank",e.title=e.href+" ("+this.source.type+")",e.appendChild(document.createTextNode(MistUtil.format.mime2human(this.source.type))),e}},logo:function(e){if("element"in e)return e.element;if("src"in e){var t=document.createElement("img");return t.src=e.src,t}},settings:function(){var e=this,t=this.skin.icons.build("settings"),i=void 0!==document.ontouchstart;return MistUtil.event.addListener(t,"click",(function(){e.container.hasAttribute("data-show-submenu")?(i&&e.container.setAttribute("data-hide-submenu",""),e.container.removeAttribute("data-show-submenu")):(e.container.setAttribute("data-show-submenu",""),e.container.removeAttribute("data-hide-submenu"))})),t},loop:function(){if("loop"in this.player.api&&"live"!=this.info.type){var e=this,t=this.skin.icons.build("loop");this.video;return t.set=function(){e.player.api.loop?MistUtil.class.remove(this,"off"):MistUtil.class.add(this,"off")},MistUtil.event.addListener(t,"click",(function(t){e.player.api.loop=!e.player.api.loop,this.set()})),t.set(),t}},fullscreen:function(){if("setSize"in this.player&&this.info.hasVideo&&"audio"!=this.source.type.split("/")[1]){var e=this,t=["requestFullscreen","webkitRequestFullscreen","mozRequestFullScreen","msRequestFullscreen","webkitEnterFullscreen"],i=[function(){return e.container},function(){return e.video}],r=!1;e:for(var n in i)for(var a in t)if(t[a]in i[n]()){(r={}).request=function(){return r.fullscreenableElement()[t[a]]()};var s=["exitFullscreen","webkitCancelFullScreen","mozCancelFullScreen","msExitFullscreen","webkitExitFullscreen"],o=["fullscreenElement","webkitFullscreenElement","mozFullScreenElement","msFullscreenElement","webkitFullscreenElement"];r.cancel=function(){return document[s[a]]()},r.element=function(){return document[o[a]]},r.event=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange","webkitfullscreenchange"][a],r.fullscreenableElement=i[n];break e}if(!r){var l=function(e){if("Escape"===e.key)r.cancel()};(r={event:"fakefullscreenchange",fullscreenableElement:function(){return e.container}}).request=function(){return r.element=function(){return e.container},MistUtil.event.send(r.event,null,document),document.addEventListener("keydown",l),!0},r.cancel=function(){return r.element=function(){return null},document.removeEventListener("keydown",l),MistUtil.event.send(r.event,null,document),!0},r.element=function(){return null}}var c=this.skin.icons.build("fullscreen");return MistUtil.event.addListener(c,"click",d),MistUtil.event.addListener(e.video,"dblclick",d),MistUtil.event.addListener(document,r.event,(function(){r.element()==r.fullscreenableElement()?e.container.setAttribute("data-fullscreen",""):e.container.hasAttribute("data-fullscreen")&&e.container.removeAttribute("data-fullscreen"),e.player.resizeAll()}),c),c}function d(){r.element()?r.cancel():r.request()}},"picture-in-picture":function(){if("setSize"in this.player&&this.info.hasVideo&&"audio"!=this.source.type.split("/")[1]&&document.pictureInPictureEnabled){var e=this;if("requestPictureInPicture"in e.video){var t=this.skin.icons.build("pip");return t.set=function(){document.pictureInPictureElement?MistUtil.class.remove(this,"off"):MistUtil.class.add(this,"off")},MistUtil.event.addListener(t,"click",(function(){var i;(i=document.pictureInPictureElement?document.exitPictureInPicture():e.video.requestPictureInPicture())?i.then((function(){t.set()})):t.set()})),t.set(),t}}},tracks:function(){if(this.info&&this.video){var e=this,t=document.createElement("table");return i(this.info.meta.tracks),MistUtil.event.addListener(e.video,"metaUpdate_tracks",(function(e){i(e.message.meta.tracks)}),t),t}function i(i){MistUtil.empty(t),i=MistUtil.tracks.parse(i);var r={},n={};function a(t,i){if(i?e.log("User selected "+t+" track with id "+i):(e.log("User selected automatic track selection for "+t),MistUtil.event.send("trackSetToAuto",t,e.video)),e.options.setTracks||(e.options.setTracks={}),e.options.setTracks[t]=i,!0===i&&r[t]&&MistUtil.event.send("change",null,r[t]),"setTrack"in e.player.api)return e.player.api.setTrack(t,i);var n={};for(var a in r)"subtitle"!=a&&""!=r[a].value&&(n[a]=r[a].value);return""!=i&&(n[t]=i),"setTracks"in e.player.api?e.player.api.setTracks(n):"setSource"in e.player.api?e.player.api.setSource(MistUtil.http.url.addParam(e.source.url,n)):void 0}var s=MistUtil.object.keys(i,(function(e,t){function i(e){switch(e){case"audio":return"aaaaaaa";case"video":return"aaaaaab";default:return e}}return i(e)>i(t)?1:i(e)1&&"player"in e&&"api"in e.player&&("setTrack"in e.player.api||"setTracks"in e.player.api||"setSource"in e.player.api)){var b=document.createElement("select");if(b.title="Select another "+l+" track",r[l]=b,b.trackType=l,f.appendChild(b),"subtitle"!=l){var k=document.createElement("option");b.appendChild(k),k.value="",k.appendChild(document.createTextNode("Automatic"))}var M=S(c[MistUtil.object.keys(c)[0]].same);if(M.length)(x=document.createElement("span")).className="mistvideo-description",f.appendChild(x),f.appendChild(document.createTextNode(M.join(" ")));function w(e){return""==e?-1:Number(e)}var U=MistUtil.object.keys(c,(function(e,t){return w(e)-w(t)}));for(var p in U){var C=c[U[p]];k=document.createElement("option");b.appendChild(k),k.value="idx"in C?C.idx:C.trackid,MistUtil.object.keys(C.different).length?k.appendChild(document.createTextNode(S(C.different).join(" "))):k.appendChild(document.createTextNode("Track "+(Number(p)+1)))}if(MistUtil.event.addListener(e.video,"playerUpdate_trackChanged",(function(t){t.message.type==l&&"none"!=t.message.trackid&&(b.value=t.message.trackid,e.log("Player selected "+l+" track with id "+t.message.trackid))}),b),"subtitle"==l){if(MistUtil.event.addListener(b,"change",(function(){try{localStorage.mistSubtitleLanguage=c[this.value].lang}catch(e){}if("setWSSubtitle"in e.player.api)e.player.api.setWSSubtitle(""==this.value?void 0:this.value);else if(""!=this.value){var t=MistUtil.object.extend({},c[this.value]);t.label=S(t.describe).join(" "),t.src=MistUtil.http.url.addParam(u,{track:this.value}),e.player.api.setSubtitle(t)}else e.player.api.setSubtitle()})),"localStorage"in window&&null!=localStorage&&"mistSubtitleLanguage"in localStorage)for(var p in c)if(c[p].lang==localStorage.mistSubtitleLanguage){b.value=p;var T=document.createEvent("Event");T.initEvent("change"),b.dispatchEvent(T);break}}else MistUtil.event.addListener(b,"change",(function(){this.trackType in n&&(n[this.trackType].checked=!0),a(this.trackType,this.value)}))}else{var x;(x=document.createElement("span")).className="mistvideo-description",f.appendChild(x),x.appendChild(document.createTextNode(S(c[g[0]].same).join(" ")))}}function S(e){var t={trackid:0,language:1,width:2,bps:3,fpks:4,channels:5,codec:6,rate:7};return MistUtil.object.values(e,(function(e,i,r,n){return t[e]>t[i]?1:t[e]=.999?n():a()}),1e3))}var s=["waiting","seeking","stalled"];for(var o in s)MistUtil.event.addListener(e.video,s[o],(function(t){e.player.api&&!e.player.api.paused&&"container"in e&&r(t)}),t);s=["seeked","playing","canplay","paused","ended"];for(var o in s)MistUtil.event.addListener(e.video,s[o],(function(t){"container"in e&&n()}),t);MistUtil.event.addListener(e.video,"progress",(function(t){"container"in e&&"monitor"in e&&"vars"in e.monitor&&"score"in e.monitor.vars&&e.monitor.vars.score>.99&&n()}),t)}return t},error:function(){var e=this,t=document.createElement("div");t.message=function(t,i,r){MistUtil.empty(this);var n=document.createElement("div");if(n.className="message",this.appendChild(n),!r.polling&&!r.passive&&!r.hideTitle){var a=document.createElement("h3");n.appendChild(a),a.appendChild(document.createTextNode("The "+(e.casting?"chromecast":"player")+" has encountered a problem"))}var s=document.createElement("p");if(n.appendChild(s),n.update=function(e){MistUtil.empty(s),s.innerHTML=e},t){e.info.on_error&&(t=e.info.on_error.replace(/\/,t)),n.update(t);var o=document.createElement("p");if(o.className="details mistvideo-description",n.appendChild(o),i)o.appendChild(document.createTextNode(i));else if("decodingIssues"in e.skin.blueprints){if("player"in e&&"api"in e.player&&e.video){if(i=[],void 0!==e.state&&i.push(["Stream state:",e.state]),void 0!==e.player.api.currentTime&&i.push(["Current video time:",MistUtil.format.time(e.player.api.currentTime)]),"video"in e&&"getVideoPlaybackQuality"in e.video){var l=e.video.getVideoPlaybackQuality();"droppedVideoFrames"in l&&"totalVideoFrames"in l&&l.totalVideoFrames&&i.push(["Frames dropped/total:",MistUtil.format.number(l.droppedVideoFrames)+"/"+MistUtil.format.number(l.totalVideoFrames)]),"corruptedVideoFrames"in l&&l.corruptedVideoFrames&&i.push(["Corrupted frames:",MistUtil.format.number(l.corruptedVideoFrames)])}i.push({0:["NETWORK EMPTY:","not yet initialized"],1:["NETWORK IDLE:","resource selected, but not in use"],2:["NETWORK LOADING:","data is being downloaded"],3:["NETWORK NO SOURCE:","could not locate source"]}[e.video.networkState]);if(i.push({0:["HAVE NOTHING:","no information about ready state"],1:["HAVE METADATA:","metadata has been loaded"],2:["HAVE CURRENT DATA:","data for the current playback position is available, but not for the next frame"],3:["HAVE FUTURE DATA:","data for current and next frame is available"],4:["HAVE ENOUGH DATA:","can start playing"]}[e.video.readyState]),!r.passive){var c=document.createElement("table");for(var d in i){var u=document.createElement("tr");for(var p in c.appendChild(u),i[d]){var h=document.createElement("td");u.appendChild(h),h.appendChild(document.createTextNode(i[d][p]))}}o.appendChild(c)}}var m,f=document.createElement("div");f.className="mistvideo-container mistvideo-column",f.style.textAlign="left",f.style.marginBottom="1em",n.appendChild(f),(m=e.UI.buildStructure({type:"forcePlayer"}))&&f.appendChild(m),(m=e.UI.buildStructure({type:"forceType"}))&&f.appendChild(m)}}return n};var i,r=!1,n=!1,a={};if(this.showError=function(s,o){o||(o={softReload:!!(e.player&&e.player.api&&e.player.api.load),reload:!0,nextCombo:!!e.info,polling:!1,passive:!1});var l=o.type?o.type:s;if(!(l in a)){if(!0===o.reload&&(e.options.reloadDelay&&!isNaN(Number(e.options.reloadDelay))?o.reload=Number(e.options.reloadDelay):o.reload=10),o.passive){if(!0===r)return;if(r)return i.update(s),void(n=(new Date).getTime());t.setAttribute("data-passive","")}else t.removeAttribute("data-passive");var c;r&&t.clear(),r=!o.passive||"passive",n=(new Date).getTime(),e.casting||(c=this.log(s,"error"));var d=t.message(s,!1,o);i=d;var u=document.createElement("div");if(u.className="mistvideo-buttoncontainer",d.appendChild(u),MistUtil.empty(u),e.casting&&!o.passive){var p={type:"button",label:"Stop casting",onclick:function(){e.detachFromCast()}};isNaN(o.softReload+"")||(p.delay=o.softReload),u.appendChild(e.UI.buildStructure(p))}if(o.softReload&&!e.casting){p={type:"button",label:"Reload video",onclick:function(){e.player.api.load()}};isNaN(o.softReload+"")||(p.delay=o.softReload),u.appendChild(e.UI.buildStructure(p))}if(o.reload){p={type:"button",label:"Reload player",onclick:function(){e.reload("Reloading because reload button was clicked.")}};isNaN(o.reload+"")||(p.delay=o.reload),u.appendChild(e.UI.buildStructure(p))}if(o.nextCombo){p={type:"button",label:"Next source",onclick:function(){e.nextCombo()}};isNaN(o.nextCombo+"")||(p.delay=o.nextCombo),u.appendChild(e.UI.buildStructure(p))}if(o.ignore){p={type:"button",label:"Ignore",onclick:function(){this.clearError(),a[l]=!0}};isNaN(o.ignore+"")||(p.delay=o.ignore),u.appendChild(e.UI.buildStructure(p))}o.polling&&u.appendChild(e.UI.buildStructure({type:"polling"})),MistUtil.class.add(t,"show"),"container"in e&&e.container.removeAttribute("data-loading"),c&&c.defaultPrevented&&(e.log("Error event was defaultPrevented, not showing."),t.clear())}},t.clear=function(){for(var i=t.querySelectorAll("svg.icon.timeout"),n=0;n=0;e--)r.removeChild(r.children[e])},e.setHtml=function(n){r.empty(),r.appendChild(n),"html"!=t&&(e.removeChild(i),e.appendChild(r),t="html")};var n=document.createElement("div");return e.triangle=n,n.className="triangle",e.appendChild(n),n.setMode=function(e,t){e||(e="bottom"),t||(t="left");var i=["bottom","top","right","left"];for(var r in i){this.style[i[r]]="";var n=MistUtil.format.ucFirst(i[r]);this.style["border"+n]="",this.style["border"+n+"Color"]=""}var a={top:"bottom",bottom:"top",left:"right",right:"left"};this.style[e]="-10px",this.style["border"+MistUtil.format.ucFirst(a[e])]="none",this.style["border"+MistUtil.format.ucFirst(e)+"Color"]="transparent",this.style[t]=0,this.style["border"+MistUtil.format.ucFirst(a[t])]="none"},e.setPos=function(e){var t={left:"auto",right:"auto",top:"auto",bottom:"auto"};for(var i in MistUtil.object.extend(t,e),t)isNaN(t[i])||(t[i]+="px"),this.style[i]=t[i]},e},button:function(e){var t=document.createElement("button"),i=this;if(e.onclick&&(MistUtil.event.addListener(t,"click",(function(){e.onclick.call(i,arguments)})),e.delay)){var r=this.UI.buildStructure({type:"timeout",delay:e.delay,function:e.onclick});r&&t.appendChild(r)}return t.appendChild(document.createTextNode(e.label)),t},videobackground:function(e){e||(e={}),e.delay||(e.delay=5);for(var t=document.createElement("div"),i=this,r=[],n=0;n<2;n++){var a=document.createElement("canvas");a._context=a.getContext("2d"),t.appendChild(a),r.push(a)}var s=0,o=!1;function l(){if(e.alwaysDisplay||i.video.videoWidth/i.video.videoHeight!=t.clientWidth/t.clientHeight){r[s].removeAttribute("data-front"),++s>=r.length&&(s=0);var n=r[s],a=n._context;n.width=i.video.videoWidth,n.height=i.video.videoHeight,a.drawImage(i.video,0,0),n.setAttribute("data-front","")}i.player.api.paused?o=!1:i.timers.start((function(){l()}),1e3*e.delay)}return MistUtil.event.addListener(i.video,"playing",(function(){o||(l(),o=!0)})),t},subtitles:function(e){if(!("WebSocket"in window))return!1;var t=this;if(!("player"in t)||!("api"in t.player)||!("currentTime"in t.player.api))return!1;if(!("metaTrackSubscriptions"in t))return!1;var i=document.createElement("div"),r=document.createElement("span");i.appendChild(r);var n=document.createTextNode("");r.appendChild(n);var a=!1;function s(e){n.nodeValue=e.data.replace(/\<\/?[bui]\>/gi,"").replace(/{\/?[bui]}/gi,"").replace(/{\\a\d+}/gi,"").replace(/\<\/?font[^>]*?\>/gi,""),a&&(t.timers.stop(a),a=null),function i(r){a=t.timers.start((function(){if(t.player.api.paused)var r=MistUtil.event.addListener(t.video,"playing",(function(){i(e.time+("duration"in e?e.duration:5e3)-1e3*t.player.api.currentTime),MistUtil.event.removeListener(r)}));else n.nodeValue=""}),r)}("duration"in e?e.duration:5e3)}if(MistUtil.event.addListener(t.video,"seeked",(function(){n.nodeValue="",a&&t.timers.stop(a),a=null})),!("setWSSubtitle"in t.player.api)){var o=!1;t.player.api.setWSSubtitle=function(e){e!=o&&(void 0!==e&&t.metaTrackSubscriptions.add(e,s),e!=o&&t.metaTrackSubscriptions.remove(o,s),o="undefined"!=e&&e)}}return i},chromecast:function(){var e=this;if(!(!"".indexOf||e.options.host.indexOf("localhost")>-1||e.options.host.indexOf("::1")>-1)){var t,i,r,n,a=document.createElement("div"),s=document.createElement("div");s.className="mistvideo-casting";var o={},l={currentTime:!1,paused:!0,volume:1,muted:!1,buffer:[],loop:e.player.api?e.player.api.loop:e.options.loop};if(e.casting=!1,window.chrome&&window.chrome.cast||window.loadedCastApi)"loading"==window.loadedCastApi?(e.log("Not appending chromecast script - still loading"),e.timers.start((function(){d()}),200)):(e.log("Not appending chromecast script - already loaded"),d());else{window.__onGCastApiAvailable=function(t,i){t||e.log("Error while loading chromecast API: "+i),d()},window.loadedCastApi="loading";var c=document.createElement("script");c.setAttribute("src","//www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"),document.head.appendChild(c),e.log("Appending chromecast script")}return a}function d(c){if(!window.chrome||!window.chrome.cast||!window.chrome.cast.isAvailable||c>5)return a.parentNode&&a.parentNode.removeChild(a),e.log("Chromecast is not supported"),void console.warn(chrome,chrome.cast,chrome.cast?chrome.cast.isAvailable:void 0,cast);if(!window.cast)return c||(c=0),e.log("Casting api loaded but cast function not yet available, retrying.."),void e.timers.start((function(){d(c++)}),200);e.log("Chromecast API loaded"),window.loadedCastApi&&"loading"!=window.loadedCastApi||(window.loadedCastApi=!0);var u=document.createElement("google-cast-launcher");function p(a){MistUtil.class.remove(u,"active"),MistUtil.class.remove(e.container,"casting"),s.parentNode&&s.parentNode.removeChild(s),!a&&cast.framework.CastContext.getInstance().getCurrentSession()&&cast.framework.CastContext.getInstance().getCurrentSession().endSession(!0),t?(e.player.api=t,t.currentTime=l.currentTime,t.play(),e.reload=i,e.nextCombo=r,e.unload=n):e.player.api.play(),e.player.api&&e.player.api.setTracks&&MistUtil.object.keys(o).length&&e.player.api.setTracks(o),e.casting=!1,e.log("Detached chromecast session")}a.appendChild(u),cast.framework.CastContext.getInstance().setOptions({receiverApplicationId:"E5F1558C",autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),e.detachFromCast=p,u.addEventListener("click",(function(a){if(a.stopPropagation(),MistUtil.class.has(u,"active"))p();else{function c(){cast.framework.CastContext.getInstance().getCurrentSession().addMessageListener("urn:x-cast:mistcaster",(function(t,i){if(e.destroyed&&p(),(i=JSON.parse(i)).type)switch(i.type){case"log":case"error":e.log("[Chromecast] "+i.message,i.type);break;case"showError":e.showError.apply(e,i.args);break;case"event":switch(i.event){case"timeupdate":l.currentTime=i.currentTime,MistUtil.event.send(i.event,"chromecast",e.video);break;case"progress":l.buffer=i.buffer,MistUtil.event.send(i.event,"chromecast",e.video);break;case"pause":case"paused":case"ended":case"play":case"playing":l.paused=i.paused,MistUtil.event.send(i.event,"chromecast",e.video);break;case"volumechange":l.volume=i.volume,l.muted=i.muted,MistUtil.event.send(i.event,"chromecast",e.video);break;default:MistUtil.event.send(i.event,"chromecast",e.video)}break;case"detach":i.n==e.n&&p(!0);break;default:console.log("Unknown chromecast message type",i)}}));var a={type:"load",n:e.n,options:{host:e.options.host,loop:e.options.loop,poster:e.options.poster,streaminfo:e.options.streaminfo,urlappend:e.options.urlappend,forcePriority:e.options.forcePriority,setTracks:e.options.setTracks,controls:!1,skin:"default"},stream:e.stream};e.info&&"live"!=e.info.type&&(a.time=e.player.api.currentTime),"dev"==e.options.skin&&(a.options.skin=e.options.skin),e.player&&e.player.api&&(a.volume=e.player.api.volume,a.muted=e.player.api.muted,a.options.loop=e.player.api.loop),MistCast.send(a),t=e.player.api,i=e.reload,r=e.nextCombo,n=e.unload,o=e.options.setTracks?e.options.setTracks:{},e.player.api=new Proxy(t,{get:function(e,t,i){var r=e[t];switch(t){case"muted":case"volume":case"currentTime":case"paused":case"loop":return l[t];case"buffered":return new function(){this.length=l.buffer.length,this.start=function(e){return l.buffer[e][0]},this.end=function(e){return l.buffer[e][1]}};case"setTracks":case"play":case"pause":return function(){for(var e=[],i=0;i=t.scrollHeight-5})),r.logs)o(r.logs[l].time,r.logs[l].message,r.logs[l].data);return MistUtil.event.addListener(r.options.target,"log",(function(e){if(e.message){var t={};r.player&&r.player.api&&"currentTime"in r.player.api&&(t.currentTime=r.player.api.currentTime),o(new Date,e.message,t)}}),e),MistUtil.event.addListener(r.options.target,"error",(function(e){if(e.message){var t={type:"error"};r.player&&r.player.api&&"currentTime"in r.player.api&&(t.currentTime=r.player.api.currentTime),o(new Date,e.message,t)}}),e),e},decodingIssues:function(){if(this.player){var e=this,t=document.createElement("div");if(e.player.api){var i={"Playback score":function(){if("monitor"in e){if("vars"in e.monitor&&"score"in e.monitor.vars&&e.monitor.vars.values.length){var t=e.monitor.vars.values[e.monitor.vars.values.length-1];if("score"in t){Math.min(1,Math.max(0,t.score));return{x:t.clock,y:Math.min(1,Math.max(0,t.score)),options:{y:{min:0,max:1},x:{count:10}},val:Math.round(100*Math.min(1,Math.max(0,e.monitor.vars.score)))+"%"}}}return 0}},"Corrupted frames":function(){if(e.player.api&&"getVideoPlaybackQuality"in e.player.api){var t=e.player.api.getVideoPlaybackQuality();if(t)return t.corruptedVideoFrames?{val:MistUtil.format.number(t.corruptedVideoFrames),x:.001*(new Date).getTime(),y:t.corruptedVideoFrames,options:{x:{count:10}}}:0}},"Dropped frames":function(){if(e.player.api){if("getVideoPlaybackQuality"in e.player.api){var t=e.player.api.getVideoPlaybackQuality();if(t)return t.droppedVideoFrames?MistUtil.format.number(t.droppedVideoFrames):0}if("webkitDroppedFrameCount"in e.player.api)return e.player.api.webkitDroppedFrameCount}},"Total frames":function(){if(e.player.api&&"getVideoPlaybackQuality"in e.player.api){var t=e.player.api.getVideoPlaybackQuality();if(t)return MistUtil.format.number(t.totalVideoFrames)}},"Decoded audio":function(){if(e.player.api)return MistUtil.format.bytes(e.player.api.webkitAudioDecodedByteCount)},"Decoded video":function(){if(e.player.api)return MistUtil.format.bytes(e.player.api.webkitVideoDecodedByteCount)},"Negative acknowledgements":function(){if(e.player.api)return MistUtil.format.number(e.player.api.nackCount)},"Picture losses":function(){return MistUtil.format.number(e.player.api.pliCount)},"Packets lost":function(){return MistUtil.format.number(e.player.api.packetsLost)},"Packets received":function(){return MistUtil.format.number(e.player.api.packetsReceived)},"Bytes received":function(){if(e.player.api)return MistUtil.format.bytes(e.player.api.bytesReceived)},"Local latency [ms]":function(){if(e.player.api&&"getLatency"in e.player.api){var t=e.player.api.getLatency();return t?new Promise((function(e,i){t.then((function(t){var i=[];for(var r in t)t[r]&&i.push(r[0]+":"+Math.round(1e3*t[r]));i.length?e(i.join(" ")):e()}),i)})):new Promise((function(e,t){e()}),(function(){}))}},"Current bitrate":function(){var t;return e.player.monitor&&"currentBps"in e.player.monitor?(t=MistUtil.format.bits(e.player.monitor.currentBps))?t+"ps":t:e.player.api&&"currentBps"in e.player.api?(t=MistUtil.format.bits(e.player.api.currentBps()))?t+"ps":t:void 0},"Framerate in":function(){if(e.player.api&&"framerate_in"in e.player.api)return MistUtil.format.number(e.player.api.framerate_in())},"Framerate out":function(){if(e.player.api&&"framerate_out"in e.player.api)return MistUtil.format.number(e.player.api.framerate_out())}},r=[];for(var n in i)void 0!==i[n]()&&a({name:n,function:i[n]});t.update=function(){for(var i in r)r[i]();e.timers.start((function(){t.update()}),1e3)},t.update()}return t}function a(e){var i=document.createElement("label");t.appendChild(i),i.style.display="none";var n=document.createElement("span");i.appendChild(n),n.appendChild(document.createTextNode(e.name+":")),n.className="mistvideo-description";var a=document.createElement("span");i.appendChild(a);var s=document.createTextNode(e.value?e.value:"");a.appendChild(s);var o=document.createElement("span");a.appendChild(o),i.set=function(e){if(0!==e&&(this.style.display=""),"object"==typeof e){try{if(e instanceof Promise)return void e.then((function(e){i.set(e)}),(function(){}))}catch(e){}if("val"in e&&(s.nodeValue=e.val,a.className="value"),o.children.length)return(t=o.children[0]).addData(e);var t=MistUtil.createGraph({x:[e.x],y:[e.y]},e.options);return o.style.display="",MistUtil.empty(o),o.appendChild(t)}return s.nodeValue=e},t.appendChild(i),r.push((function(){var t=e.function();i.set(t)}))}},forcePlayer:function(){var e=document.createElement("label");e.title="Reload MistVideo and use the selected player";var t=this,i=document.createElement("span");e.appendChild(i),i.appendChild(document.createTextNode("Force player: "));var r=document.createElement("select");e.appendChild(r);var n=document.createElement("option");for(var a in r.appendChild(n),n.value="",n.appendChild(document.createTextNode("Automatic")),mistplayers){n=document.createElement("option");r.appendChild(n),n.value=a,n.appendChild(document.createTextNode(mistplayers[a].name))}return this.options.forcePlayer&&(r.value=this.options.forcePlayer),MistUtil.event.addListener(r,"change",(function(){t.options.forcePlayer=""!=this.value&&this.value,t.options.forcePlayer!=t.playerName&&t.reload("Reloading to force player.")})),e},forceType:function(){if(this.info){var e=document.createElement("label");e.title="Reload MistVideo and use the selected protocol";var t=this,i=document.createElement("span");e.appendChild(i),i.appendChild(document.createTextNode("Force protocol: "));var r=document.createElement("select");e.appendChild(r);var n=document.createElement("option");r.appendChild(n),n.value="",n.appendChild(document.createTextNode("Automatic"));var a={};for(var s in t.info.source){var o=t.info.source[s];if(!(o.type in a)){a[o.type]=1;n=document.createElement("option");r.appendChild(n),n.value=o.type,n.appendChild(document.createTextNode(MistUtil.format.mime2human(o.type)))}}return this.options.forceType&&(r.value=this.options.forceType),MistUtil.event.addListener(r,"change",(function(){t.options.forceType=""!=this.value&&this.value,t.source&&t.options.forceType==t.source.type||t.reload("Reloading to force new type.")})),e}},forceSource:function(){var e=document.createElement("label");e.title="Reload MistVideo and use the selected source";var t=this,i=document.createElement("span");e.appendChild(i),i.appendChild(document.createTextNode("Force source: "));var r=document.createElement("select");e.appendChild(r);var n=document.createElement("option");for(var a in r.appendChild(n),n.value="",n.appendChild(document.createTextNode("Automatic")),t.info.source){var s=t.info.source[a];n=document.createElement("option");r.appendChild(n),n.value=a,n.appendChild(document.createTextNode(s.url+" ("+MistUtil.format.mime2human(s.type)+")"))}return this.options.forceSource&&(r.value=this.options.forceSource),MistUtil.event.addListener(r,"change",(function(){t.options.forceSource=""!=this.value&&this.value,t.options.forceSource!=t.source.index&&t.reload("Reloading to force new source.")})),e}}},MistSkins.dev.css={skin:misthost+"/skins/dev.css"},MistSkins.dev.structure.submenu=MistUtil.object.extend({},MistSkins.default.structure.submenu,!0),MistSkins.dev.structure.submenu.type="draggable",MistSkins.dev.structure.submenu.style.width="25em",MistSkins.dev.structure.submenu.children.unshift({type:"container",style:{flexShrink:1},classes:["mistvideo-column"],children:[{if:function(){return this.playerName&&this.source},then:{type:"container",classes:["mistvideo-description","mistvideo-displayCombo"],style:{display:"block"},children:[{type:"playername",style:{display:"inline"}},{type:"text",text:"is playing",style:{margin:"0 0.2em"}},{type:"mimetype"}]}},{type:"log"},{type:"decodingIssues"},{type:"container",classes:["mistvideo-column","mistvideo-devcontrols"],style:{"font-size":"0.9em"},children:[{type:"text",text:"Player control"},{type:"container",classes:["mistvideo-devbuttons"],style:{"flex-wrap":"wrap"},children:[{type:"button",title:"Build MistVideo again",label:"MistVideo.reload();",onclick:function(){this.reload("Dev-reload button clicked.")}},{type:"button",title:"Switch to the next available player and source combination",label:"MistVideo.nextCombo();",onclick:function(){this.nextCombo()}}]},{type:"forcePlayer"},{type:"forceType"}]}]});var mistplayers={};function MistPlayer(){}function mistPlay(e,t){return new MistVideo(e,t)}function MistVideo(e,t){var i=this;function r(e){if("meta"in e&&"tracks"in e.meta){var t=e.meta.tracks;for(var i in t)if("video"==t[i].type)return!0}return!1}function n(e){if(i.player&&i.player.api&&i.player.api.unload&&(i.log("Received new stream info while a player was already loaded: unloading player"),i.player.api.unload()),i.info=e,i.info.updated=new Date,MistUtil.event.send("haveStreamInfo",e,i.options.target),i.log("Stream info was loaded succesfully."),"error"in e){var n=e.error;return"on_error"in e?(i.log(n),n=e.on_error):"perc"in e&&(n+=" ("+Math.round(10*e.perc)/10+"%)"),void i.showError(n,{reload:!0,hideTitle:!0})}if(i.calcSize=function(e){e||(e={width:!1,height:!1});var r=e.width||!(!("width"in t)||!t.width)&&t.width,n=e.height||!(!("height"in t)||!t.height)&&t.height;if(this.info&&"source"in this.info)if(this.info.hasVideo&&"audio"!=this.source.type.split("/")[1]){if(!r||!n){var a=i.info.width/i.info.height;if(r||n)r?n=r/a:r=n*a;else{var s="maxwidth"in t&&t.maxwidth?t.maxwidth:window.innerWidth,o="maxheight"in t&&t.maxheight?t.maxheight:window.innerHeight;r=i.info.width,n=i.info.height;function l(e){r/=e,n/=e}r<426&&l(r/426),n<240&&l(n/240),s&&r>s&&l(r/s),o&&n>o&&l(n/o)}}}else r||(r=480),n||(n=42);else r=640,n=480;return this.size={width:Math.round(r),height:Math.round(n)},this.size},e.hasVideo=r(e),"live"==e.type){var a=0;for(var s in i.info.meta.tracks)a=Math.max(a,i.info.meta.tracks[s].lastms);e.lastms=a}else{var o=i.resumeTime;if(o){var l=function(){i.player&&i.player.api&&(i.player.api.currentTime=o),this.removeEventListener("initialized",l)};MistUtil.event.addListener(i.options.target,"initialized",l)}}i.options.ABR_bitrate&&i.options.ABR_resize&&i.info&&!i.info.selver&&(i.options.ABR_bitrate=!1),i.choosePlayer()?(i.reporting&&i.reporting.report({player:i.playerName,sourceType:i.source.type,sourceUrl:i.source.url,pageUrl:location.href}),i.player=new mistplayers[i.playerName].player,i.player.onreadylist=[],i.player.onready=function(e){this.onreadylist.push(e)},i.player.build(i,(function(e){if(i.log("Building new player"),i.container.removeAttribute("data-loading"),i.video=e,i.reporting&&i.reporting.init(),"api"in i.player){i.monitor={MistVideo:i,delay:1,averagingSteps:20,threshold:function(){return"webrtc"==this.MistVideo.source.type?.95:.75},init:function(){if(!this.vars||!this.vars.active){this.MistVideo.log("Enabling monitor"),this.vars={values:[],score:!1,active:!0};var e=this;!function t(){e.vars&&e.vars.active&&(e.vars.timer=e.MistVideo.timers.start((function(){var i=e.calcScore();!1!==i&&e.check(i)&&e.action(),t()}),1e3*e.delay))}()}},destroy:function(){this.vars&&this.vars.active&&(this.MistVideo.log("Disabling monitor"),this.MistVideo.timers.stop(this.vars.timer),delete this.vars)},reset:function(){this.vars&&this.vars.active?(this.MistVideo.log("Resetting monitor"),this.vars.values=[]):this.init()},calcScore:function(){var e=this.vars.values;if(e.push(this.getValue()),e.length<=1)return!1;var t=this.valueToScore(e[0],e[e.length-1]);return e.length>this.averagingSteps&&e.shift(),t=Math.max(t,e[e.length-1].score),this.vars.score=t,i.reporting&&i.reporting.stats.set("playbackScore",Math.round(10*t)/10),t},valueToScore:function(e,t){var i=1;return"player"in this.MistVideo&&"api"in this.MistVideo.player&&"playbackRate"in this.MistVideo.player.api&&(i=this.MistVideo.player.api.playbackRate),(t.video-e.video)/(t.clock-e.clock)/i},getValue:function(){var e={clock:.001*(new Date).getTime(),video:this.MistVideo.player.api.currentTime};return this.vars.values.length&&(e.score=this.valueToScore(this.vars.values[this.vars.values.length-1],e)),e},check:function(e){return!(this.vars.values.length<.5*this.averagingSteps)&&(e=e.socket.CLOSING&&e.init(),this.send_queue.push(t)};var t=!1;if(e.socket.setTracks=function(){e.s({type:"tracks",meta:MistUtil.object.keys(e.subscriptions).join(",")})},e.socket.onopen=function(){for(i.log("Metadata socket opened"),e.socket.setTracks(),1!=i.player.api.playbackRate&&e.s({type:"set_speed",play_rate:i.player.api.playbackRate}),e.s({type:"seek",seek_time:Math.round(1e3*i.player.api.currentTime),ff_to:Math.round(1e3*(i.player.api.currentTime+5))}),e.socket.addEventListener("message",(function(r){if(r.data){var n=JSON.parse(r.data);if(n){if("time"in n&&"track"in n&&"data"in n){var a=!1;if("all"in e.subscriptions&&(e.subscriptions.all.buffer.push(n),a=!0),n.track in e.subscriptions&&(e.subscriptions[n.track].buffer.push(n),a=!0),a)if(e.checktimer){var s=i.timers.list[e.checktimer];if(s)s>(new Date).getTime()+n.time-1e3*i.player.api.currentTime&&(i.log("The metadata socket received a message that should be displayed sooner than the current check time; resetting"),i.timers.stop(e.checktimer),e.checktimer=null,e.check())}else e.check()}if("type"in n)switch(n.type){case"on_time":!t&&n.data.current>1e3*(i.player.api.currentTime+30)&&(t=!0,e.s({type:"hold"}),i.log("Pausing metadata buffer because it is very far ahead, checking again in 5 seconds: "+n.data.current+" > "+1e3*i.player.api.currentTime),i.timers.start((function(){i.player.api.paused||e.s({type:"play"}),e.s({type:"fast_forward",ff_to:Math.round(1e3*(i.player.api.currentTime+5))})}),5e3));break;case"seek":for(var o in e.subscriptions)e.subscriptions[o].buffer=[];i.log("Cleared metadata buffer after completed seek"),e.checktimer&&(i.timers.stop(e.checktimer),e.checktimer=null)}}else i.log("Subtitle websocket received invalid message.")}else i.log("Subtitle websocket received empty message.")})),e.socket.onclose=function(){i.log("Metadata socket closed")};e.send_queue.length&&e.socket.readyState==e.socket.OPEN;)e.s(e.send_queue.shift())},!("seeked"in this.listeners)){var r=(new Date).getTime();e.check=function(){if(e.checktimer&&(i.timers.stop(e.checktimer),e.checktimer=null),!i.player.api.paused){var t=null;for(var n in e.subscriptions){for(var a=e.subscriptions[n].buffer;a.length&&a[0].time<=1e3*i.player.api.currentTime;){var s=a.shift();if(!(s.time<1e3*(i.player.api.currentTime-5)))for(var o in e.subscriptions[n].callbacks)e.subscriptions[n].callbacks[o].call(i,s)}a.length&&(t=Math.min(null===t?1e9:t,a[0].time))}var l=(new Date).getTime();if(l>r+5e3&&(e.s({type:"fast_forward",ff_to:Math.round(1e3*(i.player.api.currentTime+5))}),r=l),t){var c=t-1e3*i.player.api.currentTime;e.checktimer=i.timers.start((function(){e.check()}),c)}}},this.listeners.seeked=MistUtil.event.addListener(i.video,"seeked",(function(){for(var t in e.subscriptions)e.subscriptions[t].buffer=[];e.s({type:"seek",seek_time:Math.round(1e3*i.player.api.currentTime),ff_to:Math.round(1e3*(i.player.api.currentTime+5))}),r=(new Date).getTime()})),this.listeners.pause=MistUtil.event.addListener(i.video,"pause",(function(){e.s({type:"hold"}),i.timers.stop(e.checktimer),e.checktimer=null})),this.listeners.playing=MistUtil.event.addListener(i.video,"playing",(function(){e.s({type:"play"}),e.checktimer||e.check()})),this.listeners.ratechange=MistUtil.event.addListener(i.video,"ratechange",(function(){e.s({type:"set_speed",play_rate:i.player.api.playbackRate})}))}e.socket.readyState==e.socket.OPEN&&e.socket.onopen()},destroy:function(){for(var e in i.log("Closing metadata socket.."),this.socket.close(),this.socket=null,this.subscriptions={},this.listeners)MistUtil.event.removeListener(this.listeners[e]);this.listeners={}},add:function(e,t){"function"!=typeof e||t||(t=e,e="all"),"function"==typeof t&&(e in this.subscriptions||(this.subscriptions[e]={buffer:[],callbacks:[]}),this.subscriptions[e].callbacks.push(t),null===this.socket?this.init():this.socket.setTracks())},remove:function(e,t){if(e in this.subscriptions){for(var i in this.subscriptions[e].callbacks)if(t==this.subscriptions[e].callbacks[i]){this.subscriptions[e].callbacks.splice(i,1);break}0==this.subscriptions[e].callbacks.length&&(delete this.subscriptions[e],MistUtil.object.keys(this.subscriptions).length?this.socket.setTracks():this.destroy())}}},"function"==typeof t.subscribeToMetaTrack&&(t.subscribeToMetaTrack=[["all",t.subscribeToMetaTrack]]),t.subscribeToMetaTrack.length))for(var n in"object"!=typeof t.subscribeToMetaTrack[0]&&(t.subscribeToMetaTrack=[t.subscribeToMetaTrack]),t.subscribeToMetaTrack)i.metaTrackSubscriptions.add.apply(i.metaTrackSubscriptions,t.subscribeToMetaTrack[n])}}MistUtil.empty(i.options.target),new MistSkin(i),i.container=new MistUI(i),i.options.target.appendChild(i.container),i.container.setAttribute("data-loading",""),i.video.p=i.player;r=["abort","canplay","canplaythrough",,"emptied","ended","loadeddata","loadedmetadata","loadstart","pause","play","playing","ratechange","seeked","seeking","stalled","volumechange","waiting","metaUpdate_tracks","resizing"];for(var n in r)MistUtil.event.addListener(i.video,r[n],(function(e){e.message&&"chromecast"==e.message||i.log("Player event fired: "+e.type)}));if(MistUtil.event.addListener(i.video,"error",(function(e){var t;if("player"in i&&"api"in i.player&&"error"in i.player.api&&i.player.api.error)if("message"in i.player.api.error)t=i.player.api.error.message;else if("code"in i.player.api.error&&i.player.api.error instanceof MediaError){var r={1:"MEDIA_ERR_ABORTED: The fetching of the associated resource was aborted by the user's request.",2:"MEDIA_ERR_NETWORK: Some kind of network error occurred which prevented the media from being successfully fetched, despite having previously been available.",3:"MEDIA_ERR_DECODE: Despite having previously been determined to be usable, an error occurred while trying to decode the media resource, resulting in an error.",4:"MEDIA_ERR_SRC_NOT_SUPPORTED: The associated resource or media provider object (such as a MediaStream) has been found to be unsuitable."};t=i.player.api.error.code in r?r[i.player.api.error.code]:"MediaError code "+i.player.api.error.code}else"string"!=typeof(t=i.player.api.error)&&(t=JSON.stringify(t));else t="An error was encountered.";"Stream is online"==i.state?i.showError(t):(i.log(t,"error"),i.showError(i.state,{polling:!0}))})),"setSize"in i.player&&(i.player.videocontainer=i.video.parentNode,i.video.currentTarget=i.options.target,MistUtil.class.has(i.options.target,"mistvideo-secondaryVideo")||(i.player.resizeAll=function(){function e(t,i){if(t.video.currentTarget==i)return t.video;if(t.secondary)for(var r=0;r3600&&(t.reloadDelay/=1e3,this.log("A reloadDelay of more than an hour was set: assuming milliseconds were intended. ReloadDelay is now "+t.reloadDelay+"s")),new MistSkin(this),this.checkCombo=function(e,t){e||(e={}),e=MistUtil.object.extend(MistUtil.object.extend({},this.options),e);var r,n,a=!1;for(var s in e.forceSource?(r=[i.info.source[e.forceSource]],i.log("Forcing source "+e.forceSource+": "+r[0].type+" @ "+r[0].url)):e.forceType?(r=i.info.source.filter((function(t){return t.type==e.forceType})),i.log("Forcing type "+e.forceType)):r=i.info.source,mistplayers)mistplayers[s].shortname=s;e.forcePlayer&&mistplayers[e.forcePlayer]?(n=[mistplayers[e.forcePlayer]],i.log("Forcing player "+e.forcePlayer)):n=MistUtil.object.values(mistplayers),r=[].concat(r);var o={first:"source",source:[function(e){return"origIndex"in e||(e.origIndex=i.info.source.indexOf(e)),e.origIndex}],player:[{priority:1}]},l={inner:"player",outer:"source"};if(e.forcePriority){if("source"in e.forcePriority){if(!(e.forcePriority.source instanceof Array))throw"forcePriority.source is not an array.";o.source=e.forcePriority.source.concat(o.source),MistUtil.array.multiSort(r,o.source)}if("player"in e.forcePriority){if(!(e.forcePriority.player instanceof Array))throw"forcePriority.player is not an array.";o.player=e.forcePriority.player.concat(o.player),MistUtil.array.multiSort(n,o.player)}"first"in e.forcePriority&&(o.first=e.forcePriority.first),"player"==o.first&&(l.outer="player",l.inner="source")}var c={player:{list:n,current:!1},source:{list:r,current:!1}};if(e.startCombo){e.startCombo.started={player:!1,source:!1};for(s=0;s=2))for(var v in c[l.inner].list)if(c[l.inner].current=v,!(d(l.inner)>=1)){a=c.source.list[c.source.current];var y=c.player.list[c.player.current].shortname,g=mistplayers[y];if(g.isMimeSupported(a.type)){var b=g.isBrowserSupported(a.type,a,i);if(b){var k=p(b);if(k>u.score&&(t||i.log("Found a "+(u.score?"better":"working")+" combo: "+g.name+" with "+a.url+" (Score: "+k+")"),(u={score:k,player:y,source:a,source_index:c.source.current}).score==m))return u}}}return!!u.score&&u},this.choosePlayer=function(){i.log("Checking available players..");var e=this.checkCombo();if(!e)return!1;var t=mistplayers[e.player],r=e.source;return i.log("Selected: "+t.name+" with "+r.type+" @ "+r.url),i.playerName=e.player,(r=MistUtil.object.extend({},r)).index=e.source_index,r.url=i.urlappend(r.url),i.source=r,MistUtil.event.send("comboChosen","Player/source combination selected",i.options.target),!0},i.calcSize=function(){return{width:640,height:480}},MistUtil.empty(i.options.target),new MistSkin(i),i.container=new MistUI(i,i.skin.structure.placeholder),i.options.target.appendChild(i.container),i.container.setAttribute("data-loading",""),"WebSocket"in window){!function e(){i.log("Opening stream status stream through websocket..");var t,s=i.options.host.replace(/^http/i,"ws");s=MistUtil.http.url.addParam(i.urlappend(s+"/json_"+encodeURIComponent(i.stream)+".js"),{metaeverywhere:1,inclzero:1});try{t=new WebSocket(s)}catch(e){return i.log("Error while attempting to open WebSocket to "+s),void a()}i.socket=t,t.die=!1,t.destroy=function(){this.die=!0,i.reporting&&(i.reporting.reportStats(),i.reporting=!1),this.onclose=function(){},this.close()},t.timeOut=i.timers.start((function(){t.readyState<=1&&(t.destroy(),a())}),5e3),t.onopen=function(e){this.wasConnected=!0,i.reporting||(i.reporting={stats:{set:function(e,t){this.d[e]=t},add:function(e,t){void 0===t&&(t=1),this.d[e]+=t},d:{nWaiting:0,timeWaiting:0,nStalled:0,timeStalled:0,timeUnpaused:0,nError:0,nLog:0,videoHeight:null,videoWidth:null,playerHeight:null,playerWidth:null},last:{firstPlayback:null,nWaiting:0,timeWaiting:0,nStalled:0,timeStalled:0,timeUnpaused:0,nError:0,lastError:null,playbackScore:1,nLog:0,autoplay:null,videoHeight:null,videoWidth:null,playerHeight:null,playerWidth:null}},report:function(e){1==i.socket.readyState&&i.socket.send(JSON.stringify(e))},reportStats:function(){var e={},t=!1,r=i.logs.slice(this.stats.last.nLog);for(var n in this.stats.d)this.stats.d[n]!=this.stats.last[n]&&(e[n]=this.stats.d[n],this.stats.last[n]=e[n],t=!0);if(t){if(r.length)for(var n in e.logs=[],r)e.logs.push(r[n].message);this.report(e)}i.timers.start((function(){i.reporting&&i.reporting.reportStats()}),5e3)},init:function(){var e=i.video,t=MistUtil.event.addListener(e,"playing",(function(){i.reporting.stats.set("firstPlayback",(new Date).getTime()-i.bootMs),MistUtil.event.removeListener(t)}));if(MistUtil.event.addListener(e,"waiting",(function(){i&&i.reporting&&i.reporting.stats.add("nWaiting")})),MistUtil.event.addListener(e,"stalled",(function(){i&&i.reporting&&i.reporting.stats.add("nStalled")})),MistUtil.event.addListener(i.options.target,"error",(function(e){i&&i.reporting&&(i.reporting.stats.add("nError"),i.reporting.stats.set("lastError",e.message))}),e),Object&&Object.defineProperty){var r=0,n=!1,a=0,s=!1,o=0,l=!1,c=i.reporting.stats.d;Object.defineProperty(c,"timeWaiting",{get:function(){return r+(n?(new Date).getTime()-n:0)}}),Object.defineProperty(c,"timeStalled",{get:function(){return a+(s?(new Date).getTime()-s:0)}}),Object.defineProperty(c,"timeUnpaused",{get:function(){return o+(l?(new Date).getTime()-l:0)}}),Object.defineProperty(c,"nLog",{get:function(){return i.logs.length}}),Object.defineProperty(c,"videoHeight",{get:function(){return i.video?i.video.videoHeight:null}}),Object.defineProperty(c,"videoWidth",{get:function(){return i.video?i.video.videoWidth:null}}),Object.defineProperty(c,"playerHeight",{get:function(){return i.video?i.video.clientHeight:null}}),Object.defineProperty(c,"playerWidth",{get:function(){return i.video?i.video.clientWidth:null}}),MistUtil.event.addListener(e,"waiting",(function(){r=c.timeWaiting,n=(new Date).getTime()})),MistUtil.event.addListener(e,"stalled",(function(){a=c.timeStalled,s=(new Date).getTime()}));var d=["playing","pause"];for(var u in d)MistUtil.event.addListener(e,d[u],(function(){r=c.timeWaiting,a=c.timeStalled,n=!1,s=!1}));MistUtil.event.addListener(e,"playing",(function(){o=c.timeUnpaused,l=(new Date).getTime()})),MistUtil.event.addListener(e,"pause",(function(){o=c.timeUnpaused,l=!1}))}this.reportStats()}})},t.onclose=function(t){if(!this.die)return this.wasConnected?(i.log("Reopening websocket.."),void e()):void a()};var o=!1;t.addEventListener("message",(function(e){t.timeOut&&(i.timers.stop(t.timeOut),t.timeOut=!1);var a=JSON.parse(e.data);if(a||i.showError("Error while parsing stream status stream. Obtained: "+e.data.toString(),{reload:!0}),"error"in a){var s;e=a.error;switch("on_error"in a?(i.log(e),e=a.on_error):"perc"in a&&(e+=" ("+Math.round(10*a.perc)/10+"%)"),i.state=a.error,a.error){case"Stream is offline":i.info=!1,i.player&&i.player.api&&i.player.api.currentTime&&(i.resumeTime=i.player.api.currentTime);case"Stream is initializing":case"Stream is booting":case"Stream is waiting for data":case"Stream is shutting down":case"Stream status is invalid?!":if(i.player&&i.player.api&&!i.player.api.paused)return i.log(a.error,"error"),o||(o=MistUtil.event.addListener(i.video,"ended",(function(){i.showError(a.error,{polling:!0})}))),void(o=MistUtil.event.addListener(i.video,"waiting",(function(){i.showError(a.error,{polling:!0})})));s={polling:!0};break;default:s={reload:!0}}i.showError(e,s)}else{if(i.state="Stream is online",i.clearError(),o&&MistUtil.event.removeListener(o),!i.info)return void n(a);var l=function e(t,i){if(t==i)return!1;if("object"==typeof t&&void 0!==i){var r={};for(var n in t)if(!(MistUtil.array.indexOf(["lastms","hasVideo"],n)>=0)){var a=e(t[n],i[n]);a&&(r[n]=!0===a?[t[n],i[n]]:a)}for(var n in i)MistUtil.array.indexOf(["lastms","hasVideo"],n)>=0||n in t||(r[n]=[t[n],i[n]]);return!!MistUtil.object.keys(r).length&&r}return!0}(a,i.info);if(l){if("source"in l&&"error"in i.info)return void i.reload("Reloading, stream info has error");i.info=MistUtil.object.extend(i.info,a),i.info.updated=new Date;var c=!1;for(var d in l)switch(d){case"meta":for(var u in l[d])if("tracks"===u)i.info.hasVideo=r(i.info),MistUtil.event.send("metaUpdate_tracks",a,i.video);break;case"width":case"height":c=!0}c&&i.player.resize()}else i.log("Metachange: no differences detected")}}))}()}else a();return this.unload=function(e){if(!this.destroyed){for(var t in this.log("Unloading.."),this.destroyed=!0,this.timers.stop("all"),this.errorListeners){var r=this.errorListeners[t];if(r.src in MistUtil.scripts.list){var n=MistUtil.array.indexOf(MistUtil.scripts.list[r.src].subscribers);n>=0&&MistUtil.scripts.list[r.src].subscribers.splice(n,1)}}if("monitor"in i&&"destroy"in i.monitor&&i.monitor.destroy(),this.socket&&(this.reporting&&(this.reporting.reportStats(),this.reporting.report({unload:e||null})),this.socket.destroy()),this.player&&this.player.api&&("pause"in this.player.api&&this.player.api.pause(),"setSource"in this.player.api&&this.player.api.setSource(""),"unload"in this.player.api))try{this.player.api.unload()}catch(a){i.log("Error while unloading player: "+a.message)}if(this.metaTrackSubscriptions&&this.metaTrackSubscriptions.socket&&this.metaTrackSubscriptions.destroy(),this.UI&&this.UI.elements)for(var t in this.UI.elements){var a=this.UI.elements[t];if("attachedListeners"in a)for(var t in a.attachedListeners)MistUtil.event.removeListener(a.attachedListeners[t]);a.parentNode&&a.parentNode.removeChild(a)}this.video&&MistUtil.empty(this.video),"container"in this&&(MistUtil.empty(this.container),delete this.container),MistUtil.empty(this.options.target),delete this.video}},this.reload=function(e){var t="player"in this&&"api"in this.player&&this.player.api.currentTime;this.unload(e);var r=mistPlay(this.stream,this.options);if(t&&"live"!=this.info.type){var n=function(){r.player&&r.player.api&&(r.player.api.currentTime=t),this.removeEventListener("initialized",n)};MistUtil.event.addListener(this.options.target,"initialized",n)}return i},this.nextCombo=function(){var e=!1;"player"in this&&"api"in this.player&&(e=this.player.api.currentTime);var t={source:this.source.index,player:this.playerName};if(!this.checkCombo({startCombo:t},!0)){if(!this.checkCombo({startCombo:!1},!0))return;t=!1}this.unload("nextCombo");var r=this.options;if(r.startCombo=t,i=mistPlay(this.stream,r),e&&isFinite(e)&&"live"!=this.info.type){var n=function(){"player"in i&&"api"in i.player&&(i.player.api.currentTime=e),this.removeEventListener("initialized",n)};MistUtil.event.addListener(r.target,"initialized",n)}},this.onPlayerBuilt=function(){},t.MistVideoObject&&(t.MistVideoObject.reference=this),this} \ No newline at end of file +var MistUtil={format:{time:function(e,t){if(isNaN(e)||!isFinite(e))return e;t||(t={});var i=e<0?" ago":"";e=Math.abs(e);var r=Math.floor(e/86400);e-=86400*r;var n=Math.floor(e/3600);e-=3600*n;var a=Math.floor(e/60),s=Math.round(e%1*1e3);e=Math.floor(e-60*a);var o=[];return r&&(r=r+" day"+(r>1?"s":"")+", "),n||r?(o.push(n),o.push(("0"+a).slice(-2))):o.push(a),o.push(("0"+Math.floor(e)).slice(-2)),t.ms&&(o[o.length-1]+="."+("000"+s).slice(-3)),(r||"")+o.join(":")+i},ago:function(e,t){if(isNaN(e.getTime()))return"";var i=t||(new Date).getTime()-e.getTime(),r="",n=i<0;return n&&(i*=-1),i<1e3?r="live":i<6e4?(r=Math.round(i/1e3)+" sec",n?r="in "+r:r+=" ago"):r=!t&&(new Date).toLocaleDateString()==e.toLocaleDateString()||t<864e5?e.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",second:"2-digit"}):i<5184e5?e.toLocaleString(void 0,{weekday:"short",hour:"numeric",minute:"2-digit",second:"2-digit"}):!t&&(new Date).getFullYear()==e.getFullYear()||t<316224e5?e.toLocaleString(void 0,{month:"short",day:"numeric",weekday:"short",hour:"numeric",minute:"2-digit",second:"2-digit"}):e.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}),r},ucFirst:function(e){return e.charAt(0).toUpperCase()+e.slice(1)},number:function(e){if(isNaN(Number(e))||0==Number(e))return e;var t=Math.max(3,Math.ceil(Math.log(e)/Math.LN10)),i=Math.pow(10,t-Math.floor(Math.log(e)/Math.LN10)-1);if((e=Math.round(e*i)/i)>=1e4){number=e.toString().split(".");for(var r=/(\d+)(\d{3})/;r.test(number[0]);)number[0]=number[0].replace(r,"$1 $2");e=number.join(".")}return e},bytes:function(e,t){if(isNaN(Number(e)))return e;var i=t?["bits","Kb","Mb","Gb","Tb","Pb"]:["bytes","KB","MB","GB","TB","PB"];if(0==e)unit=i[0];else{var r=Math.floor(Math.log(Math.abs(e))/Math.log(1024));r<0?unit=i[0]:(e/=Math.pow(1024,r),unit=i[r])}return this.number(e)+unit},bits:function(e){return this.bytes(e,!0)},mime2human:function(e){switch(e){case"html5/video/webm":return"WebM";case"html5/application/vnd.apple.mpegurl":return"HLS (TS)";case"html5/application/vnd.apple.mpegurl;version=7":return"HLS (CMAF)";case"flash/10":return"Flash (RTMP)";case"flash/11":return"Flash (HDS)";case"flash/7":return"Flash (Progressive)";case"html5/video/mpeg":return"TS";case"html5/application/vnd.ms-sstr+xml":case"html5/application/vnd.ms-ss":return"Smooth Streaming";case"dash/video/mp4":return"DASH";case"webrtc":return"WebRTC (WS)";case"whep":return"WebRTC (WHEP)";case"silverlight":return"Smooth streaming (Silverlight)";case"html5/text/vtt":return"VTT subtitles";case"html5/text/plain":return"SRT subtitles";default:return e.replace("html5/","").replace("video/","").replace("audio/","").toLocaleUpperCase()}}},class:{add:function(e,t){if("classList"in e)e.classList.add(t);else{var i=this.get(e);i.push(t),this.set(e,i)}},remove:function(e,t){if("classList"in e)e.classList.remove(t);else{for(var i=this.get(e),r=i.length-1;r>=0;r--)i[r]==t&&i.splice(r);this.set(e,i)}},get:function(e){var t=e.getAttribute("class");return t&&""!=t?t.split(" "):[]},set:function(e,t){e.setAttribute("class",t.join(" "))},has:function(e,t){return e.className.split(" ").indexOf(t)>=0}},object:{extend:function(e,t,i){for(var r in t)!i||"object"!=typeof t[r]||"nodeType"in t[r]?e[r]=t[r]:(r in e||(MistUtil.array.is(t[r])?e[r]=[]:e[r]={}),this.extend(e[r],t[r],!0));return e},keys:function(e,t){var i=[];for(var r in e)i.push(r);return t&&("function"!=typeof t&&(t=function(e,t){return e.localeCompare(t)}),i.sort(function(i,r){return t(i,r,e[i],e[r])})),i},values:function(e,t){var i=this.keys(e,t);for(var r in values=[],i)values.push(e[i[r]]);return values}},array:{indexOf:function(e,t){if(!(e instanceof Array))throw"Tried to use indexOf on something that is not an array";if("indexOf"in e)return e.indexOf(t);for(var i;it?1:e=0?r:i.length}if("function"==typeof e)return e(t);if("object"==typeof e){if(e instanceof Array)return i(t,e[0],e[1]);for(var r in e)return i(t,r,e[r])}if(e in t)return t[e];throw"Invalid sorting rule: "+e+". This should be a function, object or key of "+JSON.stringify(t)+"."}return e.sort(function(e,n){var a=0;for(var s in t){var o=t[s];if(0!=(a=i(r(o,e),r(o,n))))break}return a}),e}},createUnique:function(){var e="uid"+Math.random().toString().replace("0.","");return document.querySelector("."+e)?createUnique():e},http:{getpost:function(e,t,i,r,n){var a=new XMLHttpRequest;if(a.open(e,t,!0),"POST"==e&&a.setRequestHeader("Content-type","application/x-www-form-urlencoded"),n&&(a.timeout=8e3),a.onload=function(){var e=a.status;e>=200&&e<300?r(a.response):n&&n(a)},n&&(a.onerror=function(){n(a)},a.ontimeout=a.onerror),"POST"==e){var s,o=[];for(var l in i)o.push(l+"="+encodeURIComponent(i[l]));o.length&&(s=o.join("&")),a.send(s)}else a.send()},get:function(e,t,i){this.getpost("GET",e,null,t,i)},post:function(e,t,i,r){this.getpost("POST",e,t,i,r)},url:{addParam:function(e,t){var i=e.split("?"),r=[i.shift()],n=[];for(var a in i.length&&(n=i[0].split("&")),t)n.push(a+"="+t[a]);return n.length&&r.push(n.join("&")),r.join("?")},append:function(e,t){var i=document.createElement("a");return i.href=e,"?"==t[0]?""==i.search?i.search=t:i.search+="&"+t.slice(1):"&"==t[0]?""==i.search?i.search="?"+t.slice(1):i.search+=t:i.href+=t,i.href},split:function(e){var t=document.createElement("a");return t.href=e,{protocol:t.protocol,host:t.hostname,hash:t.hash,port:t.port,path:t.pathname.replace(/\/*$/,"")}},sanitizeHost:function(e){var t=MistUtil.http.url.split(e);return t.protocol+"//"+t.host+(t.port&&""!=t.port?":"+t.port:"")+(t.hash&&""!=t.hash?"#"+t.hash:"")+(t.path?"/"==t.path.charAt(0)?t.path:"/"+t.path:"")}}},css:{cache:{},load:function(e,t,i){var r=document.createElement("style");r.type="text/css",r.setAttribute("data-source",e),i&&(r.callback=i);var n=this.cache;function a(e){var i=MistUtil.css.applyColors(e,t);"callback"in r?r.callback(i):r.textContent=i}if(e in n)n[e]instanceof Array?n[e].push(a):a(n[e]);else{n[e]=[a];var s=3;!function t(){MistUtil.http.get(e,function(t){for(var i in n[e])n[e][i](t);n[e]=t},function(){if(s>0)s--,setTimeout(t,2e3);else{var i="/*Failed to load*/";for(var r in n[e])n[e][r](i);n[e]=i}})}()}return r},applyColors:function(e,t){return e.replace(/\$([^\s^;^}]*)/g,function(e,i){var r=i.split("."),n=t;for(var a in r)n=n[r[a]];return n})},createStyle:function(e,t,i){var r=document.createElement("style");return r.type="text/css",e&&(t&&(e=this.prependClass(e,t,i)),r.textContent=e),r},prependClass:function(e,t,i){var r=!1;"string"!=typeof e&&("unprepended"in(r=e)||(r.unprepended=r.textContent),e=r.unprepended);var n=(e=e.replace(/\/\*.*?\*\//g,"")).match(/@[^}]*}/g);for(var a in n){e=e.replace(n[a],"@@#@@");for(var s=1;s0)s=r.bps>131072?Math.round(r.bps/1024/1024*8)+"mbps":Math.round(r.bps/1024*8)+"kbps",n[a]=s;break;case"fpks":r.fpks>0&&(n[a]=r.fpks/1e3+"fps");break;case"channels":r.channels>0&&(n[a]=1==r.channels?"Mono":2==r.channels?"Stereo":"Surround ("+r.channels+"ch)");break;case"rate":n[a]=Math.round(.001*r.rate)+"Khz";break;case"language":"Undetermined"!=r[a]&&(n[a]=r[a]);break;case"codec":if("meta"==r.codec)continue;n[a]=r[a]}r.describe=n}for(var o in t){var l=!1;for(var i in t[o])if(l){if(MistUtil.object.keys(t[o]).length>1)for(var a in t[o][i].describe)l[a]!=t[o][i].describe[a]&&delete l[a]}else l=MistUtil.object.extend({},t[o][i].describe);for(var i in t[o]){var c={},d={};for(var a in t[o][i].describe)a in l?d[a]=t[o][i].describe[a]:c[a]=t[o][i].describe[a];t[o][i].different=c,t[o][i].same=d;var u=MistUtil.object.values(c);t[o][i].displayName=u.length?u.join(", "):MistUtil.object.values(t[o][i].describe).join(" ")}var p={};for(var i in t[o]){if(t[o][i].displayName in p){var h=1;for(var i in t[o])t[o][i].different.trackid=h+")",t[o][i].displayName="Track "+h+" ("+t[o][i].displayName+")",h++;break}p[t[o][i].displayName]=1}}return t},translateCodec:function(e){function t(t){return("0"+e.init.charCodeAt(t).toString(16)).slice(-2)}switch(e.codec){case"AAC":return"mp4a.40.2";case"MP3":return"mp3";case"AC3":return"ec-3";case"H264":return"avc1."+t(1)+t(2)+t(3);case"HEVC":return"hev1."+t(1)+t(6)+t(7)+t(8)+t(9)+t(10)+t(11)+t(12);default:return e.codec.toLowerCase()}}},isTouchDevice:function(){return"ontouchstart"in window||navigator.msMaxTouchPoints>0},getPos:function(e,t){e.currentStyle||window.getComputedStyle(e,null);for(var i=1,r=e;r;)r.style.zoom&&""!=r.style.zoom&&(i*=parseFloat(r.style.zoom,10)),r=r.parentElement;var n=e.getBoundingClientRect().left-(parseInt(e.borderLeftWidth,10)||0),a=e.getBoundingClientRect().width,s=Math.max(0,(t.clientX/i-n)/a);return s=Math.min(s,1)},createGraph:function(e,t){var i="http://www.w3.org/2000/svg",r=document.createElementNS(i,"svg");r.setAttributeNS(null,"height","100%"),r.setAttributeNS(null,"width","100%"),r.setAttributeNS(null,"class","mist icon graph"),r.setAttributeNS(null,"preserveAspectRatio","none");var n=e.x[0],a=e.y[0];if(t.differentiate)for(var s=1;st.x.count&&(l.shift(),d()),d(e.x-n,-1*e.y),this.setAttributeNS(null,"d","M"+l.join(" L")),h()}},r.addData=function(e){m.addData(e)},r},getBrowser:function(){var e=window.navigator.userAgent;return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0?"ie":e.indexOf("Edge/")>=0?"edge":e.indexOf("Opera")>=0||e.indexOf("OPR")>=0?"opera":e.indexOf("Chrome")>=0?"chrome":e.indexOf("Safari")>=0?"safari":e.indexOf("Firefox")>=0&&"firefox"},getAndroid:function(){var e=navigator.userAgent.toLowerCase().match(/android\s([\d\.]*)/i);return!!e&&e[1]},sources:{find:function(e,t){e:for(var i in e){for(var r in t)if("protocol"==r){if(e[i].url.slice(0,t.protocol.length)!=t.protocol)continue e}else if(e[i][r]!=t[r])continue e;return e[i]}return!1}}};if(void 0===MistSkins)var MistSkins={};if("undefined"!=typeof mistoptions&&"host"in mistoptions)var misthost=MistUtil.http.url.sanitizeHost(mistoptions.host);else misthost="..";function MistSkin(e){e.skin=this,this.applySkinOptions=function(t){var i;return"string"==typeof t&&t in MistSkins&&(t=MistUtil.object.extend({},MistSkins[t],!0)),i="inherit"in t&&t.inherit&&t.inherit in MistSkins?this.applySkinOptions(t.inherit):MistSkins.default,this.structure=MistUtil.object.extend({},i.structure),t&&"structure"in t&&MistUtil.object.extend(this.structure,t.structure),this.blueprints=MistUtil.object.extend({},i.blueprints),t&&"blueprints"in t&&MistUtil.object.extend(this.blueprints,t.blueprints),this.icons=MistUtil.object.extend({},i.icons,!0),t&&"icons"in t&&MistUtil.object.extend(this.icons.blueprints,t.icons),this.icons.build=function(t,i,r){i||(i=22);var n,a=this.blueprints[t];n="function"==typeof a.svg?a.svg.call(e,r):a.svg,"object"!=typeof i&&(i={height:i,width:i}),"object"!=typeof a.size&&(a.size={height:a.size,width:a.size}),(!("width"in i)&&"height"in i||!("height"in i)&&"width"in i)&&("width"in i&&(i.height=i.width*a.size.height/a.size.width),"height"in i&&(i.width=i.height*a.size.width/a.size.height));var s="";s+='',s+='',s+=n,s+="",s+="";var o=document.createElement("div");return o.innerHTML=s,o.firstChild},this.colors=MistUtil.object.extend({},i.colors),t&&"colors"in t&&MistUtil.object.extend(this.colors,t.colors,!0),this.css=MistUtil.object.extend({},i.css),t&&"css"in t&&MistUtil.object.extend(this.css,t.css),this},this.applySkinOptions("skin"in e.options?e.options.skin:"default");var t=[];for(var i in this.css)if("string"==typeof this.css[i]){var r=MistUtil.css.load(e.urlappend(this.css[i]),this.colors);t.push(r)}this.css=t}function MistUI(e,t){e.UI=this,this.elements=[],this.buildStructure=function(t){if("function"==typeof t&&(t=t.call(e)),"if"in t){var i=!1;if(t.if.call(e,t)?i=t.then:"else"in t&&(i=t.else),!i)return;for(var r in t)["if","then","else"].indexOf(r)<0&&(r in i?(i[r]instanceof Array||(i[r]=[i[r]]),i[r]=i[r].concat(t[r])):i[r]=t[r]);return this.buildStructure(i)}if("type"in t&&t.type in e.skin.blueprints){var n=e.skin.blueprints[t.type].call(e,t);if(!n)return;if(MistUtil.class.add(n,"mistvideo-"+t.type),"css"in t){var a=MistUtil.createUnique();for(var r in t.css=[].concat(t.css),t.css){var s=MistUtil.css.createStyle(t.css[r],a);n.appendChild(s)}MistUtil.class.add(n,a),n.uid=a}if("classes"in t)for(var r in t.classes)MistUtil.class.add(n,t.classes[r]);if("title"in t&&(n.title=t.title),"style"in t)for(var r in t.style)n.style[r]=t.style[r];if("children"in t)for(var r in t.children){var o=this.buildStructure(t.children[r]);o&&n.appendChild(o)}return e.UI.elements.push(n),n}return!1},this.build=function(){return this.buildStructure(t||e.skin.structure.main)};var i=this.build(),r=MistUtil.createUnique(),n=0;for(var a in e.skin.css.length&&(i.style.opacity=0),e.skin.css){var s=e.skin.css[a];s.callback=function(t){"/*Failed to load*/"==t?(this.textContent=t,e.showError("Failed to load CSS from "+this.getAttribute("data-source"))):this.textContent=MistUtil.css.prependClass(t,r,!0),n++,e.skin.css.length<=n&&(i.style.opacity="")},""!=s.textContent&&s.callback(s.textContent),i.appendChild(s)}MistUtil.class.add(i,r);var o=MistUtil.getBrowser();return o&&MistUtil.class.add(i,"browser-"+o),i}MistSkins.default={structure:{main:{if:function(){return!!this.info.hasVideo&&"audio"!=this.source.type.split("/")[1]},then:{type:"placeholder",classes:["mistvideo"],children:[{type:"hoverWindow",classes:["mistvideo-maincontainer"],mode:"pos",style:{position:"relative"},transition:{hide:"left: 0; right: 0; bottom: -43px;",show:"bottom: 0;",viewport:"left:0; right: 0; top: -1000px; bottom: 0;"},button:{type:"videocontainer"},children:[{type:"loading"},{type:"error"}],window:{type:"controls"}}]},else:{type:"container",classes:["mistvideo"],style:{overflow:"visible"},children:[{type:"controls",classes:["mistvideo-novideo"],style:{width:"480px"}},{type:"loading"},{type:"error"},{if:function(){return"stock"==this.options.controls},then:{type:"video",style:{position:"absolute"}},else:{type:"video",style:{position:"absolute",display:"none"}}}]}},videocontainer:{type:"container",children:[{type:"videobackground",alwaysDisplay:!1,delay:5},{type:"video"},{type:"subtitles"}]},controls:{if:function(){return!!(this.player&&this.player.api&&this.player.api.play)},then:{type:"container",classes:["mistvideo-column"],children:[{type:"progress",classes:["mistvideo-pointer"]},{type:"container",classes:["mistvideo-main","mistvideo-padding","mistvideo-row","mistvideo-background"],children:[{type:"play",classes:["mistvideo-pointer"]},{type:"currentTime"},{if:function(){return"size"in this&&this.size.width>300||!this.info.hasVideo||"audio"==this.source.type.split("/")[1]},then:{type:"totalTime"}},{type:"container",classes:["mistvideo-align-right"],children:[{type:"container",children:[{type:"container",classes:["mistvideo-volume_container"],children:[{type:"volume",mode:"horizontal",size:{height:22},classes:["mistvideo-pointer"]}]},{type:"speaker",classes:["mistvideo-pointer"],style:{"margin-left":"-2px"}}]},{if:function(){return"size"in this&&this.size.width>300||!this.info.hasVideo||"audio"==this.source.type.split("/")[1]},then:{type:"container",children:[{type:"chromecast",classes:["mistvideo-pointer"]},{type:"loop",classes:["mistvideo-pointer"]},{type:"fullscreen",classes:["mistvideo-pointer"]},{type:"picture-in-picture",classes:["mistvideo-pointer"]}]}},{type:"hoverWindow",mode:"pos",transition:{hide:"right: -1000px; bottom: 44px;",show:"right: 5px;",viewport:"right: 0; left: 0; bottom: 0; top: -1000px"},button:{type:"settings",classes:["mistvideo-pointer"]},window:{type:"submenu"}}]}]}]},else:{if:function(){return!(!this.player||!this.player.api)},then:{type:"hoverWindow",mode:"pos",transition:{hide:"right: -1000px; bottom: 44px;",show:"right: 2.5px;",viewport:"right: 0; left: -1000px; bottom: 0; top: -1000px"},style:{right:"5px",left:"auto"},button:{type:"settings",classes:["mistvideo-background","mistvideo-padding"]},window:{type:"submenu"}}}},submenu:{type:"container",style:{width:"80%",maxWidth:"25em",zIndex:2},classes:["mistvideo-padding","mistvideo-column","mistvideo-background"],children:[{type:"tracks"},{if:function(){return"size"in this&&this.size.width<=300},then:{type:"container",classes:["mistvideo-center"],children:[{type:"chromecast",classes:["mistvideo-pointer"]},{type:"loop",classes:["mistvideo-pointer"]},{type:"fullscreen",classes:["mistvideo-pointer"]},{type:"picture-in-picture",classes:["mistvideo-pointer"]}]}}]},placeholder:{type:"container",classes:["mistvideo","mistvideo-delay-display"],children:[{type:"placeholder"},{type:"loading"},{type:"error"}]},secondaryVideo:function(e){return{type:"hoverWindow",classes:["mistvideo"],mode:"pos",transition:{hide:"left: 10px; bottom: -40px;",show:"bottom: 10px;",viewport:"left: 0; right: 0; top: 0; bottom: 0"},button:{type:"container",children:[{type:"videocontainer"}]},window:{type:"switchVideo",classes:["mistvideo-controls","mistvideo-padding","mistvideo-background","mistvideo-pointer"],containers:e}}}},css:{skin:misthost+"/skins/default.css"},icons:{blueprints:{play:{size:45,svg:''},largeplay:{size:45,svg:''},pause:{size:45,svg:''},speaker:{size:45,svg:''},volume:{size:{width:100,height:45},svg:function(){var e=MistUtil.createUnique();return''}},muted:{size:45,svg:''},fullscreen:{size:45,svg:''},pip:{size:45,svg:''},loop:{size:45,svg:''},settings:{size:45,svg:''},loading:{size:100,svg:''},timeout:{size:25,svg:function(e){e&&e.delay||(e={delay:10});var t=e.delay,i=MistUtil.createUnique();return''}},popout:{size:45,svg:''},switchvideo:{size:45,svg:''}}},blueprints:{container:function(){return document.createElement("div")},video:function(){var e=this;if(MistUtil.event.addListener(e.video,"contextmenu",function(t){t.preventDefault(),e.container.setAttribute("data-show-submenu",""),e.container.removeAttribute("data-hide-submenu"),e.container.removeAttribute("data-hidecursor");var i=function(){e.container.removeAttribute("data-show-submenu"),e.container.removeEventListener("mouseout",i)};MistUtil.event.addListener(e.container,"mouseout",i)}),e.video.hideTimer=!1,e.video.hideCursor=function(){this.hideTimer&&clearTimeout(this.hideTimer),this.hideTimer=e.timers.start(function(){e.container.setAttribute("data-hidecursor","");var t=e.container.querySelector(".mistvideo-controls");t&&t.parentNode.setAttribute("data-hidecursor","")},3e3)},MistUtil.event.addListener(e.video,"mousemove",function(){e.container.removeAttribute("data-hidecursor");var t=e.container.querySelector(".mistvideo-controls");t&&t.parentNode.removeAttribute("data-hidecursor"),e.video.hideCursor()}),MistUtil.event.addListener(e.video,"mouseout",function(){e.video.hideTimer&&e.timers.stop(e.video.hideTimer)}),e.options.autoplay)var t=MistUtil.event.addListener(e.video,"canplay",function(){if(e.player.api&&e.player.api.paused){var i=e.player.api.play();i&&i.catch(function(t){if(!e.destroyed)if(e.log("Autoplay failed. Retrying with muted audio.."),e.info.hasVideo){e.player.api.muted=!0,MistUtil.event.send("volumechange",null,e.video);var i=e.player.api.play();i&&i.then(function(){e.reporting&&(e.reporting.stats.d.autoplay="success")}).then(function(){if(!e.destroyed){e.log("Autoplay worked! Video will be unmuted on mouseover if the page has been interacted with."),e.reporting&&(e.reporting.stats.d.autoplay="muted");var t=e.skin.icons.build("muted",100);MistUtil.class.add(t,"mistvideo-pointer"),e.container.appendChild(t),MistUtil.event.addListener(t,"click",function(){e.player.api.muted=!1,e.container.removeChild(t)});var i=!1,r=function(){i=!0,document.body.removeEventListener("click",r)};MistUtil.event.addListener(document.body,"click",r,e.video);var n=function(){i&&(e.player.api.muted=!1,e.video.removeEventListener("mouseenter",n),e.log("Re-enabled sound"))};MistUtil.event.addListener(e.video,"mouseenter",n);var a=function(){e.player.api.muted||(t.parentNode&&e.container.removeChild(t),e.video.removeEventListener("volumechange",a),document.body.removeEventListener("click",r),e.video.removeEventListener("mouseenter",n))};MistUtil.event.addListener(e.video,"volumechange",a)}}).catch(function(){if(!e.destroyed){e.log("Autoplay failed even with muted video. Unmuting and showing play button."),e.timers.start(function(){e.player.api.paused&&(e.player.api.pause(),e.monitor&&e.monitor.destroy())},5e3),e.reporting&&(e.reporting.stats.d.autoplay="failed"),e.player.api.muted=!1;var t=e.skin.icons.build("largeplay",150);MistUtil.class.add(t,"mistvideo-pointer"),e.container.appendChild(t),MistUtil.event.addListener(t,"click",function(){e.player.api.paused&&e.player.api.play()});var i=function(){e.container.removeChild(t),e.video.removeEventListener("play",i)};MistUtil.event.addListener(e.video,"play",i)}})}else e.reporting&&(e.reporting.stats.d.autoplay="failed")})}else e.reporting&&(e.reporting.stats.d.autoplay="success");MistUtil.event.removeListener(t)});return this.video},videocontainer:function(){return this.UI.buildStructure(this.skin.structure.videocontainer)},secondaryVideo:function(e){e||(e={}),e.options||(e.options={});var t=this;"secondary"in t||(t.secondary=[]);var i=MistUtil.object.extend({},t.options);i=MistUtil.object.extend(i,e.options),t.secondary.push(i);var r={primary:t,secondary:!1};i.target=document.createElement("div"),delete i.container;var n={};return i.MistVideoObject=n,MistUtil.event.addListener(i.target,"initialized",function(){var e=n.reference;i.MistVideo=e,r.secondary=e,e.player.api.muted=!0,e.player.api.loop=!1;for(var a=i.target.querySelectorAll(".mistvideo-controls"),s=0;s30)e.player.api.pausedesync=!0,e.player.api.currentTime=this.currentTime,e.log("Re-syncing with main video by seeking (desync: "+t+"s)");else if(i>.01){var r=.1;i<1&&(r=.05),(r=1+r*Math.sign(t))!=e.player.api.playbackRate&&e.log("Re-syncing by changing the playback rate (desync: "+Math.round(1e3*t)+"ms, rate: "+r+")"),e.player.api.playbackRate=r}else 1!=e.player.api.playbackRate&&(e.player.api.playbackRate=1,e.log("Sync with main video achieved (desync: "+Math.round(1e3*t)+"ms)"))}},i.target),MistUtil.event.addListener(e.video,"seeked",function(){e.player.api.pausedesync=!1})}),i.skin=MistUtil.object.extend({},t.skin,!0),i.skin.structure.main=MistUtil.object.extend({},t.skin.structure.secondaryVideo(r)),mistPlay(t.stream,i),i.target},switchVideo:function(e){var t=document.createElement("div");return t.appendChild(this.skin.icons.build("switchvideo")),MistUtil.event.addListener(t,"click",function(){var t=e.containers.primary,i=e.containers.secondary;function r(e,t){if(e.video.currentTarget==t)return e.video;if(e.secondary)for(var i=0;i300&&(e.style.zoom=1.5),e}},submenu:function(){return this.UI.buildStructure(this.skin.structure.submenu)},hoverWindow:function(e){var t={type:"container",classes:"classes"in e?e.classes:[],children:"children"in e?e.children:[]};switch(t.classes.push("hover_window_container"),"classes"in e.window||(e.window.classes=[]),e.window.classes.push("inner_window"),e.window.classes.push("mistvideo-container"),e.window={type:"container",classes:["outer_window"],children:[e.window]},"classes"in e.button||(e.button.classes=[]),e.button.classes.push("pointer"),e.mode){case"left":t.classes.push("horizontal"),t.children=[e.window,e.button];break;case"right":t.classes.push("horizontal"),t.children=[e.button,e.window];break;case"top":t.classes.push("vertical"),t.children=[e.button,e.window];break;case"bottom":t.classes.push("vertical"),t.children=[e.window,e.button];break;case"pos":t.children=[e.button,e.window],"classes"in e.window||(e.window.classes=[]);break;default:throw"Unsupported mode for structure type hoverWindow"}return"transition"in e&&("css"in t||(t.css=[]),t.css.push(".hover_window_container:hover > .outer_window:not([data-hidecursor]) > .inner_window { "+e.transition.show+" }\n.hover_window_container > .outer_window { "+e.transition.viewport+" }\n.hover_window_container > .outer_window > .inner_window { "+e.transition.hide+" }")),t.classes.push(e.mode),this.UI.buildStructure(t)},draggable:function(e){var t=this.skin.blueprints.container(e),i=this,r=this.skin.icons.build("fullscreen",16);MistUtil.class.remove(r,"fullscreen"),MistUtil.class.add(r,"draggable-icon"),t.appendChild(r),r.style.alignSelf="flex-end",r.style.position="absolute",r.style.cursor="move";var n={},a=function(e){t.style.left=e.clientX-n.x+"px",t.style.top=e.clientY-n.y+"px"},s=function(e){window.removeEventListener("mousemove",a),window.removeEventListener("click",s),MistUtil.event.addListener(r,"click",o)},o=function(e){e.stopPropagation(),r.removeEventListener("click",o),n.x=i.container.getBoundingClientRect().left-(t.getBoundingClientRect().left-e.clientX),n.y=i.container.getBoundingClientRect().top-(t.getBoundingClientRect().top-e.clientY),t.style.position="absolute",t.style.right="auto",t.style.bottom="auto",i.container.appendChild(t),a(e),MistUtil.event.addListener(window,"mousemove",a,t),MistUtil.event.addListener(window,"click",s,t)};return MistUtil.event.addListener(r,"click",o),t},progress:function(){var e=document.createElement("div"),t=document.createElement("div");e.appendChild(t),t.kids={},t.kids.bar=document.createElement("div"),t.kids.bar.className="bar",t.appendChild(t.kids.bar);var i=this.video,r=this,n=1/0;if(r.info&&r.info.meta&&r.info.meta.tracks)for(var a in r.info.meta.tracks).001*r.info.meta.tracks[a].firstms1e3?(t.updateBuffers(r.player.api.buffered),l=(new Date).getTime()):c||(c=r.timers.start(function(){e(),c=!1},1e3))}()},t);var d=0,u=!1;MistUtil.event.addListener(i,"timeupdate",function(){!function e(){(new Date).getTime()-d>200&&!f?(t.updateBar(r.player.api.currentTime),d=(new Date).getTime()):u||(u=r.timers.start(function(){e(),u=!1},1e3))}()},t),MistUtil.event.addListener(i,"seeking",function(){t.updateBar(r.player.api.currentTime)},t),t.getPos=function(e){var t=isNaN(e)?MistUtil.getPos(this,e):e;return"live"==r.info.type?(t-1)*o()+r.player.api.duration:!!isFinite(r.player.api.duration)&&t*(r.player.api.duration-s())+s()},t.seek=function(e){var t=this.getPos(e);r.player.api.currentTime=t},MistUtil.event.addListener(e,"mouseup",function(e){1==e.which&&t.seek(e)});var p=r.UI.buildStructure({type:"tooltip"});p.style.opacity=0,t.appendChild(p),MistUtil.event.addListener(e,"mouseout",function(){f||(p.style.opacity=0)}),t.moveTooltip=function(e){var t=this.getPos(e);if(!1!==t){p.setDisplay(t),p.style.opacity=1;var i=MistUtil.getPos(this,e),r={bottom:20};i>.5?(r.right=100*(1-i)+"%",p.triangle.setMode("bottom","right")):(r.left=100*i+"%",p.triangle.setMode("bottom","left")),p.setPos(r)}else p.style.opacity=0};var h=document.createElement("span");h.setAttribute("class","mistvideo-realtime");var m=document.createTextNode("");h.appendChild(m),p.setDisplay=function(e){if(r.options.useDateTime&&r.info&&r.info.unixoffset){var i=t.getPos(1)-t.getPos(0),n=.001*(new Date).getTime()-(.001*r.info.unixoffset+t.getPos(1)),a=Math.max(i,n),s="";if("live"==r.info.type)if(a<60)s=MistUtil.format.ago(new Date(r.info.unixoffset+1e3*e));else{var o=.001*(new Date).getTime()-(.001*r.info.unixoffset+e);o<172800&&(s+=" - "+MistUtil.format.time(o))}else s+=MistUtil.format.time(e);if(a>=60){m.nodeValue=" at "+MistUtil.format.ago(new Date(r.info.unixoffset+1e3*e),1e3*a);var l=document.createDocumentFragment();l.appendChild(document.createTextNode(s)),l.appendChild(h),p.setHtml(l)}else m.nodeValue="",p.setText(s)}else p.setText(MistUtil.format.time(e))},MistUtil.event.addListener(e,"mousemove",function(e){t.moveTooltip(e)});var f=!1;return MistUtil.event.addListener(e,"mousedown",function(i){if(1==i.which){f=!0,t.updateBar(t.getPos(i));var r=MistUtil.event.addListener(document,"mousemove",function(e){t.updateBar(t.getPos(e)),t.moveTooltip(e)},t),n=MistUtil.event.addListener(document,"mouseup",function(i){1==i.which&&(f=!1,MistUtil.event.removeListener(r),MistUtil.event.removeListener(n),p.style.opacity=0,(!i.path||MistUtil.array.indexOf(i.path,e)<0)&&t.seek(i))},t)}}),e},play:function(){var e=this,t=document.createElement("div");t.appendChild(this.skin.icons.build("play")),t.appendChild(this.skin.icons.build("pause")),t.setState=function(e){this.setAttribute("data-state",e)},t.setState("paused");var i=this.video;return MistUtil.event.addListener(i,"playing",function(){t.setState("playing"),e.options.autoplay=!0},t),MistUtil.event.addListener(i,"pause",function(){t.setState("paused")},t),MistUtil.event.addListener(i,"paused",function(){t.setState("paused")},t),MistUtil.event.addListener(i,"ended",function(){t.setState("paused")},t),MistUtil.event.addListener(t,"click",function(){e.player.api.error&&e.player.api.load(),e.player.api.paused?e.player.api.play():(e.player.api.pause(),e.options.autoplay=!1)}),e.player.api&&MistUtil.event.addListener(e.video,"click",function(){e.player.api.paused?e.player.api.play():MistUtil.isTouchDevice()||(e.player.api.pause(),e.options.autoplay=!1)},t),t},speaker:function(){if(!(this.player.api&&"muted"in this.player.api))return!1;var e=!1,t=this.info.meta.tracks;for(var i in t)if("audio"==t[i].type){e=!0;break}if(!e)return!1;var r=this.skin.icons.build("speaker"),n=this,a=this.video;return n.player.api.volume&&!n.player.api.muted||MistUtil.class.add(r,"off"),MistUtil.event.addListener(a,"volumechange",function(){n.player.api.volume&&!n.player.api.muted?MistUtil.class.remove(r,"off"):MistUtil.class.add(r,"off")},r),MistUtil.event.addListener(r,"click",function(e){n.player.api.muted=!n.player.api.muted}),r},volume:function(e){if(!(this.player.api&&"volume"in this.player.api))return!1;var t=!1,i=this.info.meta.tracks;for(var r in i)if("audio"==i[r].type){t=!0;break}if(!t)return!1;var n=document.createElement("div"),a=this.skin.icons.build("volume","size"in e&&e.size);n.appendChild(a);var s=this;a.mode="mode"in e?e.mode:"vertical","vertical"==a.mode&&(a.style.transform="rotate(90deg)"),a.margin={start:.15,end:.1};var o=this.video;a.set=function(e){100!=(e=100-100*Math.pow(1-e/100,2))&&0!=e&&(e=100*this.addPadding(e/100));for(var t=a.querySelectorAll(".slider"),i=0;i6e4&&e.size.width>=600&&(n.nodeValue=" (at "+MistUtil.format.ago(o)+")")),t.setAttribute("title",MistUtil.format.ago(o,3456e7))}else r=a(s),t.setAttribute("title",r);i.nodeValue=r},t.set(),MistUtil.event.addListener(e.video,"timeupdate",function(){t.set()},t),MistUtil.event.addListener(e.video,"seeking",function(){t.set()},t),t},totalTime:function(){var e=this,t=document.createElement("div"),i=document.createTextNode("");t.appendChild(i);this.player.api;return"live"==e.info.type?(i.nodeValue="live",t.className="live"):(t.set=function(r){if(!isNaN(r)&&isFinite(r))if(this.style.display="",e.options.useDateTime&&e.info&&"live"==e.info.type&&e.info.unixoffset){var n=new Date(1e3*r+e.info.unixoffset);i.nodeValue=MistUtil.format.ago(n),t.setAttribute("title",MistUtil.format.ago(n,3456e7))}else i.nodeValue=MistUtil.format.time(r),t.setAttribute("title",i.nodeValue);else this.style.display="none"},MistUtil.event.addListener(e.video,"durationchange",function(){var i=e.player.api.duration;t.set(i)},t)),t},playername:function(){if(this.playerName&&this.playerName in mistplayers){var e=document.createElement("span");return e.appendChild(document.createTextNode(mistplayers[this.playerName].name)),e}},mimetype:function(){if(this.source){var e=document.createElement("a");return e.href=this.source.url,e.target="_blank",e.title=e.href+" ("+this.source.type+")",e.appendChild(document.createTextNode(MistUtil.format.mime2human(this.source.type))),e}},logo:function(e){if("element"in e)return e.element;if("src"in e){var t=document.createElement("img");return t.src=e.src,t}},settings:function(){var e=this,t=this.skin.icons.build("settings"),i=void 0!==document.ontouchstart;return MistUtil.event.addListener(t,"click",function(){e.container.hasAttribute("data-show-submenu")?(i&&e.container.setAttribute("data-hide-submenu",""),e.container.removeAttribute("data-show-submenu")):(e.container.setAttribute("data-show-submenu",""),e.container.removeAttribute("data-hide-submenu"))}),t},loop:function(){if("loop"in this.player.api&&"live"!=this.info.type){var e=this,t=this.skin.icons.build("loop");this.video;return t.set=function(){e.player.api.loop?MistUtil.class.remove(this,"off"):MistUtil.class.add(this,"off")},MistUtil.event.addListener(t,"click",function(t){e.player.api.loop=!e.player.api.loop,this.set()}),t.set(),t}},fullscreen:function(){if("setSize"in this.player&&this.info.hasVideo&&"audio"!=this.source.type.split("/")[1]){var e=this,t=["requestFullscreen","webkitRequestFullscreen","mozRequestFullScreen","msRequestFullscreen","webkitEnterFullscreen"],i=[function(){return e.container},function(){return e.video}],r=!1;e:for(var n in i)for(var a in t)if(t[a]in i[n]()){(r={}).request=function(){return r.fullscreenableElement()[t[a]]()};var s=["exitFullscreen","webkitCancelFullScreen","mozCancelFullScreen","msExitFullscreen","webkitExitFullscreen"],o=["fullscreenElement","webkitFullscreenElement","mozFullScreenElement","msFullscreenElement","webkitFullscreenElement"];r.cancel=function(){return document[s[a]]()},r.element=function(){return document[o[a]]},r.event=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange","webkitfullscreenchange"][a],r.fullscreenableElement=i[n];break e}if(!r){var l=function(e){switch(e.key){case"Escape":r.cancel()}};(r={event:"fakefullscreenchange",fullscreenableElement:function(){return e.container}}).request=function(){return r.element=function(){return e.container},MistUtil.event.send(r.event,null,document),document.addEventListener("keydown",l),!0},r.cancel=function(){return r.element=function(){return null},document.removeEventListener("keydown",l),MistUtil.event.send(r.event,null,document),!0},r.element=function(){return null}}var c=this.skin.icons.build("fullscreen");return MistUtil.event.addListener(c,"click",d),MistUtil.event.addListener(e.video,"dblclick",d),MistUtil.event.addListener(document,r.event,function(){r.element()==r.fullscreenableElement()?e.container.setAttribute("data-fullscreen",""):e.container.hasAttribute("data-fullscreen")&&e.container.removeAttribute("data-fullscreen"),e.player.resizeAll()},c),c}function d(){r.element()?r.cancel():r.request()}},"picture-in-picture":function(){if("setSize"in this.player&&this.info.hasVideo&&"audio"!=this.source.type.split("/")[1]&&document.pictureInPictureEnabled){var e=this;if("requestPictureInPicture"in e.video){var t=this.skin.icons.build("pip");return t.set=function(){document.pictureInPictureElement?MistUtil.class.remove(this,"off"):MistUtil.class.add(this,"off")},MistUtil.event.addListener(t,"click",function(){var i;(i=document.pictureInPictureElement?document.exitPictureInPicture():e.video.requestPictureInPicture())?i.then(function(){t.set()}):t.set()}),t.set(),t}}},tracks:function(){if(this.info&&this.video){var e=this,t=document.createElement("table");return i(this.info.meta.tracks),MistUtil.event.addListener(e.video,"metaUpdate_tracks",function(e){i(e.message.meta.tracks)},t),t}function i(i){MistUtil.empty(t),i=MistUtil.tracks.parse(i);var r={},n={};function a(t,i){if(i?e.log("User selected "+t+" track with id "+i):(e.log("User selected automatic track selection for "+t),MistUtil.event.send("trackSetToAuto",t,e.video)),e.options.setTracks||(e.options.setTracks={}),e.options.setTracks[t]=i,!0===i&&r[t]&&MistUtil.event.send("change",null,r[t]),"setTrack"in e.player.api)return e.player.api.setTrack(t,i);var n={};for(var a in r)"subtitle"!=a&&""!=r[a].value&&(n[a]=r[a].value);return""!=i&&(n[t]=i),"setTracks"in e.player.api?e.player.api.setTracks(n):"setSource"in e.player.api?e.player.api.setSource(MistUtil.http.url.addParam(e.source.url,n)):void 0}var s=MistUtil.object.keys(i,function(e,t){function i(e){switch(e){case"audio":return"aaaaaaa";case"video":return"aaaaaab";default:return e}}return i(e)>i(t)?1:i(e)1&&"player"in e&&"api"in e.player&&("setTrack"in e.player.api||"setTracks"in e.player.api||"setSource"in e.player.api)){var b=document.createElement("select");if(b.title="Select another "+l+" track",r[l]=b,b.trackType=l,f.appendChild(b),"subtitle"!=l){var k=document.createElement("option");b.appendChild(k),k.value="",k.appendChild(document.createTextNode("Automatic"))}var M=S(c[MistUtil.object.keys(c)[0]].same);if(M.length)(x=document.createElement("span")).className="mistvideo-description",f.appendChild(x),f.appendChild(document.createTextNode(M.join(" ")));function w(e){return""==e?-1:Number(e)}var U=MistUtil.object.keys(c,function(e,t){return w(e)-w(t)});for(var p in U){var C=c[U[p]];k=document.createElement("option");b.appendChild(k),k.value="idx"in C?C.idx:C.trackid,MistUtil.object.keys(C.different).length?k.appendChild(document.createTextNode(S(C.different).join(" "))):k.appendChild(document.createTextNode("Track "+(Number(p)+1)))}if(MistUtil.event.addListener(e.video,"playerUpdate_trackChanged",function(t){t.message.type==l&&"none"!=t.message.trackid&&(b.value=t.message.trackid,e.log("Player selected "+l+" track with id "+t.message.trackid))},b),"subtitle"==l){if(MistUtil.event.addListener(b,"change",function(){try{localStorage.mistSubtitleLanguage=c[this.value].lang}catch(e){}if("setWSSubtitle"in e.player.api)e.player.api.setWSSubtitle(""==this.value?void 0:this.value);else if(""!=this.value){var t=MistUtil.object.extend({},c[this.value]);t.label=S(t.describe).join(" "),t.src=MistUtil.http.url.addParam(u,{track:this.value}),e.player.api.setSubtitle(t)}else e.player.api.setSubtitle()}),"localStorage"in window&&null!=localStorage&&"mistSubtitleLanguage"in localStorage)for(var p in c)if(c[p].lang==localStorage.mistSubtitleLanguage){b.value=p;var T=document.createEvent("Event");T.initEvent("change"),b.dispatchEvent(T);break}}else MistUtil.event.addListener(b,"change",function(){this.trackType in n&&(n[this.trackType].checked=!0),a(this.trackType,this.value)})}else{var x;(x=document.createElement("span")).className="mistvideo-description",f.appendChild(x),x.appendChild(document.createTextNode(S(c[g[0]].same).join(" ")))}}function S(e){var t={trackid:0,language:1,width:2,bps:3,fpks:4,channels:5,codec:6,rate:7};return MistUtil.object.values(e,function(e,i,r,n){return t[e]>t[i]?1:t[e]=.999?n():t()},1e3))}()}function n(){e.container.removeAttribute("data-loading"),i&&e.timers.stop(i),i=!1}var a=["waiting","seeking","stalled"];for(var s in a)MistUtil.event.addListener(e.video,a[s],function(t){e.player.api&&!e.player.api.paused&&"container"in e&&r(t)},t);a=["seeked","playing","canplay","paused","ended"];for(var s in a)MistUtil.event.addListener(e.video,a[s],function(t){"container"in e&&n()},t);MistUtil.event.addListener(e.video,"progress",function(t){"container"in e&&"monitor"in e&&"vars"in e.monitor&&"score"in e.monitor.vars&&e.monitor.vars.score>.99&&n()},t)}return t},error:function(){var e=this,t=document.createElement("div");t.message=function(t,i,r){MistUtil.empty(this);var n=document.createElement("div");if(n.className="message",this.appendChild(n),!r.polling&&!r.passive&&!r.hideTitle){var a=document.createElement("h3");n.appendChild(a),a.appendChild(document.createTextNode("The "+(e.casting?"chromecast":"player")+" has encountered a problem"))}var s=document.createElement("p");if(n.appendChild(s),n.update=function(e){MistUtil.empty(s),s.innerHTML=e},t){e.info.on_error&&(t=e.info.on_error.replace(/\/,t)),n.update(t);var o=document.createElement("p");if(o.className="details mistvideo-description",n.appendChild(o),i)o.appendChild(document.createTextNode(i));else if("decodingIssues"in e.skin.blueprints){if("player"in e&&"api"in e.player&&e.video){if(i=[],void 0!==e.state&&i.push(["Stream state:",e.state]),void 0!==e.player.api.currentTime&&i.push(["Current video time:",MistUtil.format.time(e.player.api.currentTime)]),"video"in e&&"getVideoPlaybackQuality"in e.video){var l=e.video.getVideoPlaybackQuality();"droppedVideoFrames"in l&&"totalVideoFrames"in l&&l.totalVideoFrames&&i.push(["Frames dropped/total:",MistUtil.format.number(l.droppedVideoFrames)+"/"+MistUtil.format.number(l.totalVideoFrames)]),"corruptedVideoFrames"in l&&l.corruptedVideoFrames&&i.push(["Corrupted frames:",MistUtil.format.number(l.corruptedVideoFrames)])}i.push({0:["NETWORK EMPTY:","not yet initialized"],1:["NETWORK IDLE:","resource selected, but not in use"],2:["NETWORK LOADING:","data is being downloaded"],3:["NETWORK NO SOURCE:","could not locate source"]}[e.video.networkState]);if(i.push({0:["HAVE NOTHING:","no information about ready state"],1:["HAVE METADATA:","metadata has been loaded"],2:["HAVE CURRENT DATA:","data for the current playback position is available, but not for the next frame"],3:["HAVE FUTURE DATA:","data for current and next frame is available"],4:["HAVE ENOUGH DATA:","can start playing"]}[e.video.readyState]),!r.passive){var c=document.createElement("table");for(var d in i){var u=document.createElement("tr");for(var p in c.appendChild(u),i[d]){var h=document.createElement("td");u.appendChild(h),h.appendChild(document.createTextNode(i[d][p]))}}o.appendChild(c)}}var m,f=document.createElement("div");f.className="mistvideo-container mistvideo-column",f.style.textAlign="left",f.style.marginBottom="1em",n.appendChild(f),(m=e.UI.buildStructure({type:"forcePlayer"}))&&f.appendChild(m),(m=e.UI.buildStructure({type:"forceType"}))&&f.appendChild(m)}}return n};var i,r=!1,n=!1,a={};if(this.showError=function(s,o){o||(o={softReload:!!(e.player&&e.player.api&&e.player.api.load),reload:!0,nextCombo:!!e.info,polling:!1,passive:!1});var l=o.type?o.type:s;if(!(l in a)){if(!0===o.reload&&(e.options.reloadDelay&&!isNaN(Number(e.options.reloadDelay))?o.reload=Number(e.options.reloadDelay):o.reload=10),o.passive){if(!0===r)return;if(r)return i.update(s),void(n=(new Date).getTime());t.setAttribute("data-passive","")}else t.removeAttribute("data-passive");var c;r&&t.clear(),r=!o.passive||"passive",n=(new Date).getTime(),e.casting||(c=this.log(s,"error"));var d=t.message(s,!1,o);i=d;var u=document.createElement("div");if(u.className="mistvideo-buttoncontainer",d.appendChild(u),MistUtil.empty(u),e.casting&&!o.passive){var p={type:"button",label:"Stop casting",onclick:function(){e.detachFromCast()}};isNaN(o.softReload+"")||(p.delay=o.softReload),u.appendChild(e.UI.buildStructure(p))}if(o.softReload&&!e.casting){p={type:"button",label:"Reload video",onclick:function(){e.player.api.load()}};isNaN(o.softReload+"")||(p.delay=o.softReload),u.appendChild(e.UI.buildStructure(p))}if(o.reload){p={type:"button",label:"Reload player",onclick:function(){e.reload("Reloading because reload button was clicked.")}};isNaN(o.reload+"")||(p.delay=o.reload),u.appendChild(e.UI.buildStructure(p))}if(o.nextCombo){p={type:"button",label:"Next source",onclick:function(){e.nextCombo()}};isNaN(o.nextCombo+"")||(p.delay=o.nextCombo),u.appendChild(e.UI.buildStructure(p))}if(o.ignore){p={type:"button",label:"Ignore",onclick:function(){this.clearError(),a[l]=!0}};isNaN(o.ignore+"")||(p.delay=o.ignore),u.appendChild(e.UI.buildStructure(p))}o.polling&&u.appendChild(e.UI.buildStructure({type:"polling"})),MistUtil.class.add(t,"show"),"container"in e&&e.container.removeAttribute("data-loading"),c&&c.defaultPrevented&&(e.log("Error event was defaultPrevented, not showing."),t.clear())}},t.clear=function(){for(var i=t.querySelectorAll("svg.icon.timeout"),n=0;n=0;e--)r.removeChild(r.children[e])},e.setHtml=function(n){r.empty(),r.appendChild(n),"html"!=t&&(e.removeChild(i),e.appendChild(r),t="html")};var n=document.createElement("div");return e.triangle=n,n.className="triangle",e.appendChild(n),n.setMode=function(e,t){e||(e="bottom"),t||(t="left");var i=["bottom","top","right","left"];for(var r in i){this.style[i[r]]="";var n=MistUtil.format.ucFirst(i[r]);this.style["border"+n]="",this.style["border"+n+"Color"]=""}var a={top:"bottom",bottom:"top",left:"right",right:"left"};this.style[e]="-10px",this.style["border"+MistUtil.format.ucFirst(a[e])]="none",this.style["border"+MistUtil.format.ucFirst(e)+"Color"]="transparent",this.style[t]=0,this.style["border"+MistUtil.format.ucFirst(a[t])]="none"},e.setPos=function(e){var t={left:"auto",right:"auto",top:"auto",bottom:"auto"};for(var i in MistUtil.object.extend(t,e),t)isNaN(t[i])||(t[i]+="px"),this.style[i]=t[i]},e},button:function(e){var t=document.createElement("button"),i=this;if(e.onclick&&(MistUtil.event.addListener(t,"click",function(){e.onclick.call(i,arguments)}),e.delay)){var r=this.UI.buildStructure({type:"timeout",delay:e.delay,function:e.onclick});r&&t.appendChild(r)}return t.appendChild(document.createTextNode(e.label)),t},videobackground:function(e){e||(e={}),e.delay||(e.delay=5);for(var t=document.createElement("div"),i=this,r=[],n=0;n<2;n++){var a=document.createElement("canvas");a._context=a.getContext("2d"),t.appendChild(a),r.push(a)}var s=0,o=!1;return MistUtil.event.addListener(i.video,"playing",function(){o||(!function n(){if(e.alwaysDisplay||i.video.videoWidth/i.video.videoHeight!=t.clientWidth/t.clientHeight){r[s].removeAttribute("data-front"),++s>=r.length&&(s=0);var a=r[s],l=a._context;a.width=i.video.videoWidth,a.height=i.video.videoHeight,l.drawImage(i.video,0,0),a.setAttribute("data-front","")}i.player.api.paused?o=!1:i.timers.start(function(){n()},1e3*e.delay)}(),o=!0)}),t},subtitles:function(e){if(!("WebSocket"in window))return!1;var t=this;if(!("player"in t&&"api"in t.player&&"currentTime"in t.player.api))return!1;if(!("metaTrackSubscriptions"in t))return!1;var i=document.createElement("div"),r=document.createElement("span");i.appendChild(r);var n=document.createTextNode("");r.appendChild(n);var a=!1;function s(e){n.nodeValue=e.data.replace(/\<\/?[bui]\>/gi,"").replace(/{\/?[bui]}/gi,"").replace(/{\\a\d+}/gi,"").replace(/\<\/?font[^>]*?\>/gi,""),a&&(t.timers.stop(a),a=null),function i(r){a=t.timers.start(function(){if(t.player.api.paused)var r=MistUtil.event.addListener(t.video,"playing",function(){i(e.time+("duration"in e?e.duration:5e3)-1e3*t.player.api.currentTime),MistUtil.event.removeListener(r)});else n.nodeValue=""},r)}("duration"in e?e.duration:5e3)}if(MistUtil.event.addListener(t.video,"seeked",function(){n.nodeValue="",a&&t.timers.stop(a),a=null}),!("setWSSubtitle"in t.player.api)){var o=!1;t.player.api.setWSSubtitle=function(e){e!=o&&(void 0!==e&&t.metaTrackSubscriptions.add(e,s),e!=o&&t.metaTrackSubscriptions.remove(o,s),o="undefined"!=e&&e)}}return i},chromecast:function(){var e=this;if(!(!"".indexOf||e.options.host.indexOf("localhost")>-1||e.options.host.indexOf("::1")>-1)){var t,i,r,n,a=document.createElement("div"),s=document.createElement("div");s.className="mistvideo-casting";var o={},l={currentTime:!1,paused:!0,volume:1,muted:!1,buffer:[],loop:e.player.api?e.player.api.loop:e.options.loop};if(e.casting=!1,window.chrome&&window.chrome.cast||window.loadedCastApi)"loading"==window.loadedCastApi?(e.log("Not appending chromecast script - still loading"),e.timers.start(function(){d()},200)):(e.log("Not appending chromecast script - already loaded"),d());else{window.__onGCastApiAvailable=function(t,i){t||e.log("Error while loading chromecast API: "+i),d()},window.loadedCastApi="loading";var c=document.createElement("script");c.setAttribute("src","//www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"),document.head.appendChild(c),e.log("Appending chromecast script")}return a}function d(c){if(!window.chrome||!window.chrome.cast||!window.chrome.cast.isAvailable||c>5)return a.parentNode&&a.parentNode.removeChild(a),e.log("Chromecast is not supported"),void console.warn(chrome,chrome.cast,chrome.cast?chrome.cast.isAvailable:void 0,cast);if(!window.cast)return c||(c=0),e.log("Casting api loaded but cast function not yet available, retrying.."),void e.timers.start(function(){d(c++)},200);e.log("Chromecast API loaded"),window.loadedCastApi&&"loading"!=window.loadedCastApi||(window.loadedCastApi=!0);var u=document.createElement("google-cast-launcher");function p(a){MistUtil.class.remove(u,"active"),MistUtil.class.remove(e.container,"casting"),s.parentNode&&s.parentNode.removeChild(s),!a&&cast.framework.CastContext.getInstance().getCurrentSession()&&cast.framework.CastContext.getInstance().getCurrentSession().endSession(!0),t?(e.player.api=t,t.currentTime=l.currentTime,t.play(),e.reload=i,e.nextCombo=r,e.unload=n):e.player.api.play(),e.player.api&&e.player.api.setTracks&&MistUtil.object.keys(o).length&&e.player.api.setTracks(o),e.casting=!1,e.log("Detached chromecast session")}a.appendChild(u),cast.framework.CastContext.getInstance().setOptions({receiverApplicationId:"E5F1558C",autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),e.detachFromCast=p,u.addEventListener("click",function(a){if(a.stopPropagation(),MistUtil.class.has(u,"active"))p();else{function c(){cast.framework.CastContext.getInstance().getCurrentSession().addMessageListener("urn:x-cast:mistcaster",function(t,i){if(e.destroyed&&p(),(i=JSON.parse(i)).type)switch(i.type){case"log":case"error":e.log("[Chromecast] "+i.message,i.type);break;case"showError":e.showError.apply(e,i.args);break;case"event":switch(i.event){case"timeupdate":l.currentTime=i.currentTime,MistUtil.event.send(i.event,"chromecast",e.video);break;case"progress":l.buffer=i.buffer,MistUtil.event.send(i.event,"chromecast",e.video);break;case"pause":case"paused":case"ended":case"play":case"playing":l.paused=i.paused,MistUtil.event.send(i.event,"chromecast",e.video);break;case"volumechange":l.volume=i.volume,l.muted=i.muted,MistUtil.event.send(i.event,"chromecast",e.video);break;default:MistUtil.event.send(i.event,"chromecast",e.video)}break;case"detach":i.n==e.n&&p(!0);break;default:console.log("Unknown chromecast message type",i)}});var a={type:"load",n:e.n,options:{host:e.options.host,loop:e.options.loop,poster:e.options.poster,streaminfo:e.options.streaminfo,urlappend:e.options.urlappend,forcePriority:e.options.forcePriority,setTracks:e.options.setTracks,controls:!1,skin:"default"},stream:e.stream};e.info&&"live"!=e.info.type&&(a.time=e.player.api.currentTime),"dev"==e.options.skin&&(a.options.skin=e.options.skin),e.player&&e.player.api&&(a.volume=e.player.api.volume,a.muted=e.player.api.muted,a.options.loop=e.player.api.loop),MistCast.send(a),t=e.player.api,i=e.reload,r=e.nextCombo,n=e.unload,o=e.options.setTracks?e.options.setTracks:{},e.player.api=new Proxy(t,{get:function(e,t,i){var r=e[t];switch(t){case"muted":case"volume":case"currentTime":case"paused":case"loop":return l[t];case"buffered":return new function(){this.length=l.buffer.length,this.start=function(e){return l.buffer[e][0]},this.end=function(e){return l.buffer[e][1]}};case"setTracks":case"play":case"pause":return function(){for(var e=[],i=0;i=t.scrollHeight-5}),r.logs)o(r.logs[l].time,r.logs[l].message,r.logs[l].data);return MistUtil.event.addListener(r.options.target,"log",function(e){if(e.message){var t={};r.player&&r.player.api&&"currentTime"in r.player.api&&(t.currentTime=r.player.api.currentTime),o(new Date,e.message,t)}},e),MistUtil.event.addListener(r.options.target,"error",function(e){if(e.message){var t={type:"error"};r.player&&r.player.api&&"currentTime"in r.player.api&&(t.currentTime=r.player.api.currentTime),o(new Date,e.message,t)}},e),e},decodingIssues:function(){if(this.player){var e=this,t=document.createElement("div");if(e.player.api){var i={"Playback score":function(){if("monitor"in e){if("vars"in e.monitor&&"score"in e.monitor.vars&&e.monitor.vars.values.length){var t=e.monitor.vars.values[e.monitor.vars.values.length-1];if("score"in t){Math.min(1,Math.max(0,t.score));return{x:t.clock,y:Math.min(1,Math.max(0,t.score)),options:{y:{min:0,max:1},x:{count:10}},val:Math.round(100*Math.min(1,Math.max(0,e.monitor.vars.score)))+"%"}}}return 0}},"Corrupted frames":function(){if(e.player.api&&"getVideoPlaybackQuality"in e.player.api){var t=e.player.api.getVideoPlaybackQuality();if(t)return t.corruptedVideoFrames?{val:MistUtil.format.number(t.corruptedVideoFrames),x:.001*(new Date).getTime(),y:t.corruptedVideoFrames,options:{x:{count:10}}}:0}},"Dropped frames":function(){if(e.player.api){if("getVideoPlaybackQuality"in e.player.api){var t=e.player.api.getVideoPlaybackQuality();if(t)return t.droppedVideoFrames?MistUtil.format.number(t.droppedVideoFrames):0}if("webkitDroppedFrameCount"in e.player.api)return e.player.api.webkitDroppedFrameCount}},"Total frames":function(){if(e.player.api&&"getVideoPlaybackQuality"in e.player.api){var t=e.player.api.getVideoPlaybackQuality();if(t)return MistUtil.format.number(t.totalVideoFrames)}},"Decoded audio":function(){if(e.player.api)return MistUtil.format.bytes(e.player.api.webkitAudioDecodedByteCount)},"Decoded video":function(){if(e.player.api)return MistUtil.format.bytes(e.player.api.webkitVideoDecodedByteCount)},"Negative acknowledgements":function(){if(e.player.api)return MistUtil.format.number(e.player.api.nackCount)},"Picture losses":function(){return MistUtil.format.number(e.player.api.pliCount)},"Packets lost":function(){return MistUtil.format.number(e.player.api.packetsLost)},"Packets received":function(){return MistUtil.format.number(e.player.api.packetsReceived)},"Bytes received":function(){if(e.player.api)return MistUtil.format.bytes(e.player.api.bytesReceived)},"Local latency [ms]":function(){if(e.player.api&&"getLatency"in e.player.api){var t=e.player.api.getLatency();return t?new Promise(function(e,i){t.then(function(t){var i=[];for(var r in t)t[r]&&i.push(r[0]+":"+Math.round(1e3*t[r]));i.length?e(i.join(" ")):e()},i)}):new Promise(function(e,t){e()},function(){})}},"Current bitrate":function(){var t;return e.player.monitor&&"currentBps"in e.player.monitor?(t=MistUtil.format.bits(e.player.monitor.currentBps))?t+"ps":t:e.player.api&&"currentBps"in e.player.api?(t=MistUtil.format.bits(e.player.api.currentBps()))?t+"ps":t:void 0},"Framerate in":function(){if(e.player.api&&"framerate_in"in e.player.api)return MistUtil.format.number(e.player.api.framerate_in())},"Framerate out":function(){if(e.player.api&&"framerate_out"in e.player.api)return MistUtil.format.number(e.player.api.framerate_out())}},r=[];for(var n in i)void 0!==i[n]()&&a({name:n,function:i[n]});t.update=function(){for(var i in r)r[i]();e.timers.start(function(){t.update()},1e3)},t.update()}return t}function a(e){var i=document.createElement("label");t.appendChild(i),i.style.display="none";var n=document.createElement("span");i.appendChild(n),n.appendChild(document.createTextNode(e.name+":")),n.className="mistvideo-description";var a=document.createElement("span");i.appendChild(a);var s=document.createTextNode(e.value?e.value:"");a.appendChild(s);var o=document.createElement("span");a.appendChild(o),i.set=function(e){if(0!==e&&(this.style.display=""),"object"==typeof e){try{if(e instanceof Promise)return void e.then(function(e){i.set(e)},function(){})}catch(e){}if("val"in e&&(s.nodeValue=e.val,a.className="value"),o.children.length)return(t=o.children[0]).addData(e);var t=MistUtil.createGraph({x:[e.x],y:[e.y]},e.options);return o.style.display="",MistUtil.empty(o),o.appendChild(t)}return s.nodeValue=e},t.appendChild(i),r.push(function(){var t=e.function();i.set(t)})}},forcePlayer:function(){var e=document.createElement("label");e.title="Reload MistVideo and use the selected player";var t=this,i=document.createElement("span");e.appendChild(i),i.appendChild(document.createTextNode("Force player: "));var r=document.createElement("select");e.appendChild(r);var n=document.createElement("option");for(var a in r.appendChild(n),n.value="",n.appendChild(document.createTextNode("Automatic")),mistplayers){n=document.createElement("option");r.appendChild(n),n.value=a,n.appendChild(document.createTextNode(mistplayers[a].name))}return this.options.forcePlayer&&(r.value=this.options.forcePlayer),MistUtil.event.addListener(r,"change",function(){t.options.forcePlayer=""!=this.value&&this.value,t.options.forcePlayer!=t.playerName&&t.reload("Reloading to force player.")}),e},forceType:function(){if(this.info){var e=document.createElement("label");e.title="Reload MistVideo and use the selected protocol";var t=this,i=document.createElement("span");e.appendChild(i),i.appendChild(document.createTextNode("Force protocol: "));var r=document.createElement("select");e.appendChild(r);var n=document.createElement("option");r.appendChild(n),n.value="",n.appendChild(document.createTextNode("Automatic"));var a={};for(var s in t.info.source){var o=t.info.source[s];if(!(o.type in a)){a[o.type]=1;n=document.createElement("option");r.appendChild(n),n.value=o.type,n.appendChild(document.createTextNode(MistUtil.format.mime2human(o.type)))}}return this.options.forceType&&(r.value=this.options.forceType),MistUtil.event.addListener(r,"change",function(){t.options.forceType=""!=this.value&&this.value,t.source&&t.options.forceType==t.source.type||t.reload("Reloading to force new type.")}),e}},forceSource:function(){var e=document.createElement("label");e.title="Reload MistVideo and use the selected source";var t=this,i=document.createElement("span");e.appendChild(i),i.appendChild(document.createTextNode("Force source: "));var r=document.createElement("select");e.appendChild(r);var n=document.createElement("option");for(var a in r.appendChild(n),n.value="",n.appendChild(document.createTextNode("Automatic")),t.info.source){var s=t.info.source[a];n=document.createElement("option");r.appendChild(n),n.value=a,n.appendChild(document.createTextNode(s.url+" ("+MistUtil.format.mime2human(s.type)+")"))}return this.options.forceSource&&(r.value=this.options.forceSource),MistUtil.event.addListener(r,"change",function(){t.options.forceSource=""!=this.value&&this.value,t.options.forceSource!=t.source.index&&t.reload("Reloading to force new source.")}),e}}},MistSkins.dev.css={skin:misthost+"/skins/dev.css"},MistSkins.dev.structure.submenu=MistUtil.object.extend({},MistSkins.default.structure.submenu,!0),MistSkins.dev.structure.submenu.type="draggable",MistSkins.dev.structure.submenu.style.width="25em",MistSkins.dev.structure.submenu.children.unshift({type:"container",style:{flexShrink:1},classes:["mistvideo-column"],children:[{if:function(){return this.playerName&&this.source},then:{type:"container",classes:["mistvideo-description","mistvideo-displayCombo"],style:{display:"block"},children:[{type:"playername",style:{display:"inline"}},{type:"text",text:"is playing",style:{margin:"0 0.2em"}},{type:"mimetype"}]}},{type:"log"},{type:"decodingIssues"},{type:"container",classes:["mistvideo-column","mistvideo-devcontrols"],style:{"font-size":"0.9em"},children:[{type:"text",text:"Player control"},{type:"container",classes:["mistvideo-devbuttons"],style:{"flex-wrap":"wrap"},children:[{type:"button",title:"Build MistVideo again",label:"MistVideo.reload();",onclick:function(){this.reload("Dev-reload button clicked.")}},{type:"button",title:"Switch to the next available player and source combination",label:"MistVideo.nextCombo();",onclick:function(){this.nextCombo()}}]},{type:"forcePlayer"},{type:"forceType"}]}]});var mistplayers={};function MistPlayer(){}function mistPlay(e,t){return new MistVideo(e,t)}function MistVideo(e,t){var i=this;function r(e){if("meta"in e&&"tracks"in e.meta){var t=e.meta.tracks;for(var i in t)if("video"==t[i].type)return!0}return!1}function n(e){if(i.player&&i.player.api&&i.player.api.unload&&(i.log("Received new stream info while a player was already loaded: unloading player"),i.player.api.unload()),i.info=e,i.info.updated=new Date,MistUtil.event.send("haveStreamInfo",e,i.options.target),i.log("Stream info was loaded succesfully."),"error"in e){var n=e.error;return"on_error"in e?(i.log(n),n=e.on_error):"perc"in e&&(n+=" ("+Math.round(10*e.perc)/10+"%)"),void i.showError(n,{reload:!0,hideTitle:!0})}if(i.calcSize=function(e){e||(e={width:!1,height:!1});var r=e.width||!!("width"in t&&t.width)&&t.width,n=e.height||!!("height"in t&&t.height)&&t.height;if(this.info&&"source"in this.info)if(this.info.hasVideo&&"audio"!=this.source.type.split("/")[1]){if(!r||!n){var a=i.info.width/i.info.height;if(r||n)r?n=r/a:r=n*a;else{var s="maxwidth"in t&&t.maxwidth?t.maxwidth:window.innerWidth,o="maxheight"in t&&t.maxheight?t.maxheight:window.innerHeight;r=i.info.width,n=i.info.height;function l(e){r/=e,n/=e}r<426&&l(r/426),n<240&&l(n/240),s&&r>s&&l(r/s),o&&n>o&&l(n/o)}}}else r||(r=480),n||(n=42);else r=640,n=480;return this.size={width:Math.round(r),height:Math.round(n)},this.size},e.hasVideo=r(e),"live"==e.type){var a=0;for(var s in i.info.meta.tracks)a=Math.max(a,i.info.meta.tracks[s].lastms);e.lastms=a}else{var o=i.resumeTime;if(o){var l=function(){i.player&&i.player.api&&(i.player.api.currentTime=o),this.removeEventListener("initialized",l)};MistUtil.event.addListener(i.options.target,"initialized",l)}}i.options.ABR_bitrate&&i.options.ABR_resize&&i.info&&!i.info.selver&&(i.options.ABR_bitrate=!1),i.choosePlayer()?(i.reporting&&i.reporting.report({player:i.playerName,sourceType:i.source.type,sourceUrl:i.source.url,pageUrl:location.href}),i.player=new mistplayers[i.playerName].player,i.player.onreadylist=[],i.player.onready=function(e){this.onreadylist.push(e)},i.player.build(i,function(e){if(i.log("Building new player"),i.container.removeAttribute("data-loading"),i.video=e,i.reporting&&i.reporting.init(),"api"in i.player){i.monitor={MistVideo:i,delay:1,averagingSteps:20,threshold:function(){return"webrtc"==this.MistVideo.source.type?.95:.75},init:function(){if(!this.vars||!this.vars.active){this.MistVideo.log("Enabling monitor"),this.vars={values:[],score:!1,active:!0};var e=this;!function t(){e.vars&&e.vars.active&&(e.vars.timer=e.MistVideo.timers.start(function(){var i=e.calcScore();!1!==i&&e.check(i)&&e.action(),t()},1e3*e.delay))}()}},destroy:function(){this.vars&&this.vars.active&&(this.MistVideo.log("Disabling monitor"),this.MistVideo.timers.stop(this.vars.timer),delete this.vars)},reset:function(){this.vars&&this.vars.active?(this.MistVideo.log("Resetting monitor"),this.vars.values=[]):this.init()},calcScore:function(){var e=this.vars.values;if(e.push(this.getValue()),e.length<=1)return!1;var t=this.valueToScore(e[0],e[e.length-1]);return e.length>this.averagingSteps&&e.shift(),t=Math.max(t,e[e.length-1].score),this.vars.score=t,i.reporting&&i.reporting.stats.set("playbackScore",Math.round(10*t)/10),t},valueToScore:function(e,t){var i=1;return"player"in this.MistVideo&&"api"in this.MistVideo.player&&"playbackRate"in this.MistVideo.player.api&&(i=this.MistVideo.player.api.playbackRate),(t.video-e.video)/(t.clock-e.clock)/i},getValue:function(){var e={clock:.001*(new Date).getTime(),video:this.MistVideo.player.api.currentTime};return this.vars.values.length&&(e.score=this.valueToScore(this.vars.values[this.vars.values.length-1],e)),e},check:function(e){return!(this.vars.values.length<.5*this.averagingSteps)&&(e=e.socket.CLOSING&&e.init(),this.send_queue.push(t)};var t=!1;if(e.socket.setTracks=function(){e.s({type:"tracks",meta:MistUtil.object.keys(e.subscriptions).join(",")})},e.socket.onopen=function(){for(i.log("Metadata socket opened"),e.socket.setTracks(),1!=i.player.api.playbackRate&&e.s({type:"set_speed",play_rate:i.player.api.playbackRate}),e.s({type:"seek",seek_time:Math.round(1e3*i.player.api.currentTime),ff_to:Math.round(1e3*(i.player.api.currentTime+5))}),e.socket.addEventListener("message",function(r){if(r.data){var n=JSON.parse(r.data);if(n){if("time"in n&&"track"in n&&"data"in n){var a=!1;if("all"in e.subscriptions&&(e.subscriptions.all.buffer.push(n),a=!0),n.track in e.subscriptions&&(e.subscriptions[n.track].buffer.push(n),a=!0),a)if(e.checktimer){var s=i.timers.list[e.checktimer];if(s)s>(new Date).getTime()+n.time-1e3*i.player.api.currentTime&&(i.log("The metadata socket received a message that should be displayed sooner than the current check time; resetting"),i.timers.stop(e.checktimer),e.checktimer=null,e.check())}else e.check()}if("type"in n)switch(n.type){case"on_time":!t&&n.data.current>1e3*(i.player.api.currentTime+30)&&(t=!0,e.s({type:"hold"}),i.log("Pausing metadata buffer because it is very far ahead, checking again in 5 seconds: "+n.data.current+" > "+1e3*i.player.api.currentTime),i.timers.start(function(){i.player.api.paused||e.s({type:"play"}),e.s({type:"fast_forward",ff_to:Math.round(1e3*(i.player.api.currentTime+5))})},5e3));break;case"seek":for(var o in e.subscriptions)e.subscriptions[o].buffer=[];i.log("Cleared metadata buffer after completed seek"),e.checktimer&&(i.timers.stop(e.checktimer),e.checktimer=null)}}else i.log("Subtitle websocket received invalid message.")}else i.log("Subtitle websocket received empty message.")}),e.socket.onclose=function(){i.log("Metadata socket closed")};e.send_queue.length&&e.socket.readyState==e.socket.OPEN;)e.s(e.send_queue.shift())},!("seeked"in this.listeners)){var r=(new Date).getTime();e.check=function(){if(e.checktimer&&(i.timers.stop(e.checktimer),e.checktimer=null),!i.player.api.paused){var t=null;for(var n in e.subscriptions){for(var a=e.subscriptions[n].buffer;a.length&&a[0].time<=1e3*i.player.api.currentTime;){var s=a.shift();if(!(s.time<1e3*(i.player.api.currentTime-5)))for(var o in e.subscriptions[n].callbacks)e.subscriptions[n].callbacks[o].call(i,s)}a.length&&(t=Math.min(null===t?1e9:t,a[0].time))}var l=(new Date).getTime();if(l>r+5e3&&(e.s({type:"fast_forward",ff_to:Math.round(1e3*(i.player.api.currentTime+5))}),r=l),t){var c=t-1e3*i.player.api.currentTime;e.checktimer=i.timers.start(function(){e.check()},c)}}},this.listeners.seeked=MistUtil.event.addListener(i.video,"seeked",function(){for(var t in e.subscriptions)e.subscriptions[t].buffer=[];e.s({type:"seek",seek_time:Math.round(1e3*i.player.api.currentTime),ff_to:Math.round(1e3*(i.player.api.currentTime+5))}),r=(new Date).getTime()}),this.listeners.pause=MistUtil.event.addListener(i.video,"pause",function(){e.s({type:"hold"}),i.timers.stop(e.checktimer),e.checktimer=null}),this.listeners.playing=MistUtil.event.addListener(i.video,"playing",function(){e.s({type:"play"}),e.checktimer||e.check()}),this.listeners.ratechange=MistUtil.event.addListener(i.video,"ratechange",function(){e.s({type:"set_speed",play_rate:i.player.api.playbackRate})})}e.socket.readyState==e.socket.OPEN&&e.socket.onopen()},destroy:function(){for(var e in i.log("Closing metadata socket.."),this.socket.close(),this.socket=null,this.subscriptions={},this.listeners)MistUtil.event.removeListener(this.listeners[e]);this.listeners={}},add:function(e,t){"function"!=typeof e||t||(t=e,e="all"),"function"==typeof t&&(e in this.subscriptions||(this.subscriptions[e]={buffer:[],callbacks:[]}),this.subscriptions[e].callbacks.push(t),null===this.socket?this.init():this.socket.setTracks())},remove:function(e,t){if(e in this.subscriptions){for(var i in this.subscriptions[e].callbacks)if(t==this.subscriptions[e].callbacks[i]){this.subscriptions[e].callbacks.splice(i,1);break}0==this.subscriptions[e].callbacks.length&&(delete this.subscriptions[e],MistUtil.object.keys(this.subscriptions).length?this.socket.setTracks():this.destroy())}}},"function"==typeof t.subscribeToMetaTrack&&(t.subscribeToMetaTrack=[["all",t.subscribeToMetaTrack]]),t.subscribeToMetaTrack.length))for(var n in"object"!=typeof t.subscribeToMetaTrack[0]&&(t.subscribeToMetaTrack=[t.subscribeToMetaTrack]),t.subscribeToMetaTrack)i.metaTrackSubscriptions.add.apply(i.metaTrackSubscriptions,t.subscribeToMetaTrack[n])}}MistUtil.empty(i.options.target),new MistSkin(i),i.container=new MistUI(i),i.options.target.appendChild(i.container),i.container.setAttribute("data-loading",""),i.video.p=i.player;r=["abort","canplay","canplaythrough",,"emptied","ended","loadeddata","loadedmetadata","loadstart","pause","play","playing","ratechange","seeked","seeking","stalled","volumechange","waiting","metaUpdate_tracks","resizing"];for(var n in r)MistUtil.event.addListener(i.video,r[n],function(e){e.message&&"chromecast"==e.message||i.log("Player event fired: "+e.type)});if(MistUtil.event.addListener(i.video,"error",function(e){var t;if("player"in i&&"api"in i.player&&"error"in i.player.api&&i.player.api.error)if("message"in i.player.api.error)t=i.player.api.error.message;else if("code"in i.player.api.error&&i.player.api.error instanceof MediaError){var r={1:"MEDIA_ERR_ABORTED: The fetching of the associated resource was aborted by the user's request.",2:"MEDIA_ERR_NETWORK: Some kind of network error occurred which prevented the media from being successfully fetched, despite having previously been available.",3:"MEDIA_ERR_DECODE: Despite having previously been determined to be usable, an error occurred while trying to decode the media resource, resulting in an error.",4:"MEDIA_ERR_SRC_NOT_SUPPORTED: The associated resource or media provider object (such as a MediaStream) has been found to be unsuitable."};t=i.player.api.error.code in r?r[i.player.api.error.code]:"MediaError code "+i.player.api.error.code}else"string"!=typeof(t=i.player.api.error)&&(t=JSON.stringify(t));else t="An error was encountered.";"Stream is online"==i.state?i.showError(t):(i.log(t,"error"),i.showError(i.state,{polling:!0}))}),"setSize"in i.player&&(i.player.videocontainer=i.video.parentNode,i.video.currentTarget=i.options.target,MistUtil.class.has(i.options.target,"mistvideo-secondaryVideo")||(i.player.resizeAll=function(){function e(t,i){if(t.video.currentTarget==i)return t.video;if(t.secondary)for(var r=0;r3600&&(t.reloadDelay/=1e3,this.log("A reloadDelay of more than an hour was set: assuming milliseconds were intended. ReloadDelay is now "+t.reloadDelay+"s")),new MistSkin(this),this.checkCombo=function(e,t){e||(e={}),e=MistUtil.object.extend(MistUtil.object.extend({},this.options),e);var r,n,a=!1;for(var s in e.forceSource?(r=[i.info.source[e.forceSource]],i.log("Forcing source "+e.forceSource+": "+r[0].type+" @ "+r[0].url)):e.forceType?(r=i.info.source.filter(function(t){return t.type==e.forceType}),i.log("Forcing type "+e.forceType)):r=i.info.source,mistplayers)mistplayers[s].shortname=s;e.forcePlayer&&mistplayers[e.forcePlayer]?(n=[mistplayers[e.forcePlayer]],i.log("Forcing player "+e.forcePlayer)):n=MistUtil.object.values(mistplayers),r=[].concat(r);var o={first:"source",source:[function(e){return"origIndex"in e?e.origIndex:(e.origIndex=i.info.source.indexOf(e),e.origIndex)}],player:[{priority:1}]},l={inner:"player",outer:"source"};if(e.forcePriority){if("source"in e.forcePriority){if(!(e.forcePriority.source instanceof Array))throw"forcePriority.source is not an array.";o.source=e.forcePriority.source.concat(o.source),MistUtil.array.multiSort(r,o.source)}if("player"in e.forcePriority){if(!(e.forcePriority.player instanceof Array))throw"forcePriority.player is not an array.";o.player=e.forcePriority.player.concat(o.player),MistUtil.array.multiSort(n,o.player)}"first"in e.forcePriority&&(o.first=e.forcePriority.first),"player"==o.first&&(l.outer="player",l.inner="source")}var c={player:{list:n,current:!1},source:{list:r,current:!1}};if(e.startCombo){e.startCombo.started={player:!1,source:!1};for(s=0;s=2))for(var v in c[l.inner].list)if(c[l.inner].current=v,!(d(l.inner)>=1)){a=c.source.list[c.source.current];var y=c.player.list[c.player.current].shortname,g=mistplayers[y];if(g.isMimeSupported(a.type)){var b=g.isBrowserSupported(a.type,a,i);if(b){var k=p(b);if(k>u.score&&(t||i.log("Found a "+(u.score?"better":"working")+" combo: "+g.name+" with "+a.url+" (Score: "+k+")"),(u={score:k,player:y,source:a,source_index:c.source.current}).score==m))return u}}}return!!u.score&&u},this.choosePlayer=function(){i.log("Checking available players..");var e=this.checkCombo();if(!e)return!1;var t=mistplayers[e.player],r=e.source;return i.log("Selected: "+t.name+" with "+r.type+" @ "+r.url),i.playerName=e.player,(r=MistUtil.object.extend({},r)).index=e.source_index,r.url=i.urlappend(r.url),i.source=r,MistUtil.event.send("comboChosen","Player/source combination selected",i.options.target),!0},i.calcSize=function(){return{width:640,height:480}},MistUtil.empty(i.options.target),new MistSkin(i),i.container=new MistUI(i,i.skin.structure.placeholder),i.options.target.appendChild(i.container),i.container.setAttribute("data-loading",""),"WebSocket"in window){!function e(){i.log("Opening stream status stream through websocket..");var t,s=i.options.host.replace(/^http/i,"ws");s=MistUtil.http.url.addParam(i.urlappend(s+"/json_"+encodeURIComponent(i.stream)+".js"),{metaeverywhere:1,inclzero:1});try{t=new WebSocket(s)}catch(e){return i.log("Error while attempting to open WebSocket to "+s),void a()}i.socket=t,t.die=!1,t.destroy=function(){this.die=!0,i.reporting&&(i.reporting.reportStats(),i.reporting=!1),this.onclose=function(){},this.close()},t.timeOut=i.timers.start(function(){t.readyState<=1&&(t.destroy(),a())},5e3),t.onopen=function(e){this.wasConnected=!0,i.reporting||(i.reporting={stats:{set:function(e,t){this.d[e]=t},add:function(e,t){void 0===t&&(t=1),this.d[e]+=t},d:{nWaiting:0,timeWaiting:0,nStalled:0,timeStalled:0,timeUnpaused:0,nError:0,nLog:0,videoHeight:null,videoWidth:null,playerHeight:null,playerWidth:null},last:{firstPlayback:null,nWaiting:0,timeWaiting:0,nStalled:0,timeStalled:0,timeUnpaused:0,nError:0,lastError:null,playbackScore:1,nLog:0,autoplay:null,videoHeight:null,videoWidth:null,playerHeight:null,playerWidth:null}},report:function(e){1==i.socket.readyState&&i.socket.send(JSON.stringify(e))},reportStats:function(){var e={},t=!1,r=i.logs.slice(this.stats.last.nLog);for(var n in this.stats.d)this.stats.d[n]!=this.stats.last[n]&&(e[n]=this.stats.d[n],this.stats.last[n]=e[n],t=!0);if(t){if(r.length)for(var n in e.logs=[],r)e.logs.push(r[n].message);this.report(e)}i.timers.start(function(){i.reporting&&i.reporting.reportStats()},5e3)},init:function(){var e=i.video,t=MistUtil.event.addListener(e,"playing",function(){i.reporting.stats.set("firstPlayback",(new Date).getTime()-i.bootMs),MistUtil.event.removeListener(t)});if(MistUtil.event.addListener(e,"waiting",function(){i&&i.reporting&&i.reporting.stats.add("nWaiting")}),MistUtil.event.addListener(e,"stalled",function(){i&&i.reporting&&i.reporting.stats.add("nStalled")}),MistUtil.event.addListener(i.options.target,"error",function(e){i&&i.reporting&&(i.reporting.stats.add("nError"),i.reporting.stats.set("lastError",e.message))},e),Object&&Object.defineProperty){var r=0,n=!1,a=0,s=!1,o=0,l=!1,c=i.reporting.stats.d;Object.defineProperty(c,"timeWaiting",{get:function(){return r+(n?(new Date).getTime()-n:0)}}),Object.defineProperty(c,"timeStalled",{get:function(){return a+(s?(new Date).getTime()-s:0)}}),Object.defineProperty(c,"timeUnpaused",{get:function(){return o+(l?(new Date).getTime()-l:0)}}),Object.defineProperty(c,"nLog",{get:function(){return i.logs.length}}),Object.defineProperty(c,"videoHeight",{get:function(){return i.video?i.video.videoHeight:null}}),Object.defineProperty(c,"videoWidth",{get:function(){return i.video?i.video.videoWidth:null}}),Object.defineProperty(c,"playerHeight",{get:function(){return i.video?i.video.clientHeight:null}}),Object.defineProperty(c,"playerWidth",{get:function(){return i.video?i.video.clientWidth:null}}),MistUtil.event.addListener(e,"waiting",function(){r=c.timeWaiting,n=(new Date).getTime()}),MistUtil.event.addListener(e,"stalled",function(){a=c.timeStalled,s=(new Date).getTime()});var d=["playing","pause"];for(var u in d)MistUtil.event.addListener(e,d[u],function(){r=c.timeWaiting,a=c.timeStalled,n=!1,s=!1});MistUtil.event.addListener(e,"playing",function(){o=c.timeUnpaused,l=(new Date).getTime()}),MistUtil.event.addListener(e,"pause",function(){o=c.timeUnpaused,l=!1})}this.reportStats()}})},t.onclose=function(t){if(!this.die)return this.wasConnected?(i.log("Reopening websocket.."),void e()):void a()};var o=!1;t.addEventListener("message",function(e){t.timeOut&&(i.timers.stop(t.timeOut),t.timeOut=!1);var a=JSON.parse(e.data);if(a||i.showError("Error while parsing stream status stream. Obtained: "+e.data.toString(),{reload:!0}),"error"in a){var s;switch(e=a.error,"on_error"in a?(i.log(e),e=a.on_error):"perc"in a&&(e+=" ("+Math.round(10*a.perc)/10+"%)"),i.state=a.error,a.error){case"Stream is offline":i.info=!1,i.player&&i.player.api&&i.player.api.currentTime&&(i.resumeTime=i.player.api.currentTime);case"Stream is initializing":case"Stream is booting":case"Stream is waiting for data":case"Stream is shutting down":case"Stream status is invalid?!":if(i.player&&i.player.api&&!i.player.api.paused)return i.log(a.error,"error"),o||(o=MistUtil.event.addListener(i.video,"ended",function(){i.showError(a.error,{polling:!0})})),void(o=MistUtil.event.addListener(i.video,"waiting",function(){i.showError(a.error,{polling:!0})}));s={polling:!0};break;default:s={reload:!0}}i.showError(e,s)}else{if(i.state="Stream is online",i.clearError(),o&&MistUtil.event.removeListener(o),!i.info)return void n(a);var l=function e(t,i){if(t==i)return!1;if("object"==typeof t&&void 0!==i){var r={};for(var n in t)if(!(MistUtil.array.indexOf(["lastms","hasVideo"],n)>=0)){var a=e(t[n],i[n]);a&&(r[n]=!0===a?[t[n],i[n]]:a)}for(var n in i)MistUtil.array.indexOf(["lastms","hasVideo"],n)>=0||n in t||(r[n]=[t[n],i[n]]);return!!MistUtil.object.keys(r).length&&r}return!0}(a,i.info);if(l){if("source"in l&&"error"in i.info)return void i.reload("Reloading, stream info has error");i.info=MistUtil.object.extend(i.info,a),i.info.updated=new Date;var c=!1;for(var d in l)switch(d){case"meta":for(var u in l[d])switch(u){case"tracks":i.info.hasVideo=r(i.info),MistUtil.event.send("metaUpdate_tracks",a,i.video)}break;case"width":case"height":c=!0}c&&i.player.resize()}else i.log("Metachange: no differences detected")}})}()}else a();return this.unload=function(e){if(!this.destroyed){for(var t in this.log("Unloading.."),this.destroyed=!0,this.timers.stop("all"),this.errorListeners){var r=this.errorListeners[t];if(r.src in MistUtil.scripts.list){var n=MistUtil.array.indexOf(MistUtil.scripts.list[r.src].subscribers);n>=0&&MistUtil.scripts.list[r.src].subscribers.splice(n,1)}}if("monitor"in i&&"destroy"in i.monitor&&i.monitor.destroy(),this.socket&&(this.reporting&&(this.reporting.reportStats(),this.reporting.report({unload:e||null})),this.socket.destroy()),this.player&&this.player.api&&("pause"in this.player.api&&this.player.api.pause(),"setSource"in this.player.api&&this.player.api.setSource(""),"unload"in this.player.api))try{this.player.api.unload()}catch(a){i.log("Error while unloading player: "+a.message)}if(this.metaTrackSubscriptions&&this.metaTrackSubscriptions.socket&&this.metaTrackSubscriptions.destroy(),this.UI&&this.UI.elements)for(var t in this.UI.elements){var a=this.UI.elements[t];if("attachedListeners"in a)for(var t in a.attachedListeners)MistUtil.event.removeListener(a.attachedListeners[t]);a.parentNode&&a.parentNode.removeChild(a)}this.video&&MistUtil.empty(this.video),"container"in this&&(MistUtil.empty(this.container),delete this.container),MistUtil.empty(this.options.target),delete this.video}},this.reload=function(e){var t="player"in this&&"api"in this.player&&this.player.api.currentTime;this.unload(e);var r=mistPlay(this.stream,this.options);if(t&&"live"!=this.info.type){var n=function(){r.player&&r.player.api&&(r.player.api.currentTime=t),this.removeEventListener("initialized",n)};MistUtil.event.addListener(this.options.target,"initialized",n)}return i},this.nextCombo=function(){var e=!1;"player"in this&&"api"in this.player&&(e=this.player.api.currentTime);var t={source:this.source.index,player:this.playerName};if(!this.checkCombo({startCombo:t},!0)){if(!this.checkCombo({startCombo:!1},!0))return;t=!1}this.unload("nextCombo");var r=this.options;if(r.startCombo=t,i=mistPlay(this.stream,r),e&&isFinite(e)&&"live"!=this.info.type){var n=function(){"player"in i&&"api"in i.player&&(i.player.api.currentTime=e),this.removeEventListener("initialized",n)};MistUtil.event.addListener(r.target,"initialized",n)}},this.onPlayerBuilt=function(){},t.MistVideoObject&&(t.MistVideoObject.reference=this),this} \ No newline at end of file diff --git a/embed/min/skins/default.css b/embed/min/skins/default.css index 7d0e7892..02a6371a 100644 --- a/embed/min/skins/default.css +++ b/embed/min/skins/default.css @@ -2,32 +2,32 @@ .mistvideo-controls{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none} .mistvideo.novideo{overflow:visible} .mistvideo-video{overflow:hidden;outline:0} -svg.icon.loading{z-index:-1;position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;opacity:0} -[data-loading]{position:relative} -[data-loading=stalled] svg.icon.loading{transition:opacity 0s 3s} -[data-loading] svg.icon.loading{z-index:2;opacity:1} -[data-loading-css] .mistvideo-controls{display:none} -[data-hidecursor],[data-hidecursor] *,[data-hidecursor] .mistvideo-pointer{cursor:none} +.mistvideo svg.icon.loading{z-index:-1;position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;opacity:0} +.mistvideo [data-loading]{position:relative} +.mistvideo [data-loading=stalled] svg.icon.loading{transition:opacity 0s 3s} +.mistvideo [data-loading] svg.icon.loading{z-index:2;opacity:1} +.mistvideo [data-loading-css] .mistvideo-controls{display:none} +.mistvideo [data-hidecursor],.mistvideo [data-hidecursor] *,.mistvideo [data-hidecursor] .mistvideo-pointer{cursor:none} .mistvideo-error{display:none;position:absolute;top:0;left:0;right:0;bottom:0;background-color:$background;align-items:center;justify-content:center;text-align:center;z-index:2;cursor:default;min-height:fit-content;min-width:fit-content;height:100%} .mistvideo-error.show{display:flex} .mistvideo-error .message{max-width:80%} .mistvideo-error .message .details table{text-align:left} .mistvideo-controls button,.mistvideo-error button,.mistvideo-video:not(.video-js) button{color:$stroke;border:1px solid $semiFill;background-color:$background;margin:.25em;padding:.5em 1em;opacity:.5;cursor:pointer} -button:hover{opacity:1} -select{background-color:transparent;color:$stroke;border:none;margin:0 .5em;font-size:inherit;cursor:pointer;-ms-background-color:red} -select>option{background-color:$background} +.mistvideo button:hover{opacity:1} +.mistvideo select{background-color:transparent;color:$stroke;border:none;margin:0 .5em;font-size:inherit;cursor:pointer;-ms-background-color:red} +.mistvideo select>option{background-color:$background} .browser-edge select,.browser-safari select{border:1px solid $semiFill;border-top:none;border-left:none;margin-top:2px} @keyframes mistvideo-spin{ 0%{transform:rotate(0)} 100%{transform:rotate(360deg)} } [data-fullscreen]{position:fixed;top:0;left:0;right:0;bottom:0;width:100%!important;height:100%!important;background-color:#111!important;z-index:999} -video{display:block;flex-shrink:0} -table{color:inherit;font-size:inherit;font-style:inherit} -audio:not([controls]){display:block!important} +.mistvideo video{display:block;flex-shrink:0} +.mistvideo table{color:inherit;font-size:inherit;font-style:inherit} +.mistvideo audio:not([controls]){display:block!important} .mistvideo-padding{padding:5px 10px} .mistvideo-pointer{cursor:pointer} -.description{color:$semiFill;font-size:.9em} +.msitvideo .description{color:$semiFill;font-size:.9em} .mistvideo-container{display:flex;flex-wrap:nowrap} .mistvideo-container.mistvideo{display:inline-flex;max-width:100%} .mistvideo-container.mistvideo-row{flex-direction:row} @@ -45,7 +45,7 @@ audio:not([controls]){display:block!important} .mistvideo-tooltip .triangle{border:10px solid $background;position:absolute} .mistvideo-tracks label{display:block} .mistvideo-tracks label>span{margin-right:1em} -a{color:$accent} +.mistvideo a{color:$accent} .mistvideo-log .logs{-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text} .mistvideo-placeholder{max-width:100%;max-height:100%} .mistvideo-topright{position:absolute;top:0;right:0} @@ -55,12 +55,12 @@ a{color:$accent} from{opacity:0} to{opacity:1} } -svg.icon{display:block;stroke-width:$strokeWidth;fill:none;stroke:none} -svg.icon .fill,svg.icon.fill{fill:$fill} -svg.icon .semiFill,svg.icon.semiFill{fill:$semiFill} -svg.icon .stroke,svg.icon.stroke{stroke:$stroke;vector-effect:non-scaling-stroke} -svg.icon.off .toggle .fill,svg.icon.off .toggle .semiFill,svg.icon.off .toggle.fill,svg.icon.off .toggle.semiFill{fill:none} -svg.icon .spin,svg.icon.spin{animation:mistvideo-spin 1.5s infinite linear;transform-origin:50% 50%} +.mistvideo svg.icon{display:block;stroke-width:$strokeWidth;fill:none;stroke:none} +.mistvideo svg.icon.fill,svg.icon .fill{fill:$fill} +.mistvideo svg.icon.semiFill,svg.icon .semiFill{fill:$semiFill} +.mistvideo svg.icon.stroke,svg.icon .stroke{stroke:$stroke;vector-effect:non-scaling-stroke} +.mistvideo svg.icon.off .toggle .fill,.mistvideo svg.icon.off .toggle .semiFill,.mistvideo svg.icon.off .toggle.fill,.mistvideo svg.icon.off .toggle.semiFill{fill:none} +.mistvideo svg.icon.spin,svg.icon .spin{animation:mistvideo-spin 1.5s infinite linear;transform-origin:50% 50%} .vjs-text-track-display{pointer-events:none} .vjs-controls-disabled .vjs-control-bar,.vjs-error .vjs-control-bar,.vjs-error-display,.vjs-hidden,.vjs-using-native-controls .vjs-control-bar{display:none!important} .vjs-controls-disabled .vjs-big-play-button,.vjs-controls-disabled .vjs-loading-spinner,.vjs-error .vjs-big-play-button,.vjs-has-started .vjs-big-play-button,.vjs-using-native-controls .vjs-big-play-button{display:none} @@ -84,7 +84,7 @@ svg.icon .spin,svg.icon.spin{animation:mistvideo-spin 1.5s infinite linear;trans .mistvideo-play[data-state=playing] svg.play{display:none} .mistvideo-play[data-state=paused] svg.pause{display:none} .mistvideo-main{align-items:center} -svg.icon.timeout{display:inline-block;height:1em;width:1em;margin:0;margin-right:.25em;vertical-align:top} +.mistvideo svg.icon.timeout{display:inline-block;height:1em;width:1em;margin:0;margin-right:.25em;vertical-align:top} .mist.largeplay,.mist.muted{position:absolute;opacity:.5} .mist.largeplay{top:50%;left:0;right:0;margin:auto;transform:translateY(-50%)} .mist.muted{top:0;right:0;margin:1%;max-height:20%;width:auto} @@ -112,6 +112,6 @@ svg.icon.timeout{display:inline-block;height:1em;width:1em;margin:0;margin-right .browser-ie .mist.icon.loading{animation:mistvideo-spin 1.5s infinite linear;transform-origin:50% 50%} .browser-ie .mist.icon.loading .spin{animation:none} .mistvideo-chromecast{display:flex} -google-cast-launcher{width:24px;height:24px;--connected-color:$fill;--disconnected-color:$semiFill} -google-cast-launcher.active{--connected-color:$accent;--disconnected-color:$fill} +.mistvideo google-cast-launcher{width:24px;height:24px;--connected-color:$fill;--disconnected-color:$semiFill} +.mistvideo google-cast-launcher.active{--connected-color:$accent;--disconnected-color:$fill} .mistvideo.casting .mistvideo-slideshow_mode{display:none} \ No newline at end of file diff --git a/embed/min/skins/dev.css b/embed/min/skins/dev.css index 8ed68c56..d2956679 100644 --- a/embed/min/skins/dev.css +++ b/embed/min/skins/dev.css @@ -2,32 +2,32 @@ .mistvideo-controls{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none} .mistvideo.novideo{overflow:visible} .mistvideo-video{overflow:hidden;outline:0} -svg.icon.loading{z-index:-1;position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;opacity:0} -[data-loading]{position:relative} -[data-loading=stalled] svg.icon.loading{transition:opacity 0s 3s} -[data-loading] svg.icon.loading{z-index:2;opacity:1} -[data-loading-css] .mistvideo-controls{display:none} -[data-hidecursor],[data-hidecursor] *,[data-hidecursor] .mistvideo-pointer{cursor:none} +.mistvideo svg.icon.loading{z-index:-1;position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;opacity:0} +.mistvideo [data-loading]{position:relative} +.mistvideo [data-loading=stalled] svg.icon.loading{transition:opacity 0s 3s} +.mistvideo [data-loading] svg.icon.loading{z-index:2;opacity:1} +.mistvideo [data-loading-css] .mistvideo-controls{display:none} +.mistvideo [data-hidecursor],.mistvideo [data-hidecursor] *,.mistvideo [data-hidecursor] .mistvideo-pointer{cursor:none} .mistvideo-error{display:none;position:absolute;top:0;left:0;right:0;bottom:0;background-color:$background;align-items:center;justify-content:center;text-align:center;z-index:2;cursor:default;min-height:fit-content;min-width:fit-content;height:100%} .mistvideo-error.show{display:flex} .mistvideo-error .message{max-width:80%} .mistvideo-error .message .details table{text-align:left} .mistvideo-controls button,.mistvideo-error button,.mistvideo-video:not(.video-js) button{color:$stroke;border:1px solid $semiFill;background-color:$background;margin:.25em;padding:.5em 1em;opacity:.5;cursor:pointer} -button:hover{opacity:1} -select{background-color:transparent;color:$stroke;border:none;margin:0 .5em;font-size:inherit;cursor:pointer;-ms-background-color:red} -select>option{background-color:$background} +.mistvideo button:hover{opacity:1} +.mistvideo select{background-color:transparent;color:$stroke;border:none;margin:0 .5em;font-size:inherit;cursor:pointer;-ms-background-color:red} +.mistvideo select>option{background-color:$background} .browser-edge select,.browser-safari select{border:1px solid $semiFill;border-top:none;border-left:none;margin-top:2px} @keyframes mistvideo-spin{ 0%{transform:rotate(0)} 100%{transform:rotate(360deg)} } [data-fullscreen]{position:fixed;top:0;left:0;right:0;bottom:0;width:100%!important;height:100%!important;background-color:#111!important;z-index:999} -video{display:block;flex-shrink:0} -table{color:inherit;font-size:inherit;font-style:inherit} -audio:not([controls]){display:block!important} +.mistvideo video{display:block;flex-shrink:0} +.mistvideo table{color:inherit;font-size:inherit;font-style:inherit} +.mistvideo audio:not([controls]){display:block!important} .mistvideo-padding{padding:5px 10px} .mistvideo-pointer{cursor:pointer} -.description{color:$semiFill;font-size:.9em} +.msitvideo .description{color:$semiFill;font-size:.9em} .mistvideo-container{display:flex;flex-wrap:nowrap} .mistvideo-container.mistvideo{display:inline-flex;max-width:100%} .mistvideo-container.mistvideo-row{flex-direction:row} @@ -45,7 +45,7 @@ audio:not([controls]){display:block!important} .mistvideo-tooltip .triangle{border:10px solid $background;position:absolute} .mistvideo-tracks label{display:block} .mistvideo-tracks label>span{margin-right:1em} -a{color:$accent} +.mistvideo a{color:$accent} .mistvideo-log .logs{-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text} .mistvideo-placeholder{max-width:100%;max-height:100%} .mistvideo-topright{position:absolute;top:0;right:0} @@ -55,12 +55,12 @@ a{color:$accent} from{opacity:0} to{opacity:1} } -svg.icon{display:block;stroke-width:$strokeWidth;fill:none;stroke:none} -svg.icon .fill,svg.icon.fill{fill:$fill} -svg.icon .semiFill,svg.icon.semiFill{fill:$semiFill} -svg.icon .stroke,svg.icon.stroke{stroke:$stroke;vector-effect:non-scaling-stroke} -svg.icon.off .toggle .fill,svg.icon.off .toggle .semiFill,svg.icon.off .toggle.fill,svg.icon.off .toggle.semiFill{fill:none} -svg.icon .spin,svg.icon.spin{animation:mistvideo-spin 1.5s infinite linear;transform-origin:50% 50%} +.mistvideo svg.icon{display:block;stroke-width:$strokeWidth;fill:none;stroke:none} +.mistvideo svg.icon.fill,svg.icon .fill{fill:$fill} +.mistvideo svg.icon.semiFill,svg.icon .semiFill{fill:$semiFill} +.mistvideo svg.icon.stroke,svg.icon .stroke{stroke:$stroke;vector-effect:non-scaling-stroke} +.mistvideo svg.icon.off .toggle .fill,.mistvideo svg.icon.off .toggle .semiFill,.mistvideo svg.icon.off .toggle.fill,.mistvideo svg.icon.off .toggle.semiFill{fill:none} +.mistvideo svg.icon.spin,svg.icon .spin{animation:mistvideo-spin 1.5s infinite linear;transform-origin:50% 50%} .vjs-text-track-display{pointer-events:none} .vjs-controls-disabled .vjs-control-bar,.vjs-error .vjs-control-bar,.vjs-error-display,.vjs-hidden,.vjs-using-native-controls .vjs-control-bar{display:none!important} .vjs-controls-disabled .vjs-big-play-button,.vjs-controls-disabled .vjs-loading-spinner,.vjs-error .vjs-big-play-button,.vjs-has-started .vjs-big-play-button,.vjs-using-native-controls .vjs-big-play-button{display:none} @@ -84,7 +84,7 @@ svg.icon .spin,svg.icon.spin{animation:mistvideo-spin 1.5s infinite linear;trans .mistvideo-play[data-state=playing] svg.play{display:none} .mistvideo-play[data-state=paused] svg.pause{display:none} .mistvideo-main{align-items:center} -svg.icon.timeout{display:inline-block;height:1em;width:1em;margin:0;margin-right:.25em;vertical-align:top} +.mistvideo svg.icon.timeout{display:inline-block;height:1em;width:1em;margin:0;margin-right:.25em;vertical-align:top} .mist.largeplay,.mist.muted{position:absolute;opacity:.5} .mist.largeplay{top:50%;left:0;right:0;margin:auto;transform:translateY(-50%)} .mist.muted{top:0;right:0;margin:1%;max-height:20%;width:auto} @@ -112,8 +112,8 @@ svg.icon.timeout{display:inline-block;height:1em;width:1em;margin:0;margin-right .browser-ie .mist.icon.loading{animation:mistvideo-spin 1.5s infinite linear;transform-origin:50% 50%} .browser-ie .mist.icon.loading .spin{animation:none} .mistvideo-chromecast{display:flex} -google-cast-launcher{width:24px;height:24px;--connected-color:$fill;--disconnected-color:$semiFill} -google-cast-launcher.active{--connected-color:$accent;--disconnected-color:$fill} +.mistvideo google-cast-launcher{width:24px;height:24px;--connected-color:$fill;--disconnected-color:$semiFill} +.mistvideo google-cast-launcher.active{--connected-color:$accent;--disconnected-color:$fill} .mistvideo.casting .mistvideo-slideshow_mode{display:none} .mistvideo-log{margin:.5em 0} .mistvideo-log .logs{max-height:10em;min-height:5em;width:100%;padding:.2em 0;padding-right:1em;overflow-y:auto;overflow-x:hidden;font-size:.9em} @@ -136,8 +136,8 @@ google-cast-launcher.active{--connected-color:$accent;--disconnected-color:$fill .mistvideo-decodingIssues label{position:relative} .mistvideo-decodingIssues label .mistvideo-description{font-size:.9em} .mistvideo-decodingIssues label .value{font-size:.8em} -svg.icon.graph{position:absolute;right:0;top:0;bottom:0;width:6em} -select{border-radius:0} -input[type=checkbox]{margin:0;margin-right:.2em;border:1px solid $semiFill;border-radius:0;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;appearance:none;width:.8em;height:.8em;color:inherit;position:relative;cursor:pointer} -input[type=checkbox]:checked:after{content:"\2713";position:absolute;bottom:-.2em;left:0;font-size:1.2em} +.mistvideo svg.icon.graph{position:absolute;right:0;top:0;bottom:0;width:6em} +.mistvideo select{border-radius:0} +.mistvideo input[type=checkbox]{margin:0;margin-right:.2em;border:1px solid $semiFill;border-radius:0;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;appearance:none;width:.8em;height:.8em;color:inherit;position:relative;cursor:pointer} +.mistvideo input[type=checkbox]:checked:after{content:"\2713";position:absolute;bottom:-.2em;left:0;font-size:1.2em} .mistvideo.casting .mistvideo-displayCombo,.mistvideo.casting .mistvideo-forcePlayer,.mistvideo.casting .mistvideo-forceType{display:none!important} \ No newline at end of file diff --git a/embed/min/wrappers/dashjs.js b/embed/min/wrappers/dashjs.js index 2c68ce73..59281cf0 100644 --- a/embed/min/wrappers/dashjs.js +++ b/embed/min/wrappers/dashjs.js @@ -1 +1 @@ -mistplayers.dashjs={name:"Dash.js player",mimes:["dash/video/mp4"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return MistUtil.array.indexOf(this.mimes,e)==-1?false:true},isBrowserSupported:function(e,t,i){if(location.protocol!=MistUtil.http.url.split(t.url).protocol){i.log("HTTP/HTTPS mismatch for this source");return false}if(location.protocol=="file:"){i.log("This source ("+e+") won't load if the page is run via file://");return false}if(!("MediaSource"in window)){return false}if(!MediaSource.isTypeSupported){return true}var r={};var a=false;for(var s in i.info.meta.tracks){if(i.info.meta.tracks[s].type=="meta"){if(i.info.meta.tracks[s].codec=="subtitle"){a=true}continue}if(!(i.info.meta.tracks[s].type in r)){r[i.info.meta.tracks[s].type]={}}r[i.info.meta.tracks[s].type][MistUtil.tracks.translateCodec(i.info.meta.tracks[s])]=1}var o=[];for(var n in r){var l=false;for(var f in r[n]){if(MediaSource.isTypeSupported('video/mp4;codecs="'+f+'"')){l=true;break}}if(l){o.push(n)}}if(a){for(var s in i.info.source){if(i.info.source[s].type=="html5/text/vtt"){o.push("subtitle");break}}}return o.length?o:false},player:function(){this.onreadylist=[]},scriptsrc:function(e){return e+"/dashjs.js"}};var p=mistplayers.dashjs.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var i=this;this.onDashLoad=function(){if(e.destroyed){return}e.log("Building DashJS player..");var r=document.createElement("video");if("Proxy"in window){var a={get:{},set:{}};e.player.api=new Proxy(r,{get:function(e,t,i){if(t in a.get){return a.get[t].apply(e,arguments)}var r=e[t];if(typeof r==="function"){return function(){return r.apply(e,arguments)}}return r},set:function(e,t,i){if(t in a.set){return a.set[t].call(e,i)}return e[t]=i}});if(e.info.type=="live"){a.get.duration=function(){var t=0;if(this.buffered.length){t=this.buffered.end(this.buffered.length-1)}var i=((new Date).getTime()-e.player.api.lastProgress.getTime())*.001;return t+i+-1*e.player.api.liveOffset+45};a.set.currentTime=function(t){var i=t-e.player.api.duration;e.log("Seeking to "+MistUtil.format.time(t)+" ("+Math.round(i*-10)/10+"s from live)");e.video.currentTime=t};MistUtil.event.addListener(r,"progress",(function(){e.player.api.lastProgress=new Date}));e.player.api.lastProgress=new Date;e.player.api.liveOffset=0}}else{i.api=r}if(e.options.autoplay){r.setAttribute("autoplay","")}if(e.options.loop&&e.info.type!="live"){r.setAttribute("loop","")}if(e.options.poster){r.setAttribute("poster",e.options.poster)}if(e.options.muted){r.muted=true}if(e.options.controls=="stock"){r.setAttribute("controls","")}var s=dashjs.MediaPlayer().create();s.initialize(r,e.source.url,e.options.autoplay);i.dash=s;var o=["METRIC_ADDED","METRIC_UPDATED","METRIC_CHANGED","METRICS_CHANGED","FRAGMENT_LOADING_STARTED","FRAGMENT_LOADING_COMPLETED","LOG","PLAYBACK_TIME_UPDATED","PLAYBACK_PROGRESS"];for(var n in dashjs.MediaPlayer.events){if(o.indexOf(n)<0){i.dash.on(dashjs.MediaPlayer.events[n],(function(t){e.log("Player event fired: "+t.type)}))}}e.player.setSize=function(e){this.api.style.width=e.width+"px";this.api.style.height=e.height+"px"};e.player.api.setSource=function(t){e.player.dash.attachSource(t)};if(e.options.controls!="stock"){i.dash.updateSettings({streaming:{text:{defaultEnabled:false}}})}var l=false;i.dash.on("allTextTracksAdded",(function(){l=true}));e.player.api.setSubtitle=function(t){if(!l){var r=function(){e.player.api.setSubtitle(t);i.dash.off("allTextTracksAdded",r)};i.dash.on("allTextTracksAdded",r);return}if(!t){i.dash.enableText(false);return}var a=i.dash.getTracksFor("text");for(var s in a){var o="idx"in t?t.idx:t.trackid;if(a[s].id==o){i.dash.setTextTrack(s);if(!i.dash.isTextEnabled()){i.dash.enableText()}return true}}return false};MistUtil.event.addListener(r,"progress",(function(t){if(e.container.getAttribute("data-loading")=="stalled"){e.container.removeAttribute("data-loading")}}));i.api.unload=function(){i.dash.reset()};e.log("Built html");t(r)};if("dashjs"in window){this.onDashLoad()}else{var r=MistUtil.scripts.insert(e.urlappend(mistplayers.dashjs.scriptsrc(e.options.host)),{onerror:function(t){var i="Failed to load dashjs.js";if(t.message){i+=": "+t.message}e.showError(i)},onload:i.onDashLoad},e)}}; \ No newline at end of file +mistplayers.dashjs={name:"Dash.js player",mimes:["dash/video/mp4"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return MistUtil.array.indexOf(this.mimes,e)==-1?false:true},isBrowserSupported:function(e,t,i){if(location.protocol!=MistUtil.http.url.split(t.url).protocol){i.log("HTTP/HTTPS mismatch for this source");return false}if(location.protocol=="file:"){i.log("This source ("+e+") won't load if the page is run via file://");return false}if(!("MediaSource"in window)){return false}if(!MediaSource.isTypeSupported){return true}var r={};var a=false;for(var s in i.info.meta.tracks){if(i.info.meta.tracks[s].type=="meta"){if(i.info.meta.tracks[s].codec=="subtitle"){a=true}continue}if(!(i.info.meta.tracks[s].type in r)){r[i.info.meta.tracks[s].type]={}}r[i.info.meta.tracks[s].type][MistUtil.tracks.translateCodec(i.info.meta.tracks[s])]=1}var o=[];for(var n in r){var l=false;for(var f in r[n]){if(MediaSource.isTypeSupported('video/mp4;codecs="'+f+'"')){l=true;break}}if(l){o.push(n)}}if(a){for(var s in i.info.source){if(i.info.source[s].type=="html5/text/vtt"){o.push("subtitle");break}}}return o.length?o:false},player:function(){this.onreadylist=[]},scriptsrc:function(e){return e+"/dashjs.js"}};var p=mistplayers.dashjs.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var i=this;this.onDashLoad=function(){if(e.destroyed){return}e.log("Building DashJS player..");var r=document.createElement("video");if("Proxy"in window){var a={get:{},set:{}};e.player.api=new Proxy(r,{get:function(e,t,i){if(t in a.get){return a.get[t].apply(e,arguments)}var r=e[t];if(typeof r==="function"){return function(){return r.apply(e,arguments)}}return r},set:function(e,t,i){if(t in a.set){return a.set[t].call(e,i)}return e[t]=i}});if(e.info.type=="live"){a.get.duration=function(){var t=0;if(this.buffered.length){t=this.buffered.end(this.buffered.length-1)}var i=((new Date).getTime()-e.player.api.lastProgress.getTime())*.001;return t+i+-1*e.player.api.liveOffset+45};a.set.currentTime=function(t){var i=t-e.player.api.duration;e.log("Seeking to "+MistUtil.format.time(t)+" ("+Math.round(i*-10)/10+"s from live)");e.video.currentTime=t};MistUtil.event.addListener(r,"progress",function(){e.player.api.lastProgress=new Date});e.player.api.lastProgress=new Date;e.player.api.liveOffset=0}}else{i.api=r}if(e.options.autoplay){r.setAttribute("autoplay","")}if(e.options.loop&&e.info.type!="live"){r.setAttribute("loop","")}if(e.options.poster){r.setAttribute("poster",e.options.poster)}if(e.options.muted){r.muted=true}if(e.options.controls=="stock"){r.setAttribute("controls","")}var s=dashjs.MediaPlayer().create();s.initialize(r,e.source.url,e.options.autoplay);i.dash=s;var o=["METRIC_ADDED","METRIC_UPDATED","METRIC_CHANGED","METRICS_CHANGED","FRAGMENT_LOADING_STARTED","FRAGMENT_LOADING_COMPLETED","LOG","PLAYBACK_TIME_UPDATED","PLAYBACK_PROGRESS"];for(var n in dashjs.MediaPlayer.events){if(o.indexOf(n)<0){i.dash.on(dashjs.MediaPlayer.events[n],function(t){e.log("Player event fired: "+t.type)})}}e.player.setSize=function(e){this.api.style.width=e.width+"px";this.api.style.height=e.height+"px"};e.player.api.setSource=function(t){e.player.dash.attachSource(t)};if(e.options.controls!="stock"){i.dash.updateSettings({streaming:{text:{defaultEnabled:false}}})}var l=false;i.dash.on("allTextTracksAdded",function(){l=true});e.player.api.setSubtitle=function(t){if(!l){var r=function(){e.player.api.setSubtitle(t);i.dash.off("allTextTracksAdded",r)};i.dash.on("allTextTracksAdded",r);return}if(!t){i.dash.enableText(false);return}var a=i.dash.getTracksFor("text");for(var s in a){var o="idx"in t?t.idx:t.trackid;if(a[s].id==o){i.dash.setTextTrack(s);if(!i.dash.isTextEnabled()){i.dash.enableText()}return true}}return false};MistUtil.event.addListener(r,"progress",function(t){if(e.container.getAttribute("data-loading")=="stalled"){e.container.removeAttribute("data-loading")}});i.api.unload=function(){i.dash.reset()};e.log("Built html");t(r)};if("dashjs"in window){this.onDashLoad()}else{var r=MistUtil.scripts.insert(e.urlappend(mistplayers.dashjs.scriptsrc(e.options.host)),{onerror:function(t){var i="Failed to load dashjs.js";if(t.message){i+=": "+t.message}e.showError(i)},onload:i.onDashLoad},e)}}; \ No newline at end of file diff --git a/embed/min/wrappers/flash_strobe.js b/embed/min/wrappers/flash_strobe.js index 09013d5d..8248445d 100644 --- a/embed/min/wrappers/flash_strobe.js +++ b/embed/min/wrappers/flash_strobe.js @@ -1 +1 @@ -mistplayers.flash_strobe={name:"Strobe Flash media playback",mimes:["flash/10","flash/11","flash/7"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(t){return this.mimes.indexOf(t)==-1?false:true},isBrowserSupported:function(t,e,i){if(MistUtil.http.url.split(e.url).protocol.slice(0,4)=="http"&&location.protocol!=MistUtil.http.url.split(e.url).protocol){i.log("HTTP/HTTPS mismatch for this source");return false}var r=0;try{var a=navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;if(a.version){r=a.version.split(".")[0]}else{r=a.description.replace(/([^0-9\.])/g,"").split(".")[0]}}catch(t){}try{r=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version").replace(/([^0-9\,])/g,"").split(",")[0]}catch(t){}if(!r){return false}var l=t.split("/");return Number(r)>=Number(l[l.length-1])},player:function(){this.onreadylist=[]}};var p=mistplayers.flash_strobe.player;p.prototype=new MistPlayer;p.prototype.build=function(t,e){var i=document.createElement("object");var r=document.createElement("embed");i.appendChild(r);function a(e){var a=t.options;function l(t,e){var i=document.createElement("param");i.setAttribute("name",t);i.setAttribute("value",e);return i}MistUtil.empty(i);i.appendChild(l("movie",t.urlappend(a.host+t.source.player_url)));var o="src="+encodeURIComponent(e)+"&controlBarMode="+(a.controls?"floating":"none")+"&initialBufferTime=0.5&expandedBufferTime=5&minContinuousPlaybackTime=3"+(a.live?"&streamType=live":"")+(a.autoplay?"&autoPlay=true":"")+(a.loop?"&loop=true":"")+(a.poster?"&poster="+a.poster:"")+(a.muted?"&muted=true":"");i.appendChild(l("flashvars",o));i.appendChild(l("allowFullScreen","true"));i.appendChild(l("wmode","direct"));if(a.autoplay){i.appendChild(l("autoPlay","true"))}if(a.loop){i.appendChild(l("loop","true"))}if(a.poster){i.appendChild(l("poster",a.poster))}if(a.muted){i.appendChild(l("muted","true"))}r.setAttribute("src",t.urlappend(t.source.player_url));r.setAttribute("type","application/x-shockwave-flash");r.setAttribute("allowfullscreen","true");r.setAttribute("flashvars",o)}a(t.source.url);this.api={};this.setSize=function(t){i.setAttribute("width",t.width);i.setAttribute("height",t.height);r.setAttribute("width",t.width);r.setAttribute("height",t.height)};this.setSize(t.calcSize());this.onready((function(){if(t.container){t.container.removeAttribute("data-loading")}}));this.api.setSource=function(t){a(t)};t.log("Built html");e(i)}; \ No newline at end of file +mistplayers.flash_strobe={name:"Strobe Flash media playback",mimes:["flash/10","flash/11","flash/7"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(t){return this.mimes.indexOf(t)==-1?false:true},isBrowserSupported:function(t,e,i){if(MistUtil.http.url.split(e.url).protocol.slice(0,4)=="http"&&location.protocol!=MistUtil.http.url.split(e.url).protocol){i.log("HTTP/HTTPS mismatch for this source");return false}var r=0;try{var a=navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;if(a.version){r=a.version.split(".")[0]}else{r=a.description.replace(/([^0-9\.])/g,"").split(".")[0]}}catch(t){}try{r=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version").replace(/([^0-9\,])/g,"").split(",")[0]}catch(t){}if(!r){return false}var l=t.split("/");return Number(r)>=Number(l[l.length-1])},player:function(){this.onreadylist=[]}};var p=mistplayers.flash_strobe.player;p.prototype=new MistPlayer;p.prototype.build=function(t,e){var i=document.createElement("object");var r=document.createElement("embed");i.appendChild(r);function a(e){var a=t.options;function l(t,e){var i=document.createElement("param");i.setAttribute("name",t);i.setAttribute("value",e);return i}MistUtil.empty(i);i.appendChild(l("movie",t.urlappend(a.host+t.source.player_url)));var o="src="+encodeURIComponent(e)+"&controlBarMode="+(a.controls?"floating":"none")+"&initialBufferTime=0.5&expandedBufferTime=5&minContinuousPlaybackTime=3"+(a.live?"&streamType=live":"")+(a.autoplay?"&autoPlay=true":"")+(a.loop?"&loop=true":"")+(a.poster?"&poster="+a.poster:"")+(a.muted?"&muted=true":"");i.appendChild(l("flashvars",o));i.appendChild(l("allowFullScreen","true"));i.appendChild(l("wmode","direct"));if(a.autoplay){i.appendChild(l("autoPlay","true"))}if(a.loop){i.appendChild(l("loop","true"))}if(a.poster){i.appendChild(l("poster",a.poster))}if(a.muted){i.appendChild(l("muted","true"))}r.setAttribute("src",t.urlappend(t.source.player_url));r.setAttribute("type","application/x-shockwave-flash");r.setAttribute("allowfullscreen","true");r.setAttribute("flashvars",o)}a(t.source.url);this.api={};this.setSize=function(t){i.setAttribute("width",t.width);i.setAttribute("height",t.height);r.setAttribute("width",t.width);r.setAttribute("height",t.height)};this.setSize(t.calcSize());this.onready(function(){if(t.container){t.container.removeAttribute("data-loading")}});this.api.setSource=function(t){a(t)};t.log("Built html");e(i)}; \ No newline at end of file diff --git a/embed/min/wrappers/flv.js b/embed/min/wrappers/flv.js index 9e980613..72c2db72 100644 --- a/embed/min/wrappers/flv.js +++ b/embed/min/wrappers/flv.js @@ -1 +1 @@ -mistplayers.flv={name:"HTML5 FLV Player",mimes:["flash/7"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return MistUtil.array.indexOf(this.mimes,e)==-1?false:true},isBrowserSupported:function(e,t,r){if(location.protocol!=MistUtil.http.url.split(t.url).protocol){if(location.protocol=="file:"&&MistUtil.http.url.split(t.url).protocol=="http:"){r.log("This page was loaded over file://, the player might not behave as intended.")}else{r.log("HTTP/HTTPS mismatch for this source");return false}}if(!window.MediaSource){return false}if(!MediaSource.isTypeSupported){return true}try{var o={};for(var a in r.info.meta.tracks){if(r.info.meta.tracks[a].type=="meta"){continue}if(!(r.info.meta.tracks[a].type in o)){o[r.info.meta.tracks[a].type]={}}o[r.info.meta.tracks[a].type][MistUtil.tracks.translateCodec(r.info.meta.tracks[a])]=1}var i=[];for(var l in o){var n=false;for(var s in o[l]){if(MediaSource.isTypeSupported('video/mp4;codecs="'+s+'"')){n=true;break}}if(n){i.push(l)}}t.supportedCodecs=i;return i.length?i:false}catch(e){}return false},player:function(){this.onreadylist=[]},scriptsrc:function(e){return e+"/flv.js"}};var p=mistplayers.flv.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){this.onFLVLoad=function(){if(e.destroyed){return}e.log("Building flv.js player..");var r=document.createElement("video");r.setAttribute("playsinline","");var o=["autoplay","loop","poster"];for(var a in o){var i=o[a];if(e.options[i]){r.setAttribute(i,e.options[i]===true?"":e.options[i])}}if(e.options.muted){r.muted=true}if(e.options.controls=="stock"){r.setAttribute("controls","")}if(e.info.type=="live"){r.loop=false}flvjs.LoggingControl.applyConfig({enableVerbose:false});flvjs.LoggingControl.addLogListener((function(t,r){e.log("[flvjs] "+r)}));var l={type:"flv",url:e.source.url,hasAudio:false,hasVideo:false};for(var a in e.source.supportedCodecs){l["has"+e.source.supportedCodecs[a].charAt(0).toUpperCase()+e.source.supportedCodecs[a].slice(1)]=true}e.player.create=function(t){t=MistUtil.object.extend({},t);e.player.flvPlayer=flvjs.createPlayer(t,{lazyLoad:false});e.player.flvPlayer.attachMediaElement(r);e.player.flvPlayer.load();e.player.flvPlayer.play();if(!e.options.autoplay){r.pause()}};e.player.create(l);e.player.api={};function n(t){Object.defineProperty(e.player.api,t,{get:function(){return r[t]},set:function(e){return r[t]=e}})}var s=["volume","buffered","muted","loop","paused",,"error","textTracks","webkitDroppedFrameCount","webkitDecodedFrameCount"];if(e.info.type!="live"){s.push("duration")}else{Object.defineProperty(e.player.api,"duration",{get:function(){if(!r.buffered.length){return 0}return r.buffered.end(r.buffered.length-1)}})}for(var a in s){n(s[a])}function f(t){if(t in r){e.player.api[t]=function(){return r[t].call(r,arguments)}}}var s=["load","getVideoPlaybackQuality","play","pause"];for(var a in s){f(s[a])}e.player.api.setSource=function(t){if(t!=l.url&&t!=""){e.player.flvPlayer.unload();e.player.flvPlayer.detachMediaElement();e.player.flvPlayer.destroy();l.url=t;e.player.create(l)}};e.player.api.unload=function(){e.player.flvPlayer.unload();e.player.flvPlayer.detachMediaElement();e.player.flvPlayer.destroy()};e.player.setSize=function(e){r.style.width=e.width+"px";r.style.height=e.height+"px"};Object.defineProperty(e.player.api,"currentTime",{get:function(){return r.currentTime},set:function(t){var o=.5;for(var a=0;a=r.buffered.start(a)&&t<=r.buffered.end(a)-o){return r.currentTime=t}}e.log("Seek attempted outside of buffer, but MistServer does not support seeking in progressive flash. Setting to closest available instead");return r.currentTime=r.buffered.length?r.buffered.end(r.buffered.length-1)-o:0}});t(r)};if("flvjs"in window){this.onFLVLoad()}else{var r=MistUtil.scripts.insert(e.urlappend(mistplayers.flv.scriptsrc(e.options.host)),{onerror:function(t){var r="Failed to load flv.js";if(t.message){r+=": "+t.message}e.showError(r)},onload:e.player.onFLVLoad},e)}}; \ No newline at end of file +mistplayers.flv={name:"HTML5 FLV Player",mimes:["flash/7"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return MistUtil.array.indexOf(this.mimes,e)==-1?false:true},isBrowserSupported:function(e,t,r){if(location.protocol!=MistUtil.http.url.split(t.url).protocol){if(location.protocol=="file:"&&MistUtil.http.url.split(t.url).protocol=="http:"){r.log("This page was loaded over file://, the player might not behave as intended.")}else{r.log("HTTP/HTTPS mismatch for this source");return false}}if(!window.MediaSource){return false}if(!MediaSource.isTypeSupported){return true}try{var o={};for(var a in r.info.meta.tracks){if(r.info.meta.tracks[a].type=="meta"){continue}if(!(r.info.meta.tracks[a].type in o)){o[r.info.meta.tracks[a].type]={}}o[r.info.meta.tracks[a].type][MistUtil.tracks.translateCodec(r.info.meta.tracks[a])]=1}var i=[];for(var l in o){var n=false;for(var s in o[l]){if(MediaSource.isTypeSupported('video/mp4;codecs="'+s+'"')){n=true;break}}if(n){i.push(l)}}t.supportedCodecs=i;return i.length?i:false}catch(e){}return false},player:function(){this.onreadylist=[]},scriptsrc:function(e){return e+"/flv.js"}};var p=mistplayers.flv.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){this.onFLVLoad=function(){if(e.destroyed){return}e.log("Building flv.js player..");var r=document.createElement("video");r.setAttribute("playsinline","");var o=["autoplay","loop","poster"];for(var a in o){var i=o[a];if(e.options[i]){r.setAttribute(i,e.options[i]===true?"":e.options[i])}}if(e.options.muted){r.muted=true}if(e.options.controls=="stock"){r.setAttribute("controls","")}if(e.info.type=="live"){r.loop=false}flvjs.LoggingControl.applyConfig({enableVerbose:false});flvjs.LoggingControl.addLogListener(function(t,r){e.log("[flvjs] "+r)});var l={type:"flv",url:e.source.url,hasAudio:false,hasVideo:false};for(var a in e.source.supportedCodecs){l["has"+e.source.supportedCodecs[a].charAt(0).toUpperCase()+e.source.supportedCodecs[a].slice(1)]=true}e.player.create=function(t){t=MistUtil.object.extend({},t);e.player.flvPlayer=flvjs.createPlayer(t,{lazyLoad:false});e.player.flvPlayer.attachMediaElement(r);e.player.flvPlayer.load();e.player.flvPlayer.play();if(!e.options.autoplay){r.pause()}};e.player.create(l);e.player.api={};function n(t){Object.defineProperty(e.player.api,t,{get:function(){return r[t]},set:function(e){return r[t]=e}})}var s=["volume","buffered","muted","loop","paused",,"error","textTracks","webkitDroppedFrameCount","webkitDecodedFrameCount"];if(e.info.type!="live"){s.push("duration")}else{Object.defineProperty(e.player.api,"duration",{get:function(){if(!r.buffered.length){return 0}return r.buffered.end(r.buffered.length-1)}})}for(var a in s){n(s[a])}function f(t){if(t in r){e.player.api[t]=function(){return r[t].call(r,arguments)}}}var s=["load","getVideoPlaybackQuality","play","pause"];for(var a in s){f(s[a])}e.player.api.setSource=function(t){if(t!=l.url&&t!=""){e.player.flvPlayer.unload();e.player.flvPlayer.detachMediaElement();e.player.flvPlayer.destroy();l.url=t;e.player.create(l)}};e.player.api.unload=function(){e.player.flvPlayer.unload();e.player.flvPlayer.detachMediaElement();e.player.flvPlayer.destroy()};e.player.setSize=function(e){r.style.width=e.width+"px";r.style.height=e.height+"px"};Object.defineProperty(e.player.api,"currentTime",{get:function(){return r.currentTime},set:function(t){var o=.5;for(var a=0;a=r.buffered.start(a)&&t<=r.buffered.end(a)-o){return r.currentTime=t}}e.log("Seek attempted outside of buffer, but MistServer does not support seeking in progressive flash. Setting to closest available instead");return r.currentTime=r.buffered.length?r.buffered.end(r.buffered.length-1)-o:0}});t(r)};if("flvjs"in window){this.onFLVLoad()}else{var r=MistUtil.scripts.insert(e.urlappend(mistplayers.flv.scriptsrc(e.options.host)),{onerror:function(t){var r="Failed to load flv.js";if(t.message){r+=": "+t.message}e.showError(r)},onload:e.player.onFLVLoad},e)}}; \ No newline at end of file diff --git a/embed/min/wrappers/hlsjs.js b/embed/min/wrappers/hlsjs.js index d13425e7..195c5883 100644 --- a/embed/min/wrappers/hlsjs.js +++ b/embed/min/wrappers/hlsjs.js @@ -1 +1 @@ -mistplayers.hlsjs={name:"HLS.js player",mimes:["html5/application/vnd.apple.mpegurl","html5/application/vnd.apple.mpegurl;version=7"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(t){return this.mimes.indexOf(t)==-1?false:true},isBrowserSupported:function(t,e,r){if(location.protocol!=MistUtil.http.url.split(e.url).protocol){r.log("HTTP/HTTPS mismatch for this source");return false}if(!("MediaSource"in window)){return false}if(!MediaSource.isTypeSupported){return true}var i={};var s=false;for(var o in r.info.meta.tracks){if(r.info.meta.tracks[o].type=="meta"){if(r.info.meta.tracks[o].codec=="subtitle"){s=true}continue}if(!(r.info.meta.tracks[o].type in i)){i[r.info.meta.tracks[o].type]={}}i[r.info.meta.tracks[o].type][MistUtil.tracks.translateCodec(r.info.meta.tracks[o])]=1}var a=[];for(var l in i){var n=false;for(var p in i[l]){if(MediaSource.isTypeSupported('video/mp4;codecs="'+p+'"')){n=true;break}}if(n){a.push(l)}}if(s){for(var o in r.info.source){if(r.info.source[o].type=="html5/text/vtt"){a.push("subtitle");break}}}return a.length?a:false},player:function(){},scriptsrc:function(t){return t+"/hlsjs.js"}};var p=mistplayers.hlsjs.player;p.prototype=new MistPlayer;p.prototype.build=function(t,e){var r=this;var i=document.createElement("video");i.setAttribute("playsinline","");var s=["autoplay","loop","poster"];for(var o in s){var a=s[o];if(t.options[a]){i.setAttribute(a,t.options[a]===true?"":t.options[a])}}if(t.options.muted){i.muted=true}if(t.info.type=="live"){i.loop=false}if(t.options.controls=="stock"){i.setAttribute("controls","")}i.setAttribute("crossorigin","anonymous");this.setSize=function(t){i.style.width=t.width+"px";i.style.height=t.height+"px"};this.api=i;t.player.api.unload=function(){if(t.player.hls){t.player.hls.destroy();t.player.hls=false;t.log("hls.js instance disposed")}};function l(e){t.player.hls=new Hls({maxBufferLength:15,maxMaxBufferLength:60});t.player.hls.attachMedia(i);t.player.hls.on(Hls.Events.MEDIA_ATTACHED,(function(){t.player.hls.loadSource(e)}))}t.player.api.setSource=function(e){if(!t.player.hls){return}if(t.player.hls.url!=e){t.player.hls.destroy();l(e)}};t.player.api.setSubtitle=function(t){var e=i.getElementsByTagName("track");for(var r=e.length-1;r>=0;r--){i.removeChild(e[r])}if(t){var s=document.createElement("track");i.appendChild(s);s.kind="subtitles";s.label=t.label;s.srclang=t.lang;s.src=t.src;s.setAttribute("default","")}};function n(){l(t.source.url)}if("Hls"in window){n()}else{var p=t.urlappend(mistplayers.hlsjs.scriptsrc(t.options.host));MistUtil.scripts.insert(p,{onerror:function(e){var r="Failed to load hlsjs.js";if(e.message){r+=": "+e.message}t.showError(r)},onload:n},t)}e(i)}; \ No newline at end of file +mistplayers.hlsjs={name:"HLS.js player",mimes:["html5/application/vnd.apple.mpegurl","html5/application/vnd.apple.mpegurl;version=7"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(t){return this.mimes.indexOf(t)==-1?false:true},isBrowserSupported:function(t,e,r){if(location.protocol!=MistUtil.http.url.split(e.url).protocol){r.log("HTTP/HTTPS mismatch for this source");return false}if(!("MediaSource"in window)){return false}if(!MediaSource.isTypeSupported){return true}var i={};var s=false;for(var o in r.info.meta.tracks){if(r.info.meta.tracks[o].type=="meta"){if(r.info.meta.tracks[o].codec=="subtitle"){s=true}continue}if(!(r.info.meta.tracks[o].type in i)){i[r.info.meta.tracks[o].type]={}}i[r.info.meta.tracks[o].type][MistUtil.tracks.translateCodec(r.info.meta.tracks[o])]=1}var a=[];for(var l in i){var n=false;for(var p in i[l]){if(MediaSource.isTypeSupported('video/mp4;codecs="'+p+'"')){n=true;break}}if(n){a.push(l)}}if(s){for(var o in r.info.source){if(r.info.source[o].type=="html5/text/vtt"){a.push("subtitle");break}}}return a.length?a:false},player:function(){},scriptsrc:function(t){return t+"/hlsjs.js"}};var p=mistplayers.hlsjs.player;p.prototype=new MistPlayer;p.prototype.build=function(t,e){var r=this;var i=document.createElement("video");i.setAttribute("playsinline","");var s=["autoplay","loop","poster"];for(var o in s){var a=s[o];if(t.options[a]){i.setAttribute(a,t.options[a]===true?"":t.options[a])}}if(t.options.muted){i.muted=true}if(t.info.type=="live"){i.loop=false}if(t.options.controls=="stock"){i.setAttribute("controls","")}i.setAttribute("crossorigin","anonymous");this.setSize=function(t){i.style.width=t.width+"px";i.style.height=t.height+"px"};this.api=i;t.player.api.unload=function(){if(t.player.hls){t.player.hls.destroy();t.player.hls=false;t.log("hls.js instance disposed")}};function l(e){t.player.hls=new Hls({maxBufferLength:15,maxMaxBufferLength:60});t.player.hls.attachMedia(i);t.player.hls.on(Hls.Events.MEDIA_ATTACHED,function(){t.player.hls.loadSource(e)})}t.player.api.setSource=function(e){if(!t.player.hls){return}if(t.player.hls.url!=e){t.player.hls.destroy();l(e)}};t.player.api.setSubtitle=function(t){var e=i.getElementsByTagName("track");for(var r=e.length-1;r>=0;r--){i.removeChild(e[r])}if(t){var s=document.createElement("track");i.appendChild(s);s.kind="subtitles";s.label=t.label;s.srclang=t.lang;s.src=t.src;s.setAttribute("default","")}};function n(){l(t.source.url)}if("Hls"in window){n()}else{var p=t.urlappend(mistplayers.hlsjs.scriptsrc(t.options.host));MistUtil.scripts.insert(p,{onerror:function(e){var r="Failed to load hlsjs.js";if(e.message){r+=": "+e.message}t.showError(r)},onload:n},t)}e(i)}; \ No newline at end of file diff --git a/embed/min/wrappers/html5.js b/embed/min/wrappers/html5.js index aa8de371..ac29029f 100644 --- a/embed/min/wrappers/html5.js +++ b/embed/min/wrappers/html5.js @@ -1 +1 @@ -mistplayers.html5={name:"HTML5 video player",mimes:["html5/application/vnd.apple.mpegurl","html5/application/vnd.apple.mpegurl;version=7","html5/video/mp4","html5/video/ogg","html5/video/webm","html5/audio/mp3","html5/audio/webm","html5/audio/ogg","html5/audio/wav"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return MistUtil.array.indexOf(this.mimes,e)==-1?false:true},isBrowserSupported:function(e,t,i){if(location.protocol!=MistUtil.http.url.split(t.url).protocol){if(location.protocol=="file:"&&MistUtil.http.url.split(t.url).protocol=="http:"){i.log("This page was loaded over file://, the player might not behave as intended.")}else{i.log("HTTP/HTTPS mismatch for this source");return false}}if(e=="html5/application/vnd.apple.mpegurl"){var r=MistUtil.getAndroid();if(r&&parseFloat(r)<7){i.log("Skipping native HLS as videojs will do better");return false}}var a=false;var n=e.split("/");n.shift();try{n=n.join("/");function o(e){if(e.codecstring){return e.codecstring}function t(t){return("0"+e.init.charCodeAt(t).toString(16)).slice(-2)}switch(e.codec){case"AAC":return"mp4a.40.2";case"MP3":return"mp4a.40.34";case"AC3":return"ec-3";case"H264":return"avc1."+t(1)+t(2)+t(3);case"HEVC":return"hev1."+t(1)+t(6)+t(7)+t(8)+t(9)+t(10)+t(11)+t(12);default:return e.codec.toLowerCase()}}var s={};var l={};var p=false;for(var u in i.info.meta.tracks){if(i.info.meta.tracks[u].type!="meta"){s[o(i.info.meta.tracks[u])]=i.info.meta.tracks[u]}else if(i.info.meta.tracks[u].codec=="subtitle"){p=true}}var f=e.split("/")[2];t.supportedCodecs=[];for(var u in s){var c=d(u);if(c){t.supportedCodecs.push(s[u].codec);l[s[u].type]=1}}function d(e){var t=document.createElement("video");if(t&&typeof t.canPlayType=="function"){var i;switch(n){case"video/webm":{i=t.canPlayType(n);break}case"video/mp4":case"html5/application/vnd.apple.mpegurl":default:{i=t.canPlayType(n+';codecs="'+e+'"');break}}if(i!=""){return i}}return false}if(p){for(var u in i.info.source){if(i.info.source[u].type=="html5/text/vtt"){l.subtitle=1;break}}}a=MistUtil.object.keys(l)}catch(m){}return a},player:function(){this.onreadylist=[]},mistControls:true};var p=mistplayers.html5.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var i=e.source.type.split("/");i.shift();var r=document.createElement("video");r.setAttribute("crossorigin","anonymous");r.setAttribute("playsinline","");var a=document.createElement("source");a.setAttribute("src",e.source.url);r.source=a;r.appendChild(a);a.type=i.join("/");var n=["autoplay","loop","poster"];for(var o in n){var s=n[o];if(e.options[s]){r.setAttribute(s,e.options[s]===true?"":e.options[s])}}if(e.options.muted){r.muted=true}if(e.options.controls=="stock"){r.setAttribute("controls","")}if(e.info.type=="live"){r.loop=false}if("Proxy"in window&&"Reflect"in window){var l={get:{},set:{}};e.player.api=new Proxy(r,{get:function(e,t,i){if(t in l.get){return l.get[t].apply(e,arguments)}var r=e[t];if(typeof r==="function"){return function(){return r.apply(e,arguments)}}return r},set:function(e,t,i){if(t in l.set){return l.set[t].call(e,i)}return e[t]=i}});if(e.source.type=="html5/audio/mp3"){l.set.currentTime=function(){e.log("Seek attempted, but MistServer does not currently support seeking in MP3.");return false}}if(e.info.type=="live"){l.get.duration=function(){var t=0;if(this.buffered.length){t=this.buffered.end(this.buffered.length-1)}var i=((new Date).getTime()-e.player.api.lastProgress.getTime())*.001;return t+i-e.player.api.liveOffset};l.set.currentTime=function(t){var i=t-e.player.api.duration;if(i>0){i=0}e.player.api.liveOffset=i;e.log("Seeking to "+MistUtil.format.time(t)+" ("+Math.round(i*-10)/10+"s from live)");var r={startunix:i};if(i==0){r={}}e.player.api.setSource(MistUtil.http.url.addParam(e.source.url,r))};MistUtil.event.addListener(r,"progress",(function(){e.player.api.lastProgress=new Date}));e.player.api.lastProgress=new Date;e.player.api.liveOffset=0;MistUtil.event.addListener(r,"pause",(function(){e.player.api.pausedAt=new Date}));l.get.play=function(){return function(){if(e.player.api.paused&&e.player.api.pausedAt&&new Date-e.player.api.pausedAt>5e3){r.load();e.log("Reloading source..")}return r.play.apply(r,arguments)}};if(e.source.type=="html5/video/mp4"){var p=l.get.duration;l.get.duration=function(){return p.apply(this,arguments)-e.player.api.liveOffset+e.info.lastms*.001};l.get.currentTime=function(){return this.currentTime-e.player.api.liveOffset+e.info.lastms*.001};l.get.buffered=function(){var t=this;return{length:t.buffered.length,start:function(i){return t.buffered.start(i)-e.player.api.liveOffset+e.info.lastms*.001},end:function(i){return t.buffered.end(i)-e.player.api.liveOffset+e.info.lastms*.001}}}}}else{if(!isFinite(r.duration)){var u=0;for(var o in e.info.meta.tracks){u=Math.max(u,e.info.meta.tracks[o].lastms)}l.get.duration=function(){if(isFinite(this.duration)){return this.duration}return u*.001}}}}else{e.player.api=r}e.player.api.setSource=function(e){if(e!=this.source.src){this.source.src=e;this.load()}};e.player.api.setSubtitle=function(e){var t=r.getElementsByTagName("track");for(var i=t.length-1;i>=0;i--){r.removeChild(t[i])}if(e){var a=document.createElement("track");r.appendChild(a);a.kind="subtitles";a.label=e.label;a.srclang=e.lang;a.src=e.src;a.setAttribute("default","")}};e.player.setSize=function(e){this.api.style.width=e.width+"px";this.api.style.height=e.height+"px"};t(r)}; \ No newline at end of file +mistplayers.html5={name:"HTML5 video player",mimes:["html5/application/vnd.apple.mpegurl","html5/application/vnd.apple.mpegurl;version=7","html5/video/mp4","html5/video/ogg","html5/video/webm","html5/audio/mp3","html5/audio/webm","html5/audio/ogg","html5/audio/wav"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return MistUtil.array.indexOf(this.mimes,e)==-1?false:true},isBrowserSupported:function(e,t,i){if(location.protocol!=MistUtil.http.url.split(t.url).protocol){if(location.protocol=="file:"&&MistUtil.http.url.split(t.url).protocol=="http:"){i.log("This page was loaded over file://, the player might not behave as intended.")}else{i.log("HTTP/HTTPS mismatch for this source");return false}}if(e=="html5/application/vnd.apple.mpegurl"){var r=MistUtil.getAndroid();if(r&&parseFloat(r)<7){i.log("Skipping native HLS as videojs will do better");return false}}var a=false;var n=e.split("/");n.shift();try{n=n.join("/");function o(e){if(e.codecstring){return e.codecstring}function t(t){return("0"+e.init.charCodeAt(t).toString(16)).slice(-2)}switch(e.codec){case"AAC":return"mp4a.40.2";case"MP3":return"mp4a.40.34";case"AC3":return"ec-3";case"H264":return"avc1."+t(1)+t(2)+t(3);case"HEVC":return"hev1."+t(1)+t(6)+t(7)+t(8)+t(9)+t(10)+t(11)+t(12);default:return e.codec.toLowerCase()}}var s={};var l={};var p=false;for(var u in i.info.meta.tracks){if(i.info.meta.tracks[u].type!="meta"){s[o(i.info.meta.tracks[u])]=i.info.meta.tracks[u]}else if(i.info.meta.tracks[u].codec=="subtitle"){p=true}}var f=e.split("/")[2];t.supportedCodecs=[];for(var u in s){var c=d(u);if(c){t.supportedCodecs.push(s[u].codec);l[s[u].type]=1}}function d(e){var t=document.createElement("video");if(t&&typeof t.canPlayType=="function"){var i;switch(n){case"video/webm":{i=t.canPlayType(n);break}case"video/mp4":case"html5/application/vnd.apple.mpegurl":default:{i=t.canPlayType(n+';codecs="'+e+'"');break}}if(i!=""){return i}}return false}if(p){for(var u in i.info.source){if(i.info.source[u].type=="html5/text/vtt"){l.subtitle=1;break}}}a=MistUtil.object.keys(l)}catch(e){}return a},player:function(){this.onreadylist=[]},mistControls:true};var p=mistplayers.html5.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var i=e.source.type.split("/");i.shift();var r=document.createElement("video");r.setAttribute("crossorigin","anonymous");r.setAttribute("playsinline","");var a=document.createElement("source");a.setAttribute("src",e.source.url);r.source=a;r.appendChild(a);a.type=i.join("/");var n=["autoplay","loop","poster"];for(var o in n){var s=n[o];if(e.options[s]){r.setAttribute(s,e.options[s]===true?"":e.options[s])}}if(e.options.muted){r.muted=true}if(e.options.controls=="stock"){r.setAttribute("controls","")}if(e.info.type=="live"){r.loop=false}if("Proxy"in window&&"Reflect"in window){var l={get:{},set:{}};e.player.api=new Proxy(r,{get:function(e,t,i){if(t in l.get){return l.get[t].apply(e,arguments)}var r=e[t];if(typeof r==="function"){return function(){return r.apply(e,arguments)}}return r},set:function(e,t,i){if(t in l.set){return l.set[t].call(e,i)}return e[t]=i}});if(e.source.type=="html5/audio/mp3"){l.set.currentTime=function(){e.log("Seek attempted, but MistServer does not currently support seeking in MP3.");return false}}if(e.info.type=="live"){l.get.duration=function(){var t=0;if(this.buffered.length){t=this.buffered.end(this.buffered.length-1)}var i=((new Date).getTime()-e.player.api.lastProgress.getTime())*.001;return t+i-e.player.api.liveOffset};l.set.currentTime=function(t){var i=t-e.player.api.duration;if(i>0){i=0}e.player.api.liveOffset=i;e.log("Seeking to "+MistUtil.format.time(t)+" ("+Math.round(i*-10)/10+"s from live)");var r={startunix:i};if(i==0){r={}}e.player.api.setSource(MistUtil.http.url.addParam(e.source.url,r))};MistUtil.event.addListener(r,"progress",function(){e.player.api.lastProgress=new Date});e.player.api.lastProgress=new Date;e.player.api.liveOffset=0;MistUtil.event.addListener(r,"pause",function(){e.player.api.pausedAt=new Date});l.get.play=function(){return function(){if(e.player.api.paused&&e.player.api.pausedAt&&new Date-e.player.api.pausedAt>5e3){r.load();e.log("Reloading source..")}return r.play.apply(r,arguments)}};if(e.source.type=="html5/video/mp4"){var p=l.get.duration;l.get.duration=function(){return p.apply(this,arguments)-e.player.api.liveOffset+e.info.lastms*.001};l.get.currentTime=function(){return this.currentTime-e.player.api.liveOffset+e.info.lastms*.001};l.get.buffered=function(){var t=this;return{length:t.buffered.length,start:function(i){return t.buffered.start(i)-e.player.api.liveOffset+e.info.lastms*.001},end:function(i){return t.buffered.end(i)-e.player.api.liveOffset+e.info.lastms*.001}}}}}else{if(!isFinite(r.duration)){var u=0;for(var o in e.info.meta.tracks){u=Math.max(u,e.info.meta.tracks[o].lastms)}l.get.duration=function(){if(isFinite(this.duration)){return this.duration}return u*.001}}}}else{e.player.api=r}e.player.api.setSource=function(e){if(e!=this.source.src){this.source.src=e;this.load()}};e.player.api.setSubtitle=function(e){var t=r.getElementsByTagName("track");for(var i=t.length-1;i>=0;i--){r.removeChild(t[i])}if(e){var a=document.createElement("track");r.appendChild(a);a.kind="subtitles";a.label=e.label;a.srclang=e.lang;a.src=e.src;a.setAttribute("default","")}};e.player.setSize=function(e){this.api.style.width=e.width+"px";this.api.style.height=e.height+"px"};t(r)}; \ No newline at end of file diff --git a/embed/min/wrappers/mews.js b/embed/min/wrappers/mews.js index ff57a3e5..194b355b 100644 --- a/embed/min/wrappers/mews.js +++ b/embed/min/wrappers/mews.js @@ -1 +1 @@ -mistplayers.mews={name:"MSE websocket player",mimes:["ws/video/mp4","ws/video/webm"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return this.mimes.indexOf(e)==-1?false:true},isBrowserSupported:function(e,t,i){if(!("WebSocket"in window)||!("MediaSource"in window)||!("Promise"in window)){return false}if(location.protocol.replace(/^http/,"ws")!=MistUtil.http.url.split(t.url.replace(/^http/,"ws")).protocol){i.log("HTTP/HTTPS mismatch for this source");return false}if(navigator.platform.toUpperCase().indexOf("MAC")>=0){return false}function r(e){if(e.codecstring){return e.codecstring}function t(t){return("0"+e.init.charCodeAt(t).toString(16)).slice(-2)}switch(e.codec){case"AAC":return"mp4a.40.2";case"MP3":return"mp4a.40.34";case"AC3":return"ec-3";case"H264":return"avc1."+t(1)+t(2)+t(3);case"HEVC":return"hev1."+t(1)+t(6)+t(7)+t(8)+t(9)+t(10)+t(11)+t(12);default:return e.codec.toLowerCase()}}var n={};var s={};var a=false;for(var o in i.info.meta.tracks){if(i.info.meta.tracks[o].type!="meta"){n[r(i.info.meta.tracks[o])]=i.info.meta.tracks[o]}else if(i.info.meta.tracks[o].codec=="subtitle"){a=true}}var u=e.split("/")[2];function d(e){return MediaSource.isTypeSupported("video/"+u+';codecs="'+e+'"')}t.supportedCodecs=[];for(var o in n){var c=d(o);if(c){t.supportedCodecs.push(n[o].codec);s[n[o].type]=1}}if(a){for(var o in i.info.source){if(i.info.source[o].type=="html5/text/vtt"){s.subtitle=1;break}}}return MistUtil.object.keys(s)},player:function(){}};var p=mistplayers.mews.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var i=document.createElement("video");i.setAttribute("playsinline","");var r=["autoplay","loop","poster"];for(var n in r){var s=r[n];if(e.options[s]){i.setAttribute(s,e.options[s]===true?"":e.options[s])}}if(e.options.muted){i.muted=true}if(e.info.type=="live"){i.loop=false}if(e.options.controls=="stock"){i.setAttribute("controls","")}i.setAttribute("crossorigin","anonymous");this.setSize=function(e){i.style.width=e.width+"px";i.style.height=e.height+"px"};var a=this;a.built=false;function o(){if(a.ws.readyState==a.ws.OPEN&&a.ms.readyState=="open"&&a.sb){if(!a.built){t(i);a.built=true}if(e.options.autoplay){a.api.play().catch((function(){}))}return true}}this.msoninit=[];this.msinit=function(){return new Promise((function(e,t){a.ms=new MediaSource;i.src=URL.createObjectURL(a.ms);a.ms.onsourceopen=function(){for(var t in a.msoninit){a.msoninit[t]()}a.msoninit=[];e()};a.ms.onsourceclose=function(e){if(a.debugging)console.error("ms close",e);u({type:"stop"})};a.ms.onsourceended=function(e){if(a.debugging)console.error("ms ended",e);if(a.debugging=="dl"){function t(e,t,r){var n,s;n=new Blob([e],{type:r});s=window.URL.createObjectURL(n);i(s,t);setTimeout((function(){return window.URL.revokeObjectURL(s)}),1e3)}function i(e,t){var i;i=document.createElement("a");i.href=e;i.download=t;document.body.appendChild(i);i.style="display: none";i.click();i.remove()}var r=0;for(var n=0;n=500){n=0;a.sb._clean(10)}else{n++}var t=r.slice();r=[];for(var s in t){if(!a.sb){if(a.debugging){console.warn("I was doing on_updateend but the sb was reset")}break}if(a.sb.updating){r.concat(t.slice(s));if(a.debugging){console.warn("I was doing on_updateend but was interrupted")}break}t[s](s0&&!a.sb.updating&&!i.error){a.sb._append(this.queue.shift())}}));a.sb.error=function(e){console.error("sb error",e)};a.sb.abort=function(e){console.error("sb abort",e)};a.sb._doNext=function(e){r.push(e)};a.sb._do=function(e){if(this.updating||this._busy){this._doNext(e)}else{e()}};a.sb._append=function(t){if(!t){return}if(!t.buffer){return}if(a.debugging){a.sb.appending=new Uint8Array(t)}if(a.sb._busy){if(a.debugging)console.warn("I wanted to append data, but now I won't because the thingy was still busy. Putting it back in the queue.");a.sb.queue.unshift(t);return}a.sb._busy=true;try{a.sb.appendBuffer(t)}catch(n){switch(n.name){case"QuotaExceededError":{if(i.buffered.length){if(i.currentTime-i.buffered.start(0)>1){e.log("Triggered QuotaExceededError: cleaning up "+Math.round((i.currentTime-i.buffered.start(0)-1)*10)/10+"s");a.sb._clean(1)}else{var r=i.buffered.end(i.buffered.length-1);e.log("Triggered QuotaExceededError but there is nothing to clean: skipping ahead "+Math.round((r-i.currentTime)*10)/10+"s");i.currentTime=r}a.sb._busy=false;a.sb._append(t);return}break}case"InvalidStateError":{a.api.pause();if(e.video.error){return}break}}e.showError(n.message)}};if(a.msgqueue){if(a.msgqueue[0]){var s=false;if(a.msgqueue[0].length){for(var u in a.msgqueue[0]){if(a.sb.updating||a.sb.queue.length||a.sb._busy){a.sb.queue.push(a.msgqueue[0][u])}else{a.sb._append(a.msgqueue[0][u])}}}else{s=true}a.msgqueue.shift();if(a.msgqueue.length==0){a.msgqueue=false}e.log("The newly initialized source buffer was filled with data from a separate message queue."+(a.msgqueue?" "+a.msgqueue.length+" more message queue(s) remain.":""));if(s){e.log("The separate message queue was empty; manually triggering any onupdateend functions");a.sb.dispatchEvent(new Event("updateend"))}}}a.sb._clean=function(e){if(!e)e=180;if(i.currentTime>e){a.sb._do((function(){a.sb.remove(0,Math.max(.1,i.currentTime-e))}))}};if(a.onsbinit.length){a.onsbinit.shift()()}o()};this.wsconnect=function(){return new Promise(function(t,r){this.ws=new WebSocket(e.source.url);this.ws.binaryType="arraybuffer";this.ws.s=this.ws.send;this.ws.send=function(){if(this.readyState==1){this.s.apply(this,arguments);return true}return false};this.ws.onopen=function(){this.wasConnected=true;t()};this.ws.onerror=function(t){e.showError("MP4 over WS: websocket error")};this.ws.onclose=function(t){e.log("MP4 over WS: websocket closed");if(this.wasConnected&&!e.destroyed&&(!a.sb||!a.sb.paused)&&e.state=="Stream is online"&&!(e.video&&e.video.error)){e.log("MP4 over WS: reopening websocket");a.wsconnect().then((function(){if(!a.sb){var t=function(e){if(!a.sb){a.sbinit(e.data.codecs)}else{a.api.play().catch((function(){}))}a.ws.removeListener("codec_data",t)};a.ws.addListener("codec_data",t);u({type:"request_codec_data",supported_codecs:e.source.supportedCodecs})}else{a.api.play()}}),(function(){Mistvideo.error("Lost connection to the Media Server")}))}};this.ws.timeOut=e.timers.start((function(){if(a.ws.readyState==0){e.log("MP4 over WS: socket timeout - try next combo");e.nextCombo()}}),5e3);this.ws.listeners={};this.ws.addListener=function(e,t){if(!(e in this.listeners)){this.listeners[e]=[]}this.listeners[e].push(t)};this.ws.removeListener=function(e,t){if(!(e in this.listeners)){return}var i=this.listeners[e].indexOf(t);if(i<0){return}this.listeners[e].splice(i,1);return true};a.msgqueue=false;var n=1;var s=[];var o=[];this.ws.onmessage=function(t){if(!t.data){throw"Received invalid data"}if(typeof t.data=="string"){var r=JSON.parse(t.data);if(a.debugging&&r.type!="on_time"){console.log("ws message",r)}switch(r.type){case"on_stop":{var s;s=MistUtil.event.addListener(i,"waiting",(function(e){a.sb.paused=true;MistUtil.event.send("ended",null,i);MistUtil.event.removeListener(s)}));a.ws.onclose=function(){};break}case"on_time":{var c=r.data.current-i.currentTime*1e3;var f=a.ws.serverDelay.get();var l=Math.max(100+f,f*2);var p=l+(r.data.jitter?r.data.jitter:0);if(e.info.type!="live"){l+=2e3}if(a.debugging){console.log("on_time received",r.data.current/1e3,"currtime",i.currentTime,n+"x","buffer",Math.round(c),"/",Math.round(l),e.info.type=="live"?"latency:"+Math.round(r.data.end-i.currentTime*1e3)+"ms":"",a.monitor?"bitrate:"+MistUtil.format.bits(a.monitor.currentBps)+"/s":"","listeners",a.ws.listeners&&a.ws.listeners.on_time?a.ws.listeners.on_time:0,"msgqueue",a.msgqueue?a.msgqueue.length:0,"readyState",e.video.readyState,r.data)}if(!a.sb){e.log("Received on_time, but the source buffer is being cleared right now. Ignoring.");break}if(d!=r.data.end*.001){d=r.data.end*.001;MistUtil.event.send("durationchange",null,e.video)}e.info.meta.buffer_window=r.data.end-r.data.begin;a.sb.paused=false;if(e.info.type=="live"){if(n==1){if(r.data.play_rate_curr=="auto"){if(i.currentTime>0){if(c>p*2){n=1+Math.min(1,(c-p)/p)*.08;i.playbackRate*=n;e.log("Our buffer ("+Math.round(c)+"ms) is big (>"+Math.round(p*2)+"ms), so increase the playback speed to "+Math.round(n*100)/100+" to catch up.")}else if(c<0){n=.8;i.playbackRate*=n;e.log("Our buffer ("+Math.round(c)+"ms) is negative so decrease the playback speed to "+Math.round(n*100)/100+" to let it catch up.")}else if(c1){if(cp){i.playbackRate/=n;n=1;e.log("Our buffer ("+Math.round(c)+"ms) is big enough (>"+Math.round(p)+"ms), so return to real time playback.")}}}else{if(n==1){if(r.data.play_rate_curr=="auto"){if(cl){e.log("Our buffer is big, so request a slower download rate.");n=.5;u({type:"set_speed",play_rate:n})}}}else if(n>1){if(c>l){u({type:"set_speed",play_rate:"auto"});n=1;e.log("The buffer is big enough, so ask for realtime download rate.")}}else{if(ct){t=r}if(!i.buffered.length||i.buffered.end(i.buffered.length-1)i.currentTime){var e=i.buffered.start(0);i.currentTime=e;if(i.currentTime!=e){n()}}}else{n()}}))};n()}}if(v(a.last_codecs?a.last_codecs:a.sb._codecs,r.data.codecs)){e.log("Player switched tracks, keeping source buffer as codecs are the same as before.");if(i.currentTime==0&&r.data.current!=0){w((r.data.current*.001).toFixed(3))}}else{if(a.debugging){console.warn("Different codecs!");console.warn("video time",i.currentTime,"switch startpoint",r.data.current*.001)}a.last_codecs=r.data.codecs;if(a.msgqueue){a.msgqueue.push([])}else{a.msgqueue=[[]]}var y=function(){if(a&&a.sb){a.sb._do((function(t){if(!a.sb.updating){if(!isNaN(a.ms.duration))a.sb.remove(0,Infinity);a.sb.queue=[];a.ms.removeSourceBuffer(a.sb);a.sb=null;i.src="";a.ms.onsourceclose=null;a.ms.onsourceended=null;if(a.debugging&&t&&t.length){console.warn("There are do_on_updateend functions queued, which I will re-apply after clearing the sb.")}a.msinit().then((function(){a.sbinit(r.data.codecs);a.sb.do_on_updateend=t;var n=MistUtil.event.addListener(i,"loadedmetadata",(function(){e.log("Buffer cleared");w((r.data.current*.001).toFixed(3));MistUtil.event.removeListener(n)}))}))}else{y()}}))}else{if(a.debugging){console.warn("sb not available to do clear")}a.onsbinit.push(y)}};if(!r.data.codecs||!r.data.codecs.length){e.showError("Track switch does not contain any codecs, aborting.");e.options.setTracks=false;y();break}function k(t){if(a.debugging){console.warn("reached switching point",t.data.current*.001,MistUtil.format.time(t.data.current*.001))}e.log("Track switch: reached switching point");y()}if(i.currentTime==0){k(r)}else{if(r.data.current>=i.currentTime*1e3){e.log("Track switch: waiting for playback to reach the switching point ("+MistUtil.format.time(r.data.current*.001,{ms:true})+")");var _=MistUtil.event.addListener(i,"timeupdate",(function(){if(r.data.current=i.currentTime*1e3){k(e);a.ws.removeListener("on_time",_)}};a.ws.addListener("on_time",_)}}}break}case"pause":{if(a.sb){a.sb.paused=true}break}}if(r.type in this.listeners){for(var g=this.listeners[r.type].length-1;g>=0;g--){this.listeners[r.type][g](r)}}return}var T=new Uint8Array(t.data);if(T){if(a.monitor&&a.monitor.bitCounter){for(var g in a.monitor.bitCounter){a.monitor.bitCounter[g]+=t.data.byteLength*8}}if(a.sb&&!a.msgqueue){if(a.sb.updating||a.sb.queue.length||a.sb._busy){a.sb.queue.push(T)}else{a.sb._append(T)}}else{if(!a.msgqueue){a.msgqueue=[[]]}a.msgqueue[a.msgqueue.length-1].push(T)}}else{e.log("Expecting data from websocket, but received none?!")}};this.ws.serverDelay={delays:[],log:function(e){var t=false;switch(e){case"seek":case"set_speed":{t=e;break}case"request_codec_data":{t="codec_data";break}default:{return}}if(t){var i=(new Date).getTime();function r(){if(!a.ws||!a.ws.serverDelay){return}a.ws.serverDelay.add((new Date).getTime()-i);a.ws.removeListener(t,r)}a.ws.addListener(t,r)}},add:function(e){this.delays.unshift(e);if(this.delays.length>5){this.delays.splice(5)}},get:function(){if(this.delays.length){let e=0;let t=0;for(null;t=3){break}e+=this.delays[t]}return e/t}return 500}}}.bind(this))};this.wsconnect().then(function(){var t=function(e){if(a.ms&&a.ms.readyState=="open"){a.sbinit(e.data.codecs)}else{a.msoninit.push((function(){a.sbinit(e.data.codecs)}))}a.ws.removeListener("codec_data",t)};this.ws.addListener("codec_data",t);u({type:"request_codec_data",supported_codecs:e.source.supportedCodecs})}.bind(this));function u(t,i){if(!a.ws){throw"No websocket to send to"}if(i>5){throw"Too many retries, giving up"}if(a.ws.readyState=a.ws.CLOSING){if(e.destroyed){return}e.log("MP4 over WS: reopening websocket");a.wsconnect().then((function(){if(!a.sb){var i=function(e){if(!a.sb){a.sbinit(e.data.codecs)}else{a.api.play().catch((function(){}))}a.ws.removeListener("codec_data",i)};a.ws.addListener("codec_data",i);u({type:"request_codec_data",supported_codecs:e.source.supportedCodecs})}else{a.api.play()}u(t)}),(function(){Mistvideo.error("Lost connection to the Media Server")}));return}if(a.debugging){console.log("ws send",t)}a.ws.serverDelay.log(t.type);if(!a.ws.send(JSON.stringify(t))){return u(t,++i)}}a.findBuffer=function(e){var t=false;for(var r=0;r=e){t=r;break}}return t};this.api={play:function(t){return new Promise((function(r,n){if(!i.paused){r();return}if("paused"in a.sb&&!a.sb.paused){i.play().then(r).catch(n);return}var s=function(o){if(!a.sb){e.log("Attempting to play, but the source buffer is being cleared. Waiting for next on_time.");return}if(e.info.type=="live"){if(t||i.currentTime==0){var u=function(){if(i.buffered.length){var t=a.findBuffer(o.data.current*.001);if(t!==false){if(i.buffered.start(t)>i.currentTime||i.buffered.end(t)i.currentTime){a.sb.paused=false;if(i.buffered.length&&i.buffered.start(0)>i.currentTime){i.currentTime=i.buffered.start(0)}i.play().then(r).catch(n);a.ws.removeListener("on_time",s)}};a.ws.addListener("on_time",s);var o={type:"play"};if(t){o.seek_time="live"}u(o)}))},pause:function(){i.pause();u({type:"hold"});if(a.sb){a.sb.paused=true}},setTracks:function(e){if(!MistUtil.object.keys(e).length){return}e.type="tracks";e=MistUtil.object.extend({type:"tracks"},e);u(e)},unload:function(){a.api.pause();a.sb._do((function(){a.sb.remove(0,Infinity);try{a.ms.endOfStream()}catch(e){}}));a.ws.close()},setSubtitle:function(e){var t=i.getElementsByTagName("track");for(var r=t.length-1;r>=0;r--){i.removeChild(t[r])}if(e){var n=document.createElement("track");i.appendChild(n);n.kind="subtitles";n.label=e.label;n.srclang=e.lang;n.src=e.src;n.setAttribute("default","")}}};Object.defineProperty(this.api,"currentTime",{get:function(){return i.currentTime},set:function(t){if(isNaN(t)||t<0){e.log("Ignoring seek to "+t+" because ewww.");return}MistUtil.event.send("seeking",t,i);u({type:"seek",seek_time:Math.round(Math.max(0,t*1e3-(250+a.ws.serverDelay.get())))});var r=function(n){a.ws.removeListener("seek",r);var s=function(r){a.ws.removeListener("on_time",s);t=r.data.current*.001;t=t.toFixed(3);var n=10;var o=function(){i.currentTime=t;if(i.currentTime.toFixed(3)=0){n--;a.sb._doNext(o)}}};o()};a.ws.addListener("on_time",s)};a.ws.addListener("seek",r);i.currentTime=t;e.log("Seeking to "+MistUtil.format.time(t,{ms:true})+" ("+t+")")}});var d=Infinity;Object.defineProperty(this.api,"duration",{get:function(){return d}});Object.defineProperty(this.api,"playbackRate",{get:function(){return i.playbackRate},set:function(e){var t=function(e){i.playbackRate=e.data.play_rate_curr};a.ws.addListener("set_speed",t);u({type:"set_speed",play_rate:e==1?"auto":e})}});function c(e){Object.defineProperty(a.api,e,{get:function(){return i[e]},set:function(t){return i[e]=t}})}var f=["volume","buffered","muted","loop","paused",,"error","textTracks","webkitDroppedFrameCount","webkitDecodedFrameCount"];for(var n in f){c(f[n])}MistUtil.event.addListener(i,"ended",(function(){if(a.api.loop){a.api.currentTime=0;a.sb._do((function(){try{a.sb.remove(0,Infinity)}catch(e){}}))}}));var l=false;MistUtil.event.addListener(i,"seeking",(function(){l=true;var e=MistUtil.event.addListener(i,"seeked",(function(){l=false;MistUtil.event.removeListener(e)}))}));MistUtil.event.addListener(i,"waiting",(function(){if(l){return}var t=a.findBuffer(i.currentTime);if(t!==false){if(t+1=i.buffered.start(r)&&i.currentTime<=i.buffered.end(r)){t=true}e.push([i.buffered.start(r),i.buffered.end(r)])}console.log("waiting","currentTime",i.currentTime,"buffers",e,t?"contained":"outside of buffer","readystate",i.readyState,"networkstate",i.networkState);if(i.readyState>=2&&i.networkState>=2){console.error("Why am I waiting?!",i.currentTime)}}))}this.ABR={size:null,bitrate:null,generateString:function(e,t){switch(e){case"size":{return"~"+[t.width,t.height].join("x")}case"bitrate":{return"<"+Math.round(t)+"bps,minbps"}default:{throw"Unknown ABR type"}}},request:function(e,t){this[e]=t;var i=[];if(this.bitrate!==null){i.push(this.generateString("bitrate",this.bitrate))}if(this.size!==null){i.push(this.generateString("size",this.size))}else{i.push("maxbps")}return a.api.setTracks({video:i.join(",|")})}};this.api.ABR_resize=function(t){e.log("Requesting the video track with the resolution that best matches the player size");a.ABR.request("size",t)};this.monitor={bitCounter:[],bitsSince:[],currentBps:null,nWaiting:0,nWaitingThreshold:3,listener:e.options.ABR_bitrate?MistUtil.event.addListener(i,"waiting",(function(){a.monitor.nWaiting++;if(a.monitor.nWaiting>=a.monitor.nWaitingThreshold){a.monitor.nWaiting=0;a.monitor.action()}})):null,getBitRate:function(){if(a.sb&&!a.sb.paused){this.bitCounter.push(0);this.bitsSince.push((new Date).getTime());var t,i;if(this.bitCounter.length>5){t=a.monitor.bitCounter.shift();i=this.bitsSince.shift()}else{t=a.monitor.bitCounter[0];i=this.bitsSince[0]}var r=(new Date).getTime()-i;this.currentBps=t/(r*.001)}e.timers.start((function(){a.monitor.getBitRate()}),500)},action:function(){if(e.options.setTracks&&e.options.setTracks.video){return}e.log("ABR threshold triggered, requesting lower quality");a.ABR.request("bitrate",this.currentBps)}};this.monitor.getBitRate()}; \ No newline at end of file +mistplayers.mews={name:"MSE websocket player",mimes:["ws/video/mp4","ws/video/webm"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return this.mimes.indexOf(e)==-1?false:true},isBrowserSupported:function(e,t,i){if(!("WebSocket"in window)||!("MediaSource"in window)||!("Promise"in window)){return false}if(location.protocol.replace(/^http/,"ws")!=MistUtil.http.url.split(t.url.replace(/^http/,"ws")).protocol){i.log("HTTP/HTTPS mismatch for this source");return false}if(navigator.platform.toUpperCase().indexOf("MAC")>=0){return false}function r(e){if(e.codecstring){return e.codecstring}function t(t){return("0"+e.init.charCodeAt(t).toString(16)).slice(-2)}switch(e.codec){case"AAC":return"mp4a.40.2";case"MP3":return"mp4a.40.34";case"AC3":return"ec-3";case"H264":return"avc1."+t(1)+t(2)+t(3);case"HEVC":return"hev1."+t(1)+t(6)+t(7)+t(8)+t(9)+t(10)+t(11)+t(12);default:return e.codec.toLowerCase()}}var n={};var s={};var a=false;for(var o in i.info.meta.tracks){if(i.info.meta.tracks[o].type!="meta"){n[r(i.info.meta.tracks[o])]=i.info.meta.tracks[o]}else if(i.info.meta.tracks[o].codec=="subtitle"){a=true}}var u=e.split("/")[2];function d(e){return MediaSource.isTypeSupported("video/"+u+';codecs="'+e+'"')}t.supportedCodecs=[];for(var o in n){var c=d(o);if(c){t.supportedCodecs.push(n[o].codec);s[n[o].type]=1}}if(a){for(var o in i.info.source){if(i.info.source[o].type=="html5/text/vtt"){s.subtitle=1;break}}}return MistUtil.object.keys(s)},player:function(){}};var p=mistplayers.mews.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var i=document.createElement("video");i.setAttribute("playsinline","");var r=["autoplay","loop","poster"];for(var n in r){var s=r[n];if(e.options[s]){i.setAttribute(s,e.options[s]===true?"":e.options[s])}}if(e.options.muted){i.muted=true}if(e.info.type=="live"){i.loop=false}if(e.options.controls=="stock"){i.setAttribute("controls","")}i.setAttribute("crossorigin","anonymous");this.setSize=function(e){i.style.width=e.width+"px";i.style.height=e.height+"px"};var a=this;a.built=false;function o(){if(a.ws.readyState==a.ws.OPEN&&a.ms.readyState=="open"&&a.sb){if(!a.built){t(i);a.built=true}if(e.options.autoplay){a.api.play().catch(function(){})}return true}}this.msoninit=[];this.msinit=function(){return new Promise(function(e,t){a.ms=new MediaSource;i.src=URL.createObjectURL(a.ms);a.ms.onsourceopen=function(){for(var t in a.msoninit){a.msoninit[t]()}a.msoninit=[];e()};a.ms.onsourceclose=function(e){if(a.debugging)console.error("ms close",e);u({type:"stop"})};a.ms.onsourceended=function(e){if(a.debugging)console.error("ms ended",e);if(a.debugging=="dl"){function t(e,t,r){var n,s;n=new Blob([e],{type:r});s=window.URL.createObjectURL(n);i(s,t);setTimeout(function(){return window.URL.revokeObjectURL(s)},1e3)}function i(e,t){var i;i=document.createElement("a");i.href=e;i.download=t;document.body.appendChild(i);i.style="display: none";i.click();i.remove()}var r=0;for(var n=0;n=500){n=0;a.sb._clean(10)}else{n++}var t=r.slice();r=[];for(var s in t){if(!a.sb){if(a.debugging){console.warn("I was doing on_updateend but the sb was reset")}break}if(a.sb.updating){r.concat(t.slice(s));if(a.debugging){console.warn("I was doing on_updateend but was interrupted")}break}t[s](s0&&!a.sb.updating&&!i.error){a.sb._append(this.queue.shift())}});a.sb.error=function(e){console.error("sb error",e)};a.sb.abort=function(e){console.error("sb abort",e)};a.sb._doNext=function(e){r.push(e)};a.sb._do=function(e){if(this.updating||this._busy){this._doNext(e)}else{e()}};a.sb._append=function(t){if(!t){return}if(!t.buffer){return}if(a.debugging){a.sb.appending=new Uint8Array(t)}if(a.sb._busy){if(a.debugging)console.warn("I wanted to append data, but now I won't because the thingy was still busy. Putting it back in the queue.");a.sb.queue.unshift(t);return}a.sb._busy=true;try{a.sb.appendBuffer(t)}catch(n){switch(n.name){case"QuotaExceededError":{if(i.buffered.length){if(i.currentTime-i.buffered.start(0)>1){e.log("Triggered QuotaExceededError: cleaning up "+Math.round((i.currentTime-i.buffered.start(0)-1)*10)/10+"s");a.sb._clean(1)}else{var r=i.buffered.end(i.buffered.length-1);e.log("Triggered QuotaExceededError but there is nothing to clean: skipping ahead "+Math.round((r-i.currentTime)*10)/10+"s");i.currentTime=r}a.sb._busy=false;a.sb._append(t);return}break}case"InvalidStateError":{a.api.pause();if(e.video.error){return}break}}e.showError(n.message)}};if(a.msgqueue){if(a.msgqueue[0]){var s=false;if(a.msgqueue[0].length){for(var u in a.msgqueue[0]){if(a.sb.updating||a.sb.queue.length||a.sb._busy){a.sb.queue.push(a.msgqueue[0][u])}else{a.sb._append(a.msgqueue[0][u])}}}else{s=true}a.msgqueue.shift();if(a.msgqueue.length==0){a.msgqueue=false}e.log("The newly initialized source buffer was filled with data from a separate message queue."+(a.msgqueue?" "+a.msgqueue.length+" more message queue(s) remain.":""));if(s){e.log("The separate message queue was empty; manually triggering any onupdateend functions");a.sb.dispatchEvent(new Event("updateend"))}}}a.sb._clean=function(e){if(!e)e=180;if(i.currentTime>e){a.sb._do(function(){a.sb.remove(0,Math.max(.1,i.currentTime-e))})}};if(a.onsbinit.length){a.onsbinit.shift()()}o()};this.wsconnect=function(){return new Promise(function(t,r){this.ws=new WebSocket(e.source.url);this.ws.binaryType="arraybuffer";this.ws.s=this.ws.send;this.ws.send=function(){if(this.readyState==1){this.s.apply(this,arguments);return true}return false};this.ws.onopen=function(){this.wasConnected=true;t()};this.ws.onerror=function(t){e.showError("MP4 over WS: websocket error")};this.ws.onclose=function(t){e.log("MP4 over WS: websocket closed");if(this.wasConnected&&!e.destroyed&&(!a.sb||!a.sb.paused)&&e.state=="Stream is online"&&!(e.video&&e.video.error)){e.log("MP4 over WS: reopening websocket");a.wsconnect().then(function(){if(!a.sb){var t=function(e){if(!a.sb){a.sbinit(e.data.codecs)}else{a.api.play().catch(function(){})}a.ws.removeListener("codec_data",t)};a.ws.addListener("codec_data",t);u({type:"request_codec_data",supported_codecs:e.source.supportedCodecs})}else{a.api.play()}},function(){Mistvideo.error("Lost connection to the Media Server")})}};this.ws.timeOut=e.timers.start(function(){if(a.ws.readyState==0){e.log("MP4 over WS: socket timeout - try next combo");e.nextCombo()}},5e3);this.ws.listeners={};this.ws.addListener=function(e,t){if(!(e in this.listeners)){this.listeners[e]=[]}this.listeners[e].push(t)};this.ws.removeListener=function(e,t){if(!(e in this.listeners)){return}var i=this.listeners[e].indexOf(t);if(i<0){return}this.listeners[e].splice(i,1);return true};a.msgqueue=false;var n=1;var s=[];var o=[];this.ws.onmessage=function(t){if(!t.data){throw"Received invalid data"}if(typeof t.data=="string"){var r=JSON.parse(t.data);if(a.debugging&&r.type!="on_time"){console.log("ws message",r)}switch(r.type){case"on_stop":{var s;s=MistUtil.event.addListener(i,"waiting",function(e){a.sb.paused=true;MistUtil.event.send("ended",null,i);MistUtil.event.removeListener(s)});a.ws.onclose=function(){};break}case"on_time":{var c=r.data.current-i.currentTime*1e3;var f=a.ws.serverDelay.get();var l=Math.max(100+f,f*2);var p=l+(r.data.jitter?r.data.jitter:0);if(e.info.type!="live"){l+=2e3}if(a.debugging){console.log("on_time received",r.data.current/1e3,"currtime",i.currentTime,n+"x","buffer",Math.round(c),"/",Math.round(l),e.info.type=="live"?"latency:"+Math.round(r.data.end-i.currentTime*1e3)+"ms":"",a.monitor?"bitrate:"+MistUtil.format.bits(a.monitor.currentBps)+"/s":"","listeners",a.ws.listeners&&a.ws.listeners.on_time?a.ws.listeners.on_time:0,"msgqueue",a.msgqueue?a.msgqueue.length:0,"readyState",e.video.readyState,r.data)}if(!a.sb){e.log("Received on_time, but the source buffer is being cleared right now. Ignoring.");break}if(d!=r.data.end*.001){d=r.data.end*.001;MistUtil.event.send("durationchange",null,e.video)}e.info.meta.buffer_window=r.data.end-r.data.begin;a.sb.paused=false;if(e.info.type=="live"){if(n==1){if(r.data.play_rate_curr=="auto"){if(i.currentTime>0){if(c>p*2){n=1+Math.min(1,(c-p)/p)*.08;i.playbackRate*=n;e.log("Our buffer ("+Math.round(c)+"ms) is big (>"+Math.round(p*2)+"ms), so increase the playback speed to "+Math.round(n*100)/100+" to catch up.")}else if(c<0){n=.8;i.playbackRate*=n;e.log("Our buffer ("+Math.round(c)+"ms) is negative so decrease the playback speed to "+Math.round(n*100)/100+" to let it catch up.")}else if(c1){if(cp){i.playbackRate/=n;n=1;e.log("Our buffer ("+Math.round(c)+"ms) is big enough (>"+Math.round(p)+"ms), so return to real time playback.")}}}else{if(n==1){if(r.data.play_rate_curr=="auto"){if(cl){e.log("Our buffer is big, so request a slower download rate.");n=.5;u({type:"set_speed",play_rate:n})}}}else if(n>1){if(c>l){u({type:"set_speed",play_rate:"auto"});n=1;e.log("The buffer is big enough, so ask for realtime download rate.")}}else{if(ct){t=r}if(!i.buffered.length||i.buffered.end(i.buffered.length-1)i.currentTime){var e=i.buffered.start(0);i.currentTime=e;if(i.currentTime!=e){n()}}}else{n()}})};n()}}if(v(a.last_codecs?a.last_codecs:a.sb._codecs,r.data.codecs)){e.log("Player switched tracks, keeping source buffer as codecs are the same as before.");if(i.currentTime==0&&r.data.current!=0){w((r.data.current*.001).toFixed(3))}}else{if(a.debugging){console.warn("Different codecs!");console.warn("video time",i.currentTime,"switch startpoint",r.data.current*.001)}a.last_codecs=r.data.codecs;if(a.msgqueue){a.msgqueue.push([])}else{a.msgqueue=[[]]}var y=function(){if(a&&a.sb){a.sb._do(function(t){if(!a.sb.updating){if(!isNaN(a.ms.duration))a.sb.remove(0,Infinity);a.sb.queue=[];a.ms.removeSourceBuffer(a.sb);a.sb=null;i.src="";a.ms.onsourceclose=null;a.ms.onsourceended=null;if(a.debugging&&t&&t.length){console.warn("There are do_on_updateend functions queued, which I will re-apply after clearing the sb.")}a.msinit().then(function(){a.sbinit(r.data.codecs);a.sb.do_on_updateend=t;var n=MistUtil.event.addListener(i,"loadedmetadata",function(){e.log("Buffer cleared");w((r.data.current*.001).toFixed(3));MistUtil.event.removeListener(n)})})}else{y()}})}else{if(a.debugging){console.warn("sb not available to do clear")}a.onsbinit.push(y)}};if(!r.data.codecs||!r.data.codecs.length){e.showError("Track switch does not contain any codecs, aborting.");e.options.setTracks=false;y();break}function k(t){if(a.debugging){console.warn("reached switching point",t.data.current*.001,MistUtil.format.time(t.data.current*.001))}e.log("Track switch: reached switching point");y()}if(i.currentTime==0){k(r)}else{if(r.data.current>=i.currentTime*1e3){e.log("Track switch: waiting for playback to reach the switching point ("+MistUtil.format.time(r.data.current*.001,{ms:true})+")");var _=MistUtil.event.addListener(i,"timeupdate",function(){if(r.data.current=i.currentTime*1e3){k(e);a.ws.removeListener("on_time",_)}};a.ws.addListener("on_time",_)}}}break}case"pause":{if(a.sb){a.sb.paused=true}break}}if(r.type in this.listeners){for(var g=this.listeners[r.type].length-1;g>=0;g--){this.listeners[r.type][g](r)}}return}var T=new Uint8Array(t.data);if(T){if(a.monitor&&a.monitor.bitCounter){for(var g in a.monitor.bitCounter){a.monitor.bitCounter[g]+=t.data.byteLength*8}}if(a.sb&&!a.msgqueue){if(a.sb.updating||a.sb.queue.length||a.sb._busy){a.sb.queue.push(T)}else{a.sb._append(T)}}else{if(!a.msgqueue){a.msgqueue=[[]]}a.msgqueue[a.msgqueue.length-1].push(T)}}else{e.log("Expecting data from websocket, but received none?!")}};this.ws.serverDelay={delays:[],log:function(e){var t=false;switch(e){case"seek":case"set_speed":{t=e;break}case"request_codec_data":{t="codec_data";break}default:{return}}if(t){var i=(new Date).getTime();function r(){if(!a.ws||!a.ws.serverDelay){return}a.ws.serverDelay.add((new Date).getTime()-i);a.ws.removeListener(t,r)}a.ws.addListener(t,r)}},add:function(e){this.delays.unshift(e);if(this.delays.length>5){this.delays.splice(5)}},get:function(){if(this.delays.length){let e=0;let t=0;for(null;t=3){break}e+=this.delays[t]}return e/t}return 500}}}.bind(this))};this.wsconnect().then(function(){var t=function(e){if(a.ms&&a.ms.readyState=="open"){a.sbinit(e.data.codecs)}else{a.msoninit.push(function(){a.sbinit(e.data.codecs)})}a.ws.removeListener("codec_data",t)};this.ws.addListener("codec_data",t);u({type:"request_codec_data",supported_codecs:e.source.supportedCodecs})}.bind(this));function u(t,i){if(!a.ws){throw"No websocket to send to"}if(i>5){throw"Too many retries, giving up"}if(a.ws.readyState=a.ws.CLOSING){if(e.destroyed){return}e.log("MP4 over WS: reopening websocket");a.wsconnect().then(function(){if(!a.sb){var i=function(e){if(!a.sb){a.sbinit(e.data.codecs)}else{a.api.play().catch(function(){})}a.ws.removeListener("codec_data",i)};a.ws.addListener("codec_data",i);u({type:"request_codec_data",supported_codecs:e.source.supportedCodecs})}else{a.api.play()}u(t)},function(){Mistvideo.error("Lost connection to the Media Server")});return}if(a.debugging){console.log("ws send",t)}a.ws.serverDelay.log(t.type);if(!a.ws.send(JSON.stringify(t))){return u(t,++i)}}a.findBuffer=function(e){var t=false;for(var r=0;r=e){t=r;break}}return t};this.api={play:function(t){return new Promise(function(r,n){if(!i.paused){r();return}if("paused"in a.sb&&!a.sb.paused){i.play().then(r).catch(n);return}var s=function(o){if(!a.sb){e.log("Attempting to play, but the source buffer is being cleared. Waiting for next on_time.");return}if(e.info.type=="live"){if(t||i.currentTime==0){var u=function(){if(i.buffered.length){var t=a.findBuffer(o.data.current*.001);if(t!==false){if(i.buffered.start(t)>i.currentTime||i.buffered.end(t)i.currentTime){a.sb.paused=false;if(i.buffered.length&&i.buffered.start(0)>i.currentTime){i.currentTime=i.buffered.start(0)}i.play().then(r).catch(n);a.ws.removeListener("on_time",s)}};a.ws.addListener("on_time",s);var o={type:"play"};if(t){o.seek_time="live"}u(o)})},pause:function(){i.pause();u({type:"hold"});if(a.sb){a.sb.paused=true}},setTracks:function(e){if(!MistUtil.object.keys(e).length){return}e.type="tracks";e=MistUtil.object.extend({type:"tracks"},e);u(e)},unload:function(){a.api.pause();a.sb._do(function(){a.sb.remove(0,Infinity);try{a.ms.endOfStream()}catch(e){}});a.ws.close()},setSubtitle:function(e){var t=i.getElementsByTagName("track");for(var r=t.length-1;r>=0;r--){i.removeChild(t[r])}if(e){var n=document.createElement("track");i.appendChild(n);n.kind="subtitles";n.label=e.label;n.srclang=e.lang;n.src=e.src;n.setAttribute("default","")}}};Object.defineProperty(this.api,"currentTime",{get:function(){return i.currentTime},set:function(t){if(isNaN(t)||t<0){e.log("Ignoring seek to "+t+" because ewww.");return}MistUtil.event.send("seeking",t,i);u({type:"seek",seek_time:Math.round(Math.max(0,t*1e3-(250+a.ws.serverDelay.get())))});var r=function(n){a.ws.removeListener("seek",r);var s=function(r){a.ws.removeListener("on_time",s);t=r.data.current*.001;t=t.toFixed(3);var n=10;var o=function(){i.currentTime=t;if(i.currentTime.toFixed(3)=0){n--;a.sb._doNext(o)}}};o()};a.ws.addListener("on_time",s)};a.ws.addListener("seek",r);i.currentTime=t;e.log("Seeking to "+MistUtil.format.time(t,{ms:true})+" ("+t+")")}});var d=Infinity;Object.defineProperty(this.api,"duration",{get:function(){return d}});Object.defineProperty(this.api,"playbackRate",{get:function(){return i.playbackRate},set:function(e){var t=function(e){i.playbackRate=e.data.play_rate_curr};a.ws.addListener("set_speed",t);u({type:"set_speed",play_rate:e==1?"auto":e})}});function c(e){Object.defineProperty(a.api,e,{get:function(){return i[e]},set:function(t){return i[e]=t}})}var f=["volume","buffered","muted","loop","paused",,"error","textTracks","webkitDroppedFrameCount","webkitDecodedFrameCount"];for(var n in f){c(f[n])}MistUtil.event.addListener(i,"ended",function(){if(a.api.loop){a.api.currentTime=0;a.sb._do(function(){try{a.sb.remove(0,Infinity)}catch(e){}})}});var l=false;MistUtil.event.addListener(i,"seeking",function(){l=true;var e=MistUtil.event.addListener(i,"seeked",function(){l=false;MistUtil.event.removeListener(e)})});MistUtil.event.addListener(i,"waiting",function(){if(l){return}var t=a.findBuffer(i.currentTime);if(t!==false){if(t+1=i.buffered.start(r)&&i.currentTime<=i.buffered.end(r)){t=true}e.push([i.buffered.start(r),i.buffered.end(r)])}console.log("waiting","currentTime",i.currentTime,"buffers",e,t?"contained":"outside of buffer","readystate",i.readyState,"networkstate",i.networkState);if(i.readyState>=2&&i.networkState>=2){console.error("Why am I waiting?!",i.currentTime)}})}this.ABR={size:null,bitrate:null,generateString:function(e,t){switch(e){case"size":{return"~"+[t.width,t.height].join("x")}case"bitrate":{return"<"+Math.round(t)+"bps,minbps"}default:{throw"Unknown ABR type"}}},request:function(e,t){this[e]=t;var i=[];if(this.bitrate!==null){i.push(this.generateString("bitrate",this.bitrate))}if(this.size!==null){i.push(this.generateString("size",this.size))}else{i.push("maxbps")}return a.api.setTracks({video:i.join(",|")})}};this.api.ABR_resize=function(t){e.log("Requesting the video track with the resolution that best matches the player size");a.ABR.request("size",t)};this.monitor={bitCounter:[],bitsSince:[],currentBps:null,nWaiting:0,nWaitingThreshold:3,listener:e.options.ABR_bitrate?MistUtil.event.addListener(i,"waiting",function(){a.monitor.nWaiting++;if(a.monitor.nWaiting>=a.monitor.nWaitingThreshold){a.monitor.nWaiting=0;a.monitor.action()}}):null,getBitRate:function(){if(a.sb&&!a.sb.paused){this.bitCounter.push(0);this.bitsSince.push((new Date).getTime());var t,i;if(this.bitCounter.length>5){t=a.monitor.bitCounter.shift();i=this.bitsSince.shift()}else{t=a.monitor.bitCounter[0];i=this.bitsSince[0]}var r=(new Date).getTime()-i;this.currentBps=t/(r*.001)}e.timers.start(function(){a.monitor.getBitRate()},500)},action:function(){if(e.options.setTracks&&e.options.setTracks.video){return}e.log("ABR threshold triggered, requesting lower quality");a.ABR.request("bitrate",this.currentBps)}};this.monitor.getBitRate()}; \ No newline at end of file diff --git a/embed/min/wrappers/rawws.js b/embed/min/wrappers/rawws.js index 042bc7a6..bf19711c 100644 --- a/embed/min/wrappers/rawws.js +++ b/embed/min/wrappers/rawws.js @@ -1 +1 @@ -mistplayers.rawws={name:"RAW to Canvas",mimes:["ws/video/raw"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return MistUtil.array.indexOf(this.mimes,e)==-1?false:true},isBrowserSupported:function(e,t,r){if(location.protocol!=MistUtil.http.url.split(t.url.replace(/^ws/,"http")).protocol){if(location.protocol=="file:"&&MistUtil.http.url.split(t.url.replace(/^ws/,"http")).protocol=="http:"){r.log("This page was loaded over file://, the player might not behave as intended.")}else{r.log("HTTP/HTTPS mismatch for this source");return false}}for(var i in r.info.meta.tracks){if(r.info.meta.tracks[i].codec=="HEVC"){return["video"]}}return false},player:function(){this.onreadylist=[]},scriptsrc:function(e){return e+"/libde265.js"}};var p=mistplayers.rawws.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var r=this;r.onDecoderLoad=function(){if(e.destroyed){return}e.log("Building rawws player..");var i={};e.player.api=i;var a=document.createElement("canvas");var n=a.getContext("2d");a.style.objectFit="contain";r.vars={};if(e.options.autoplay){r.vars.wantToPlay=true}r.dropping=false;r.frames={received:0,bitsReceived:0,decoded:0,dropped:0,behind:function(){return this.received-this.decoded-this.dropped},timestamps:{},frame2time:function(e,t){if(e in this.timestamps){if(t){for(var r in this.timestamps){if(r==e){break}delete this.timestamps[r]}}return this.timestamps[e]*.001}return 0},history:{log:[],add:function(){this.log.unshift({time:(new Date).getTime(),received:r.frames.received,bitsReceived:r.frames.bitsReceived,decoded:r.frames.decoded});if(this.log.length>3){this.log.splice(3)}}},framerate_in:function(){var e=this.history.log.length-1;if(e<1){return 0}var t=this.history.log[0].received-this.history.log[e].received;var r=(this.history.log[0].time-this.history.log[e].time)*.001;return t/r},bitrate_in:function(){var e=this.history.log.length-1;if(e<1){return 0}var t=this.history.log[0].bitsReceived-this.history.log[e].bitsReceived;var r=(this.history.log[0].time-this.history.log[e].time)*.001;return t/r},framerate_out:function(){var e=this.history.log.length-1;if(e<1){return 0}var t=this.history.log[0].decoded-this.history.log[e].decoded;var r=(this.history.log[0].time-this.history.log[e].time)*.001;return t/r},framerate:function(){if("rate_theoretical"in this){return this.rate_theoretical}return this.framerate_in()},keepingUp:function(){var e=this.history.log.length-1;if(e<1){return 0}var t=this.history.log[e].received-this.history.log[e].decoded-(this.history.log[0].received-this.history.log[0].decoded);var r=(this.history.log[0].time-this.history.log[e].time)*.001;var i=t/r;return i/this.framerate()}};i.framerate_in=function(){return r.frames.framerate_in()};i.framerate_out=function(){return r.frames.framerate_out()};i.currentBps=function(){return r.frames.bitrate_in()};i.loop=e.options.loop;Object.defineProperty(e.player.api,"webkitDecodedFrameCount",{get:function(){return r.frames.decoded}});Object.defineProperty(e.player.api,"webkitDroppedFrameCount",{get:function(){return r.frames.dropped}});var s;this.decoder=null;function o(e){MistUtil.event.send(e,undefined,a)}function d(){function i(){s=new libde265.Decoder;e.player.decoder=s;var t=[];s.addListener=function(e){t.push(e)};s.removeListener=function(e){var r=t.indexOf(e);if(r<0){return}t.splice(r,1);return true};var i;if(window.requestAnimationFrame){i=function(e){s.pending_image_data=e;window.requestAnimationFrame((function(){if(s.pending_image_data){n.putImageData(s.pending_image_data,0,0);s.pending_image_data=null}}))}}else{i=function(e){n.putImageData(e,0,0)}}s.set_image_callback((function(d){r.frames.decoded++;if(r.vars.wantToPlay&&r.state!="seeking"){o("timeupdate")}if(!s.image_data){var l=d.get_width();var p=d.get_height();if(l!=a.width||p!=a.height||!this.image_data){a.width=l;a.height=p;var f=n.createImageData(l,p);s.image_data=f}}if(r.state!="seeking"){d.display(this.image_data,(function(e){s.decoding=false;i(e)}))}d.free();switch(r.state){case"play":case"waiting":{if(!r.dropping){o("canplay");o("playing");r.state="playing";if(!r.vars.wantToPlay){e.player.send({type:"hold"})}}break}case"seeking":{var c=r.frames.frame2time(r.frames.decoded+r.frames.dropped);if(c>=r.vars.seekTo){o("seeked");r.vars.seekTo=null;r.state="playing";if(!r.vars.wantToPlay){o("timeupdate");e.player.send({type:"hold"})}}break}default:{r.state="playing"}}for(var u in t){t[u]()}}))}i();function d(e){return!!e[1]}function l(e){var t=new DataView(new ArrayBuffer(8));for(var r=0;r<8;r++){t.setUint8(r,e[r+2])}return t.getInt32(4)}function p(){o("loadstart");var i=MistUtil.http.url.addParam(e.source.url,{buffer:0,video:"hevc,|minbps"});var n=new WebSocket(i);e.player.ws=n;n.binaryType="arraybuffer";function f(t){if(!e.player.ws){throw"No websocket to send to"}if(n.readyState==1){n.send(JSON.stringify(t))}return false}e.player.send=f;n.wasConnected=false;n.onopen=function(){if(!e.player.built){e.player.built=true;t(a)}f({type:"request_codec_data",supported_codecs:["HEVC"]});n.wasConnected=true};n.onclose=function(){if(this.wasConnected&&!e.destroyed&&e.state=="Stream is online"){e.log("Raw over WS: reopening websocket");p(i)}else{e.showError("Raw over WS: websocket closed")}};n.onerror=function(t){e.showError("Raw over WS: websocket error")};n.onmessage=function(t){if(typeof t.data=="string"){var i=JSON.parse(t.data);switch(i.type){case"on_time":{r.vars.paused=false;r.frames.history.add();if(r.vars.duration!=i.data.end*.001){r.vars.duration=i.data.end*.001;o("durationchange")}break}case"seek":{e.player.frames.timestamps={};if(e.player.dropping){e.log("Emptying drop queue for seek");e.player.frames.dropped+=e.player.dropping.length;e.player.dropping=[]}break}case"codec_data":{o("loadedmetadata");f({type:"play"});r.state="play";break}case"info":{var a=e.info.meta.tracks;var p;for(var c in a){if(a[c].idx==i.data.tracks[0]){p=a[c];break}}if(typeof p!=undefined&&p.fpks>0){r.frames.rate_theoretical=p.fpks*.001}break}case"pause":{r.vars.paused=i.paused;if(i.paused){r.decoder.flush();o("pause")}break}case"on_stop":{if(r.state=="ended"){return}r.state="ended";r.vars.paused=true;n.onclose=function(){};n.close();r.decoder.flush();o("ended");break}default:{}}}else{r.frames.received++;r.frames.bitsReceived+=t.data.byteLength*8;var u=12;var h=new Uint8Array(t.data.slice(0,u));var m=new Uint8Array(t.data.slice(u,t.data.byteLength));r.frames.timestamps[r.frames.received]=l(h);function y(t,i){setTimeout((function(){if(r.dropping){if(r.state!="waiting"){o("waiting");r.state="waiting"}if(d(i)){if(r.dropping.length){r.frames.dropped+=r.dropping.length;e.log("Dropped "+r.dropping.length+" frames");r.dropping=[]}else{e.log("Caught up! no longer dropping");r.dropping=false}}else{r.dropping.push([i,t]);if(!s.decoding){var a=r.dropping.shift();e.player.process(a[1],a[0])}return}}else{if(r.frames.behind()>20){r.dropping=[];e.log("Falling behind, dropping files..")}}e.player.process(t,i)}),0)}y(m,h)}};n.listeners={};n.addListener=function(e,t){if(!(e in this.listeners)){this.listeners[e]=[]}this.listeners[e].push(t)};n.removeListener=function(e,t){if(!(e in this.listeners)){return}var r=this.listeners[e].indexOf(t);if(r<0){return}this.listeners[e].splice(r,1);return true}}e.player.connect=p;e.player.process=function(e,t){s.decoding=true;var i=s.push_data(e);if(r.state=="play"){o("loadeddata");r.state="waiting"}if(r.vars.wantToPlay&&r.state!="seeking"){o("progress")}function n(e){if(e==0){return}if(e==libde265.DE265_ERROR_WAITING_FOR_INPUT_DATA){r.state="waiting";return}if(!libde265.de265_isOK(e)){a.error="Decode error: "+libde265.de265_get_error_text(e);o("error");return true}}if(!n(i)){s.decode(n)}else{s.free()}};p()}d();function l(t){Object.defineProperty(e.player.api,t,{get:function(){return r.vars[t]},set:function(e){return r.vars[t]=e}})}var p=["duration","paused","error"];for(var f in p){l(p[f])}i.play=function(){return new Promise((function(t,a){r.vars.wantToPlay=true;var n=function(){t();e.player.decoder.removeListener(n)};e.player.decoder.addListener(n);if(e.player.ws.readyState>e.player.ws.OPEN){e.player.connect();e.log("Websocket was closed: reconnecting to resume playback");return}if(i.paused)e.player.send({type:"play"});r.state="play"}))};i.pause=function(){r.vars.wantToPlay=false;e.player.send({type:"hold"})};e.player.api.unload=function(){if(e.player.ws){e.player.ws.onclose=function(){};e.player.ws.close()}if(e.player.decoder){e.player.decoder.push_data=function(){};e.player.decoder.flush();e.player.decoder.free()}};e.player.setSize=function(e){a.style.width=e.width+"px";a.style.height=e.height+"px"};Object.defineProperty(e.player.api,"currentTime",{get:function(){var e=r.frames.decoded+r.frames.dropped;if(r.state=="seeking"){return r.vars.seekTo}if(e in r.frames.timestamps){return r.frames.frame2time(e)}return 0},set:function(t){o("seeking");r.state="seeking";r.vars.seekTo=t;e.player.send({type:"seek",seek_time:t*1e3});return t}});Object.defineProperty(e.player.api,"buffered",{get:function(){return{start:function(e){if(this.length&&e==0){return r.frames.frame2time(r.frames.decoded+r.frames.dropped)}},end:function(e){if(this.length&&e==0){return r.frames.frame2time(r.frames.received)}},length:r.frames.received-r.frames.decoded>0?1:0}}});if(e.info.type!="live"){MistUtil.event.addListener(a,"ended",(function(){if(r.api.loop){r.api.play();r.api.currentTime=0}}))}};if("libde265"in window){this.onDecoderLoad()}else{var i=MistUtil.scripts.insert(e.urlappend(mistplayers.rawws.scriptsrc(e.options.host)),{onerror:function(t){var r="Failed to load H265 decoder";if(t.message){r+=": "+t.message}e.showError(r)},onload:e.player.onDecoderLoad},e)}}; \ No newline at end of file +mistplayers.rawws={name:"RAW to Canvas",mimes:["ws/video/raw"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return MistUtil.array.indexOf(this.mimes,e)==-1?false:true},isBrowserSupported:function(e,t,r){if(location.protocol!=MistUtil.http.url.split(t.url.replace(/^ws/,"http")).protocol){if(location.protocol=="file:"&&MistUtil.http.url.split(t.url.replace(/^ws/,"http")).protocol=="http:"){r.log("This page was loaded over file://, the player might not behave as intended.")}else{r.log("HTTP/HTTPS mismatch for this source");return false}}for(var i in r.info.meta.tracks){if(r.info.meta.tracks[i].codec=="HEVC"){return["video"]}}return false},player:function(){this.onreadylist=[]},scriptsrc:function(e){return e+"/libde265.js"}};var p=mistplayers.rawws.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var r=this;r.onDecoderLoad=function(){if(e.destroyed){return}e.log("Building rawws player..");var i={};e.player.api=i;var a=document.createElement("canvas");var n=a.getContext("2d");a.style.objectFit="contain";r.vars={};if(e.options.autoplay){r.vars.wantToPlay=true}r.dropping=false;r.frames={received:0,bitsReceived:0,decoded:0,dropped:0,behind:function(){return this.received-this.decoded-this.dropped},timestamps:{},frame2time:function(e,t){if(e in this.timestamps){if(t){for(var r in this.timestamps){if(r==e){break}delete this.timestamps[r]}}return this.timestamps[e]*.001}return 0},history:{log:[],add:function(){this.log.unshift({time:(new Date).getTime(),received:r.frames.received,bitsReceived:r.frames.bitsReceived,decoded:r.frames.decoded});if(this.log.length>3){this.log.splice(3)}}},framerate_in:function(){var e=this.history.log.length-1;if(e<1){return 0}var t=this.history.log[0].received-this.history.log[e].received;var r=(this.history.log[0].time-this.history.log[e].time)*.001;return t/r},bitrate_in:function(){var e=this.history.log.length-1;if(e<1){return 0}var t=this.history.log[0].bitsReceived-this.history.log[e].bitsReceived;var r=(this.history.log[0].time-this.history.log[e].time)*.001;return t/r},framerate_out:function(){var e=this.history.log.length-1;if(e<1){return 0}var t=this.history.log[0].decoded-this.history.log[e].decoded;var r=(this.history.log[0].time-this.history.log[e].time)*.001;return t/r},framerate:function(){if("rate_theoretical"in this){return this.rate_theoretical}return this.framerate_in()},keepingUp:function(){var e=this.history.log.length-1;if(e<1){return 0}var t=this.history.log[e].received-this.history.log[e].decoded-(this.history.log[0].received-this.history.log[0].decoded);var r=(this.history.log[0].time-this.history.log[e].time)*.001;var i=t/r;return i/this.framerate()}};i.framerate_in=function(){return r.frames.framerate_in()};i.framerate_out=function(){return r.frames.framerate_out()};i.currentBps=function(){return r.frames.bitrate_in()};i.loop=e.options.loop;Object.defineProperty(e.player.api,"webkitDecodedFrameCount",{get:function(){return r.frames.decoded}});Object.defineProperty(e.player.api,"webkitDroppedFrameCount",{get:function(){return r.frames.dropped}});var s;this.decoder=null;function o(e){MistUtil.event.send(e,undefined,a)}function d(){function i(){s=new libde265.Decoder;e.player.decoder=s;var t=[];s.addListener=function(e){t.push(e)};s.removeListener=function(e){var r=t.indexOf(e);if(r<0){return}t.splice(r,1);return true};var i;if(window.requestAnimationFrame){i=function(e){s.pending_image_data=e;window.requestAnimationFrame(function(){if(s.pending_image_data){n.putImageData(s.pending_image_data,0,0);s.pending_image_data=null}})}}else{i=function(e){n.putImageData(e,0,0)}}s.set_image_callback(function(d){r.frames.decoded++;if(r.vars.wantToPlay&&r.state!="seeking"){o("timeupdate")}if(!s.image_data){var l=d.get_width();var p=d.get_height();if(l!=a.width||p!=a.height||!this.image_data){a.width=l;a.height=p;var f=n.createImageData(l,p);s.image_data=f}}if(r.state!="seeking"){d.display(this.image_data,function(e){s.decoding=false;i(e)})}d.free();switch(r.state){case"play":case"waiting":{if(!r.dropping){o("canplay");o("playing");r.state="playing";if(!r.vars.wantToPlay){e.player.send({type:"hold"})}}break}case"seeking":{var c=r.frames.frame2time(r.frames.decoded+r.frames.dropped);if(c>=r.vars.seekTo){o("seeked");r.vars.seekTo=null;r.state="playing";if(!r.vars.wantToPlay){o("timeupdate");e.player.send({type:"hold"})}}break}default:{r.state="playing"}}for(var u in t){t[u]()}})}i();function d(e){return!!e[1]}function l(e){var t=new DataView(new ArrayBuffer(8));for(var r=0;r<8;r++){t.setUint8(r,e[r+2])}return t.getInt32(4)}function p(){o("loadstart");var i=MistUtil.http.url.addParam(e.source.url,{buffer:0,video:"hevc,|minbps"});var n=new WebSocket(i);e.player.ws=n;n.binaryType="arraybuffer";function f(t){if(!e.player.ws){throw"No websocket to send to"}if(n.readyState==1){n.send(JSON.stringify(t))}return false}e.player.send=f;n.wasConnected=false;n.onopen=function(){if(!e.player.built){e.player.built=true;t(a)}f({type:"request_codec_data",supported_codecs:["HEVC"]});n.wasConnected=true};n.onclose=function(){if(this.wasConnected&&!e.destroyed&&e.state=="Stream is online"){e.log("Raw over WS: reopening websocket");p(i)}else{e.showError("Raw over WS: websocket closed")}};n.onerror=function(t){e.showError("Raw over WS: websocket error")};n.onmessage=function(t){if(typeof t.data=="string"){var i=JSON.parse(t.data);switch(i.type){case"on_time":{r.vars.paused=false;r.frames.history.add();if(r.vars.duration!=i.data.end*.001){r.vars.duration=i.data.end*.001;o("durationchange")}break}case"seek":{e.player.frames.timestamps={};if(e.player.dropping){e.log("Emptying drop queue for seek");e.player.frames.dropped+=e.player.dropping.length;e.player.dropping=[]}break}case"codec_data":{o("loadedmetadata");f({type:"play"});r.state="play";break}case"info":{var a=e.info.meta.tracks;var p;for(var c in a){if(a[c].idx==i.data.tracks[0]){p=a[c];break}}if(typeof p!=undefined&&p.fpks>0){r.frames.rate_theoretical=p.fpks*.001}break}case"pause":{r.vars.paused=i.paused;if(i.paused){r.decoder.flush();o("pause")}break}case"on_stop":{if(r.state=="ended"){return}r.state="ended";r.vars.paused=true;n.onclose=function(){};n.close();r.decoder.flush();o("ended");break}default:{}}}else{r.frames.received++;r.frames.bitsReceived+=t.data.byteLength*8;var u=12;var h=new Uint8Array(t.data.slice(0,u));var m=new Uint8Array(t.data.slice(u,t.data.byteLength));r.frames.timestamps[r.frames.received]=l(h);function y(t,i){setTimeout(function(){if(r.dropping){if(r.state!="waiting"){o("waiting");r.state="waiting"}if(d(i)){if(r.dropping.length){r.frames.dropped+=r.dropping.length;e.log("Dropped "+r.dropping.length+" frames");r.dropping=[]}else{e.log("Caught up! no longer dropping");r.dropping=false}}else{r.dropping.push([i,t]);if(!s.decoding){var a=r.dropping.shift();e.player.process(a[1],a[0])}return}}else{if(r.frames.behind()>20){r.dropping=[];e.log("Falling behind, dropping files..")}}e.player.process(t,i)},0)}y(m,h)}};n.listeners={};n.addListener=function(e,t){if(!(e in this.listeners)){this.listeners[e]=[]}this.listeners[e].push(t)};n.removeListener=function(e,t){if(!(e in this.listeners)){return}var r=this.listeners[e].indexOf(t);if(r<0){return}this.listeners[e].splice(r,1);return true}}e.player.connect=p;e.player.process=function(e,t){s.decoding=true;var i=s.push_data(e);if(r.state=="play"){o("loadeddata");r.state="waiting"}if(r.vars.wantToPlay&&r.state!="seeking"){o("progress")}function n(e){if(e==0){return}if(e==libde265.DE265_ERROR_WAITING_FOR_INPUT_DATA){r.state="waiting";return}if(!libde265.de265_isOK(e)){a.error="Decode error: "+libde265.de265_get_error_text(e);o("error");return true}}if(!n(i)){s.decode(n)}else{s.free()}};p()}d();function l(t){Object.defineProperty(e.player.api,t,{get:function(){return r.vars[t]},set:function(e){return r.vars[t]=e}})}var p=["duration","paused","error"];for(var f in p){l(p[f])}i.play=function(){return new Promise(function(t,a){r.vars.wantToPlay=true;var n=function(){t();e.player.decoder.removeListener(n)};e.player.decoder.addListener(n);if(e.player.ws.readyState>e.player.ws.OPEN){e.player.connect();e.log("Websocket was closed: reconnecting to resume playback");return}if(i.paused)e.player.send({type:"play"});r.state="play"})};i.pause=function(){r.vars.wantToPlay=false;e.player.send({type:"hold"})};e.player.api.unload=function(){if(e.player.ws){e.player.ws.onclose=function(){};e.player.ws.close()}if(e.player.decoder){e.player.decoder.push_data=function(){};e.player.decoder.flush();e.player.decoder.free()}};e.player.setSize=function(e){a.style.width=e.width+"px";a.style.height=e.height+"px"};Object.defineProperty(e.player.api,"currentTime",{get:function(){var e=r.frames.decoded+r.frames.dropped;if(r.state=="seeking"){return r.vars.seekTo}if(e in r.frames.timestamps){return r.frames.frame2time(e)}return 0},set:function(t){o("seeking");r.state="seeking";r.vars.seekTo=t;e.player.send({type:"seek",seek_time:t*1e3});return t}});Object.defineProperty(e.player.api,"buffered",{get:function(){return{start:function(e){if(this.length&&e==0){return r.frames.frame2time(r.frames.decoded+r.frames.dropped)}},end:function(e){if(this.length&&e==0){return r.frames.frame2time(r.frames.received)}},length:r.frames.received-r.frames.decoded>0?1:0}}});if(e.info.type!="live"){MistUtil.event.addListener(a,"ended",function(){if(r.api.loop){r.api.play();r.api.currentTime=0}})}};if("libde265"in window){this.onDecoderLoad()}else{var i=MistUtil.scripts.insert(e.urlappend(mistplayers.rawws.scriptsrc(e.options.host)),{onerror:function(t){var r="Failed to load H265 decoder";if(t.message){r+=": "+t.message}e.showError(r)},onload:e.player.onDecoderLoad},e)}}; \ No newline at end of file diff --git a/embed/min/wrappers/videojs.js b/embed/min/wrappers/videojs.js index 94d5d939..94fde146 100644 --- a/embed/min/wrappers/videojs.js +++ b/embed/min/wrappers/videojs.js @@ -1 +1 @@ -mistplayers.videojs={name:"VideoJS player",mimes:["html5/application/vnd.apple.mpegurl","html5/application/vnd.apple.mpegurl;version=7"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return MistUtil.array.indexOf(this.mimes,e)==-1?false:true},isBrowserSupported:function(e,t,r){if(location.protocol!=MistUtil.http.url.split(t.url).protocol){r.log("HTTP/HTTPS mismatch for this source");return false}if(location.protocol=="file:"&&e=="html5/application/vnd.apple"){r.log("This source ("+e+") won't load if the page is run via file://");return false}function i(e){if(!MediaSource.isTypeSupported){return true}var t={};var i=false;for(var o in r.info.meta.tracks){if(r.info.meta.tracks[o].type=="meta"){if(r.info.meta.tracks[o].codec=="subtitle"){i=true}continue}if(!(r.info.meta.tracks[o].type in t)){t[r.info.meta.tracks[o].type]={}}t[r.info.meta.tracks[o].type][MistUtil.tracks.translateCodec(r.info.meta.tracks[o])]=1}var s=[];for(var a in t){var n=false;for(var l in t[a]){if(MediaSource.isTypeSupported(e+';codecs="'+l+'"')){n=true;break}}if(n){s.push(a)}}if(i){for(var o in r.info.source){if(r.info.source[o].type=="html5/text/vtt"){s.push("subtitle");break}}}return s.length?s:false}if(document.createElement("video").canPlayType(e.replace("html5/",""))){if(!("MediaSource"in window)){return true}if(!MediaSource.isTypeSupported){return true}return i(e.replace("html5/",""))}if(!("MediaSource"in window)){return false}return i("video/mp4")},player:function(){},scriptsrc:function(e){return e+"/videojs.js"}};var p=mistplayers.videojs.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var r=this;var i;function o(){if(e.destroyed){return}e.log("Building VideoJS player..");i=document.createElement("video");if(e.source.type!="html5/video/ogg"){i.crossOrigin="anonymous"}i.setAttribute("playsinline","");var o=e.source.type.split("/");if(o[0]=="html5"){o.shift()}var s=document.createElement("source");s.setAttribute("src",e.source.url);r.source=s;i.appendChild(s);s.type=o.join("/");e.log("Adding "+s.type+" source @ "+e.source.url);MistUtil.class.add(i,"video-js");var a={};if(e.options.autoplay){a.autoplay=true}if(e.options.loop&&e.info.type!="live"){i.setAttribute("loop","")}if(e.options.muted){i.setAttribute("muted","")}if(e.options.poster){a.poster=e.options.poster}if(e.options.controls=="stock"){i.setAttribute("controls","");if(!document.getElementById("videojs-css")){var n=document.createElement("link");n.rel="stylesheet";n.href=e.options.host+"/skins/videojs.css";n.id="videojs-css";document.head.appendChild(n)}}else{a.controls=false}var l=MistUtil.event.addListener(i,"error",(function(t){t.stopImmediatePropagation();var r=t.message;if(!r&&i.error){if("code"in i.error&&i.error.code){r="Code "+i.error.code;for(var o in i.error){if(o=="code"){continue}if(i.error[o]==i.error.code){r=o;break}}}else{r=JSON.stringify(i.error)}}e.log("Error captured and stopped because videojs has not yet loaded: "+r)}));function d(){var e=navigator.userAgent.toLowerCase().match(/android\s([\d\.]*)/i);return e?e[1]:false}var p=MistUtil.getAndroid();if(p&&parseFloat(p)<7){e.log("Detected android < 7: instructing videojs to override native playback");a.html5={hls:{overrideNative:true}};a.nativeAudioTracks=false;a.nativeVideoTracks=false}r.onready((function(){e.log("Building videojs");r.videojs=videojs(i,a,(function(){MistUtil.event.removeListener(l);e.log("Videojs initialized");if(e.info.type=="live"){MistUtil.event.addListener(i,"progress",(function(t){var r=e.player.videojs.seekable().length-1;e.info.meta.buffer_window=(Math.max(e.player.videojs.seekable().end(r),i.duration)-e.player.videojs.seekable().start(r))*1e3}))}}));MistUtil.event.addListener(i,"error",(function(t){if(t&&t.target&&t.target.error&&t.target.error.message&&MistUtil.array.indexOf(t.target.error.message,"NS_ERROR_DOM_MEDIA_OVERFLOW_ERR")>=0){e.timers.start((function(){e.log("Reloading player because of NS_ERROR_DOM_MEDIA_OVERFLOW_ERR");e.reload()}),1e3)}}));r.api.unload=function(){if(r.videojs){r.videojs.autoplay(false);r.videojs.pause();r.videojs.dispose();r.videojs=false;e.log("Videojs instance disposed")}}}));e.log("Built html");if("Proxy"in window&&"Reflect"in window){var u={get:{},set:{}};e.player.api=new Proxy(i,{get:function(e,t,r){if(t in u.get){return u.get[t].apply(e,arguments)}var i=e[t];if(typeof i==="function"){return function(){return i.apply(e,arguments)}}return i},set:function(e,t,r){if(t in u.set){return u.set[t].call(e,r)}return e[t]=r}});e.player.api.load=function(){};u.set.currentTime=function(t){e.player.videojs.currentTime(t)};var f=0;var c=Infinity;for(var v in e.info.meta.tracks){f=Math.max(f,e.info.meta.tracks[v].lastms);c=Math.min(c,e.info.meta.tracks[v].firstms)}var y=c*.001;u.get.duration=function(){if(e.info){var t=i.duration;return t+y}return 0};MistUtil.event.addListener(i,"progress",(function(){e.player.api.lastProgress=new Date}));u.set.currentTime=function(t){var r=e.player.api.currentTime-t;var i=t-e.player.api.duration;e.log("Seeking to "+MistUtil.format.time(t)+" ("+Math.round(i*-10)/10+"s from live)");e.player.videojs.currentTime(e.video.currentTime-r)};u.get.currentTime=function(){var t=e.player.videojs?e.player.videojs.currentTime():i.currentTime;if(isNaN(t)){return 0}return t+y};u.get.buffered=function(){var t=e.player.videojs?e.player.videojs.buffered():i.buffered;return{length:t.length,start:function(e){return t.start(e)+y},end:function(e){return t.end(e)+y}}};if(e.info.type=="live"){e.player.api.lastProgress=new Date;e.player.api.liveOffset=0}}else{r.api=i}e.player.setSize=function(t){if("videojs"in e.player){e.player.videojs.dimensions(t.width,t.height);i.parentNode.style.width=t.width+"px";i.parentNode.style.height=t.height+"px"}this.api.style.width=t.width+"px";this.api.style.height=t.height+"px"};e.player.api.setSource=function(t){if(!e.player.videojs){return}if(e.player.videojs.src()!=t){e.player.videojs.src({type:e.player.videojs.currentSource().type,src:t})}};e.player.api.setSubtitle=function(e){var t=i.getElementsByTagName("track");for(var r=t.length-1;r>=0;r--){i.removeChild(t[r])}if(e){var o=document.createElement("track");i.appendChild(o);o.kind="subtitles";o.label=e.label;o.srclang=e.lang;o.src=e.src;o.setAttribute("default","")}};if(e.info.type=="live"){var m=MistUtil.event.addListener(i,"loadstart",(function(e){MistUtil.event.removeListener(m);MistUtil.event.send("canplay",false,this)}));var g=MistUtil.event.addListener(i,"canplay",(function(e){if(m){MistUtil.event.removeListener(m)}MistUtil.event.removeListener(g)}))}t(i)}if("videojs"in window){o()}else{var s=false;function a(){try{e.video.pause()}catch(e){}e.showError("Error in videojs player");if(!window.mistplayer_videojs_failures){window.mistplayer_videojs_failures=1;e.reload()}else{if(!s){var t=.05*Math.pow(2,window.mistplayer_videojs_failures);e.log("Rate limiter activated: MistPlayer reload delayed by "+Math.round(t*10)/10+" seconds.","error");s=e.timers.start((function(){s=false;delete window.videojs;e.reload()}),t*1e3);window.mistplayer_videojs_failures++}}}var n=e.urlappend(mistplayers.videojs.scriptsrc(e.options.host));var l;var d=function(e,t,r,i,o){if(!l){return}if(t==l.src){window.removeEventListener("error",d);a()}return false};window.addEventListener("error",d);l=MistUtil.scripts.insert(n,{onerror:function(t){var r="Failed to load videojs.js";if(t.message){r+=": "+t.message}e.showError(r)},onload:o},e)}}; \ No newline at end of file +mistplayers.videojs={name:"VideoJS player",mimes:["html5/application/vnd.apple.mpegurl","html5/application/vnd.apple.mpegurl;version=7"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return MistUtil.array.indexOf(this.mimes,e)==-1?false:true},isBrowserSupported:function(e,t,r){if(location.protocol!=MistUtil.http.url.split(t.url).protocol){r.log("HTTP/HTTPS mismatch for this source");return false}if(location.protocol=="file:"&&e=="html5/application/vnd.apple"){r.log("This source ("+e+") won't load if the page is run via file://");return false}function i(e){if(!MediaSource.isTypeSupported){return true}var t={};var i=false;for(var o in r.info.meta.tracks){if(r.info.meta.tracks[o].type=="meta"){if(r.info.meta.tracks[o].codec=="subtitle"){i=true}continue}if(!(r.info.meta.tracks[o].type in t)){t[r.info.meta.tracks[o].type]={}}t[r.info.meta.tracks[o].type][MistUtil.tracks.translateCodec(r.info.meta.tracks[o])]=1}var s=[];for(var a in t){var n=false;for(var l in t[a]){if(MediaSource.isTypeSupported(e+';codecs="'+l+'"')){n=true;break}}if(n){s.push(a)}}if(i){for(var o in r.info.source){if(r.info.source[o].type=="html5/text/vtt"){s.push("subtitle");break}}}return s.length?s:false}if(document.createElement("video").canPlayType(e.replace("html5/",""))){if(!("MediaSource"in window)){return true}if(!MediaSource.isTypeSupported){return true}return i(e.replace("html5/",""))}if(!("MediaSource"in window)){return false}return i("video/mp4")},player:function(){},scriptsrc:function(e){return e+"/videojs.js"}};var p=mistplayers.videojs.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var r=this;var i;function o(){if(e.destroyed){return}e.log("Building VideoJS player..");i=document.createElement("video");if(e.source.type!="html5/video/ogg"){i.crossOrigin="anonymous"}i.setAttribute("playsinline","");var o=e.source.type.split("/");if(o[0]=="html5"){o.shift()}var s=document.createElement("source");s.setAttribute("src",e.source.url);r.source=s;i.appendChild(s);s.type=o.join("/");e.log("Adding "+s.type+" source @ "+e.source.url);MistUtil.class.add(i,"video-js");var a={};if(e.options.autoplay){a.autoplay=true}if(e.options.loop&&e.info.type!="live"){i.setAttribute("loop","")}if(e.options.muted){i.setAttribute("muted","")}if(e.options.poster){a.poster=e.options.poster}if(e.options.controls=="stock"){i.setAttribute("controls","");if(!document.getElementById("videojs-css")){var n=document.createElement("link");n.rel="stylesheet";n.href=e.options.host+"/skins/videojs.css";n.id="videojs-css";document.head.appendChild(n)}}else{a.controls=false}var l=MistUtil.event.addListener(i,"error",function(t){t.stopImmediatePropagation();var r=t.message;if(!r&&i.error){if("code"in i.error&&i.error.code){r="Code "+i.error.code;for(var o in i.error){if(o=="code"){continue}if(i.error[o]==i.error.code){r=o;break}}}else{r=JSON.stringify(i.error)}}e.log("Error captured and stopped because videojs has not yet loaded: "+r)});function d(){var e=navigator.userAgent.toLowerCase().match(/android\s([\d\.]*)/i);return e?e[1]:false}var p=MistUtil.getAndroid();if(p&&parseFloat(p)<7){e.log("Detected android < 7: instructing videojs to override native playback");a.html5={hls:{overrideNative:true}};a.nativeAudioTracks=false;a.nativeVideoTracks=false}r.onready(function(){e.log("Building videojs");r.videojs=videojs(i,a,function(){MistUtil.event.removeListener(l);e.log("Videojs initialized");if(e.info.type=="live"){MistUtil.event.addListener(i,"progress",function(t){var r=e.player.videojs.seekable().length-1;e.info.meta.buffer_window=(Math.max(e.player.videojs.seekable().end(r),i.duration)-e.player.videojs.seekable().start(r))*1e3})}});MistUtil.event.addListener(i,"error",function(t){if(t&&t.target&&t.target.error&&t.target.error.message&&MistUtil.array.indexOf(t.target.error.message,"NS_ERROR_DOM_MEDIA_OVERFLOW_ERR")>=0){e.timers.start(function(){e.log("Reloading player because of NS_ERROR_DOM_MEDIA_OVERFLOW_ERR");e.reload()},1e3)}});r.api.unload=function(){if(r.videojs){r.videojs.autoplay(false);r.videojs.pause();r.videojs.dispose();r.videojs=false;e.log("Videojs instance disposed")}}});e.log("Built html");if("Proxy"in window&&"Reflect"in window){var u={get:{},set:{}};e.player.api=new Proxy(i,{get:function(e,t,r){if(t in u.get){return u.get[t].apply(e,arguments)}var i=e[t];if(typeof i==="function"){return function(){return i.apply(e,arguments)}}return i},set:function(e,t,r){if(t in u.set){return u.set[t].call(e,r)}return e[t]=r}});e.player.api.load=function(){};u.set.currentTime=function(t){e.player.videojs.currentTime(t)};var f=0;var c=Infinity;for(var v in e.info.meta.tracks){f=Math.max(f,e.info.meta.tracks[v].lastms);c=Math.min(c,e.info.meta.tracks[v].firstms)}var y=c*.001;u.get.duration=function(){if(e.info){var t=i.duration;return t+y}return 0};MistUtil.event.addListener(i,"progress",function(){e.player.api.lastProgress=new Date});u.set.currentTime=function(t){var r=e.player.api.currentTime-t;var i=t-e.player.api.duration;e.log("Seeking to "+MistUtil.format.time(t)+" ("+Math.round(i*-10)/10+"s from live)");e.player.videojs.currentTime(e.video.currentTime-r)};u.get.currentTime=function(){var t=e.player.videojs?e.player.videojs.currentTime():i.currentTime;if(isNaN(t)){return 0}return t+y};u.get.buffered=function(){var t=e.player.videojs?e.player.videojs.buffered():i.buffered;return{length:t.length,start:function(e){return t.start(e)+y},end:function(e){return t.end(e)+y}}};if(e.info.type=="live"){e.player.api.lastProgress=new Date;e.player.api.liveOffset=0}}else{r.api=i}e.player.setSize=function(t){if("videojs"in e.player){e.player.videojs.dimensions(t.width,t.height);i.parentNode.style.width=t.width+"px";i.parentNode.style.height=t.height+"px"}this.api.style.width=t.width+"px";this.api.style.height=t.height+"px"};e.player.api.setSource=function(t){if(!e.player.videojs){return}if(e.player.videojs.src()!=t){e.player.videojs.src({type:e.player.videojs.currentSource().type,src:t})}};e.player.api.setSubtitle=function(e){var t=i.getElementsByTagName("track");for(var r=t.length-1;r>=0;r--){i.removeChild(t[r])}if(e){var o=document.createElement("track");i.appendChild(o);o.kind="subtitles";o.label=e.label;o.srclang=e.lang;o.src=e.src;o.setAttribute("default","")}};if(e.info.type=="live"){var m=MistUtil.event.addListener(i,"loadstart",function(e){MistUtil.event.removeListener(m);MistUtil.event.send("canplay",false,this)});var g=MistUtil.event.addListener(i,"canplay",function(e){if(m){MistUtil.event.removeListener(m)}MistUtil.event.removeListener(g)})}t(i)}if("videojs"in window){o()}else{var s=false;function a(){try{e.video.pause()}catch(e){}e.showError("Error in videojs player");if(!window.mistplayer_videojs_failures){window.mistplayer_videojs_failures=1;e.reload()}else{if(!s){var t=.05*Math.pow(2,window.mistplayer_videojs_failures);e.log("Rate limiter activated: MistPlayer reload delayed by "+Math.round(t*10)/10+" seconds.","error");s=e.timers.start(function(){s=false;delete window.videojs;e.reload()},t*1e3);window.mistplayer_videojs_failures++}}}var n=e.urlappend(mistplayers.videojs.scriptsrc(e.options.host));var l;var d=function(e,t,r,i,o){if(!l){return}if(t==l.src){window.removeEventListener("error",d);a()}return false};window.addEventListener("error",d);l=MistUtil.scripts.insert(n,{onerror:function(t){var r="Failed to load videojs.js";if(t.message){r+=": "+t.message}e.showError(r)},onload:o},e)}}; \ No newline at end of file diff --git a/embed/min/wrappers/webrtc.js b/embed/min/wrappers/webrtc.js index 7eb8dc20..916e8cd6 100644 --- a/embed/min/wrappers/webrtc.js +++ b/embed/min/wrappers/webrtc.js @@ -1 +1 @@ -mistplayers.webrtc={name:"WebRTC player",mimes:["webrtc"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return this.mimes.indexOf(e)==-1?false:true},isBrowserSupported:function(e,t,n){if(!("WebSocket"in window)||(!("RTCPeerConnection"in window)||!("RTCRtpReceiver"in window))){return false}if(location.protocol.replace(/^http/,"ws")!=MistUtil.http.url.split(t.url.replace(/^http/,"ws")).protocol){n.log("HTTP/HTTPS mismatch for this source");return false}var i={};var r=false;for(var s in n.info.meta.tracks){if(n.info.meta.tracks[s].type=="meta"){if(n.info.meta.tracks[s].codec=="subtitle"){r=true}continue}if(!(n.info.meta.tracks[s].type in i)){i[n.info.meta.tracks[s].type]={}}i[n.info.meta.tracks[s].type][n.info.meta.tracks[s].codec]=1}var o=[];for(var a in i){var c=false;for(var l in i[a]){var f=RTCRtpReceiver.getCapabilities(a).codecs;for(var s in f){if(f[s].mimeType.toLowerCase()==(a+"/"+l).toLowerCase()){c=true;break}}}if(c){o.push(a)}}if(r){for(var s in n.info.source){if(n.info.source[s].type=="html5/text/vtt"){o.push("subtitle");break}}}return o.length?o:false},player:function(){}};var p=mistplayers.webrtc.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var n=this;if(typeof WebRTCBrowserEqualizerLoaded=="undefined"||!WebRTCBrowserEqualizerLoaded){var i=document.createElement("script");i.src=e.urlappend(e.options.host+"/webrtc.js");e.log("Retrieving webRTC browser equalizer code from "+i.src);document.head.appendChild(i);i.onerror=function(){e.showError("Failed to load webrtc browser equalizer",{nextCombo:5})};i.onload=function(){n.build(e,t)};return}var r=document.createElement("video");r.setAttribute("playsinline","");var s=["autoplay","loop","poster"];for(var o in s){var a=s[o];if(e.options[a]){r.setAttribute(a,e.options[a]===true?"":e.options[a])}}if(e.options.muted){r.muted=true}if(e.info.type=="live"){r.loop=false}if(e.options.controls=="stock"){r.setAttribute("controls","")}r.setAttribute("crossorigin","anonymous");this.setSize=function(e){r.style.width=e.width+"px";r.style.height=e.height+"px"};MistUtil.event.addListener(r,"loadeddata",b);MistUtil.event.addListener(r,"seeked",b);if(!e.options.autoplay){MistUtil.event.addListener(r,"canplay",(function(){var t=MistUtil.event.addListener(r,"play",(function(){e.log("Pausing because autoplay is disabled");var i=MistUtil.event.addListener(r,"pause",(function(){e.options.autoplay=false;MistUtil.event.removeListener(i)}));n.api.pause();MistUtil.event.removeListener(t)}))}))}var c=0;var l=false;var f=[];this.listeners={on_connected:function(){c=0;l=false;this.webrtc.play();MistUtil.event.send("webrtc_connected",null,r)},on_disconnected:function(){MistUtil.event.send("webrtc_disconnected",null,r);e.log("Websocket sent on_disconnect");if(!l){r.pause()}},on_answer_sdp:function(t){if(!t.result){e.showError("Failed to open stream.");this.on_disconnected();return}e.log("SDP answer received")},on_time:function(t){var n=c;c=t.current*.001-r.currentTime;if(Math.abs(n-c)>1){b()}if((!("paused"in t)||!t.paused)&&r.paused){r.play()}var i=t.end==0?Infinity:t.end*.001;if(i!=p){p=i;MistUtil.event.send("durationchange",i,r)}e.info.meta.buffer_window=t.end-t.begin;if(t.tracks&&f!=t.tracks){var s=e.info?MistUtil.tracks.parse(e.info.meta.tracks):[];for(var o in t.tracks){if(f.indexOf(t.tracks[o])<0){var a;for(var l in s){if(t.tracks[o]in s[l]){a=l;break}}if(!a){continue}if(a=="subtitle"){continue}MistUtil.event.send("playerUpdate_trackChanged",{type:a,trackid:t.tracks[o]},e.video)}}f=t.tracks}if(e.reporting&&t.tracks){e.reporting.stats.d.tracks=t.tracks.join(",")}},seek:function(e){var t=this;MistUtil.event.send("seeked",c,r);if(e.live_point){t.webrtc.playbackrate("auto")}if("seekPromise"in this.webrtc.signaling){r.play().then((function(){if("seekPromise"in t.webrtc.signaling){t.webrtc.signaling.seekPromise.resolve("Play promise resolved")}})).catch((function(){if("seekPromise"in t.webrtc.signaling){t.webrtc.signaling.seekPromise.reject("Play promise rejected")}}))}else{r.play()}},set_speed:function(e){this.webrtc.play_rate=e.play_rate_curr;MistUtil.event.send("ratechange",e,r)},on_stop:function(){e.log("Websocket sent on_stop");r.pause();MistUtil.event.send("ended",null,r);l=true}};function u(){this.peerConn=null;this.localOffer=null;this.isConnected=false;this.isConnecting=false;this.play_rate="auto";var t=this;this.on_event=function(i){switch(i.type){case"on_connected":{t.isConnected=true;t.isConnecting=false;break}case"on_answer_sdp":{t.peerConn.setRemoteDescription({type:"answer",sdp:i.answer_sdp}).then((function(){}),(function(e){console.error(e)}));break}case"on_disconnected":{t.isConnected=false;break}case"on_error":{e.showError("WebRTC error: "+MistUtil.format.ucFirst(i.message));return;break}}if(i.type in n.listeners){return n.listeners[i.type].call(n,"data"in i?i.data:i)}e.log("Unhandled WebRTC event "+i.type+": "+JSON.stringify(i));return false};this.connect=function(n){t.isConnecting=true;e.container.setAttribute("data-loading","connecting");function i(e){var t=new Promise((function(t,n){function i(e){try{var r=RTCRtpReceiver.getCapabilities("video");for(var s=0;s0){setTimeout((function(){i(e-1)}),100)}else{n("H264 not found :(")}}catch(e){t("Checker unavailable")}}i(e)}));return t}i(5).catch((function(){e.log("Beware: this device does not seem to be able to play H264.")})).finally((function(){t.signaling=new d(t.on_event);var i={};if(e.options.RTCIceServers){i.iceServers=e.options.RTCIceServers}else if(e.source.RTCIceServers){i.iceServers=e.source.RTCIceServers}t.peerConn=new RTCPeerConnection(i);t.MetaDataTrack=t.peerConn.createDataChannel("*",{protocol:"JSON"});t.peerConn.ontrack=function(e){r.srcObject=e.streams[0];if(n){n()}};t.peerConn.ondatachannel=function(){console.warn("ondatachannel",arguments)};t.peerConn.onconnectionstatechange=function(t){if(e.destroyed){return}switch(this.connectionState){case"failed":{e.log("UDP connection failed, trying next combo.","error");e.nextCombo();break}case"connected":{e.container.removeAttribute("data-loading")}case"disconnected":case"closed":case"new":case"connecting":default:{e.log("WebRTC connection state changed to "+this.connectionState);break}}};t.peerConn.oniceconnectionstatechange=function(t){if(e.destroyed){return}switch(this.iceConnectionState){case"failed":{e.showError("ICE connection "+this.iceConnectionState);break}case"disconnected":case"closed":case"new":case"checking":case"connected":case"completed":default:{e.log("WebRTC ICE connection state changed to "+this.iceConnectionState);break}}};MistUtil.event.send("webrtc_ready",null,r)}))};this.play=function(){if(!this.isConnected){throw"Not connected, cannot play"}this.peerConn.createOffer({offerToReceiveAudio:true,offerToReceiveVideo:true}).then((function(e){t.localOffer=e;t.peerConn.setLocalDescription(e).then((function(){t.signaling.sendOfferSDP(t.localOffer.sdp)}),(function(e){console.error(e)}))}),(function(e){throw e}))};this.stop=function(){if(!this.isConnected){throw"Not connected, cannot stop."}this.signaling.send({type:"stop"})};this.seek=function(n){var i=new Promise((function(i,r){if(!t.isConnected||!t.signaling){if(t.isConnecting){var s=MistUtil.event.addListener(e.video,"loadstart",(function(){t.seek(n);MistUtil.event.removeListener(s)}));return r("Not connected yet, will seek once connected")}else{return r("Failed seek: not connected")}}t.signaling.send({type:"seek",seek_time:n=="live"?"live":n*1e3});if("seekPromise"in t.signaling){t.signaling.seekPromise.reject("Doing new seek")}t.signaling.seekPromise={resolve:function(e){i("seeked");delete t.signaling.seekPromise},reject:function(e){r("Failed to seek: "+e);delete t.signaling.seekPromise}}}));return i};this.pause=function(){if(!this.isConnected){throw"Not connected, cannot pause."}this.signaling.send({type:"hold"})};this.setTrack=function(e){if(!this.isConnected){throw"Not connected, cannot set track."}e.type="tracks";this.signaling.send(e)};this.playbackrate=function(e){if(typeof e=="undefined"){return n.webrtc.play_rate=="auto"?1:n.webrtc.play_rate}if(!this.isConnected){throw"Not connected, cannot change playback rate."}this.signaling.send({type:"set_speed",play_rate:e})};this.getStats=function(e){this.peerConn.getStats().then((function(t){var n={};var i=Array.from(t.entries());for(var r in i){var s=i[r];if(s[1].type=="inbound-rtp"){n[s[0]]=s[1]}}e(n)}))};this.connect()}function d(t){this.ws=null;this.ws=new WebSocket(e.source.url.replace(/^http/,"ws"));var n=false;this.ws.onopen=function(){t({type:"on_connected"})};this.ws.timeOut=e.timers.start((function(){if(e.player.webrtc.signaling.ws.readyState==0){e.log("WebRTC: socket timeout - try next combo");e.nextCombo()}}),5e3);this.ws.onmessage=function(e){try{var n=JSON.parse(e.data);t(n)}catch(t){console.error("Failed to parse a response from MistServer",t,e.data)}};this.ws.onclose=function(e){switch(e.code){case 1006:{}default:{t({type:"on_disconnected",code:e.code});break}}};this.sendOfferSDP=function(e){this.send({type:"offer_sdp",offer_sdp:e})};this.send=function(e){if(!this.ws){throw"Not initialized, cannot send "+JSON.stringify(e)}this.ws.send(JSON.stringify(e))}}this.webrtc=new u;this.api={};var p;Object.defineProperty(this.api,"duration",{get:function(){return p}});Object.defineProperty(this.api,"currentTime",{get:function(){return c+r.currentTime},set:function(e){c=e-r.currentTime;r.pause();var t=n.webrtc.seek(e);MistUtil.event.send("seeking",e,r);if(t){t.catch((function(e){}))}}});Object.defineProperty(this.api,"playbackRate",{get:function(){return n.webrtc.playbackrate()},set:function(e){return n.webrtc.playbackrate(e)}});function h(e){Object.defineProperty(n.api,e,{get:function(){return r[e]},set:function(t){return r[e]=t}})}var v=["volume","muted","loop","paused",,"error","textTracks","webkitDroppedFrameCount","webkitDecodedFrameCount"];for(var o in v){h(v[o])}function g(e){if(e in r){n.api[e]=function(){return r[e].call(r,arguments)}}}var v=["load","getVideoPlaybackQuality"];for(var o in v){g(v[o])}n.api.play=function(){var t;if(n.api.currentTime){t=n.api.currentTime}if(e.info&&e.info.type=="live"){t="live"}if(t){var i=new Promise((function(i,r){if(!n.webrtc.isConnected&&n.webrtc.peerConn.iceConnectionState!="completed"){if(!n.webrtc.isConnecting){e.log("Received call to play while not connected, connecting "+n.webrtc.peerConn.iceConnectionState);n.webrtc.connect((function(){n.webrtc.seek(t).then((function(e){i("played "+e)})).catch((function(e){r(e)}))}))}else{r("Still connecting")}}else{n.webrtc.seek(t).then((function(e){i("played "+e)})).catch((function(e){r(e)}))}}));return i}else{return r.play()}};n.api.getStats=function(){if(n.webrtc&&n.webrtc.isConnected){return new Promise((function(e,t){n.webrtc.peerConn.getStats().then((function(t){var n={audio:null,video:null};var i=Object.fromEntries(t);for(var r in i){if(i[r].type=="track"){n[i[r].kind]=i[r]}}e(n)}))}))}};n.api.getLatency=function(){var t=e.player.api.getStats();if(t){return new Promise((function(e,i){t.then((function(t){setTimeout((function(){var r=n.api.getStats();if(!r){i();return}r.then((function(n){var i={};for(var r in t){i[r]=t[r]&&n[r]?(n[r].jitterBufferDelay-t[r].jitterBufferDelay)/(n[r].jitterBufferEmittedCount-t[r].jitterBufferEmittedCount):null}e(i)}),i)}),1e3)}),i)}))}};n.api.pause=function(){r.pause();try{n.webrtc.pause()}catch(e){}MistUtil.event.send("paused",null,r)};n.api.setTracks=function(e){if(n.webrtc.isConnected){n.webrtc.setTrack(e)}else{var t=function(){n.webrtc.setTrack(e);MistUtil.event.removeListener({type:"webrtc_connected",callback:t,element:r})};MistUtil.event.addListener(r,"webrtc_connected",t)}};function b(){if(!n.api.textTracks[0]){return}var e=n.api.textTracks[0].currentOffset||0;if(Math.abs(c-e)<1){return}var t=[];for(var i=n.api.textTracks[0].cues.length-1;i>=0;i--){var r=n.api.textTracks[0].cues[i];n.api.textTracks[0].removeCue(r);if(!("orig"in r)){r.orig={start:r.startTime,end:r.endTime}}r.startTime=r.orig.start-c;r.endTime=r.orig.end-c;t.push(r)}for(var i in t){n.api.textTracks[0].addCue(t[i])}n.api.textTracks[0].currentOffset=c}n.api.setSubtitle=function(e){var t=r.getElementsByTagName("track");for(var n=t.length-1;n>=0;n--){r.removeChild(t[n])}if(e){var i=document.createElement("track");r.appendChild(i);i.kind="subtitles";i.label=e.label;i.srclang=e.lang;i.src=e.src;i.setAttribute("default","");i.onload=b}};n.api.metaTrackSocket=function(){this.origin={};this.CONNECTING=0;this.OPEN=1;this.CLOSING=2;this.CLOSED=3;this.readyState=0;this.listeners=[];var t=this;MistUtil.event.addListener(e.video,"webrtc_ready",(function(){t.init()}));this.init=function(){this.origin=e.player.webrtc&&e.player.webrtc.MetaDataTrack?e.player.webrtc.MetaDataTrack:{};if("readyState"in this.origin){function n(){t.readyState=t.OPEN;t.onopen()}this.origin.addEventListener("open",n);this.origin.onmessage=function(e){};this.origin.addEventListener("close",(function(){t.readyState=t.CLOSED;t.onclose()}));if(this.origin.readyState=="open"){n()}return true}else{return false}};this.open=function(){if(this.readyState==this.OPEN)return;switch(this.origin.readyState){case"connecting":{this.readyState=this.CONNECTING;break}case"open":{this.readyState=this.OPEN;break}case"closing":{this.readyState=this.CLOSING;break}case"closed":{this.readyState=this.CLOSED;break}}for(var e in this.listeners){this.origin.addEventListener.apply(this.origin,this.listeners[e])}};this.close=function(){if(this.readyState>=this.CLOSING)return;this.readyState=this.CLOSED;for(var e in this.listeners){this.removeEventListener.apply(this,this.listeners[e])}};this.send=function(){if(this.origin.readyState=="open")return this.origin.send.apply(this,arguments);return false};this.onopen=function(){};this.onclose=function(){};this.addEventListener=function(){this.listeners.push(arguments);return this.origin.addEventListener.apply(this.origin,arguments)};this.removeEventListener=function(e,t){for(var n=this.listeners.length-1;n>=0;n--){if(e==this.listeners[n][0]&&t==this.listeners[n][1]){this.listeners.splice(n,1);break}}return this.origin.removeEventListener.apply(this.origin,arguments)};this.init();return this};MistUtil.event.addListener(r,"ended",(function(){if(n.api.loop){if(e.state=="Stream is online"){n.webrtc.connect()}}}));if("decodingIssues"in e.skin.blueprints){var y=["nackCount","pliCount","packetsLost","packetsReceived","bytesReceived"];for(var w in y){n.api[y[w]]=0}var k=function(){e.timers.start((function(){n.webrtc.getStats((function(e){for(var t in e){for(var i in y){if(y[i]in e[t]){n.api[y[i]]=e[t][y[i]]}}break}}));k()}),1e3)};k()}n.api.ABR_resize=function(t){e.log("Requesting the video track with the resolution that best matches the player size");n.api.setTracks({video:"~"+[t.width,t.height].join("x")})};n.api.unload=function(){try{n.webrtc.stop();n.webrtc.signaling.ws.close();n.webrtc.peerConn.close()}catch(e){}};t(r)}; \ No newline at end of file +mistplayers.webrtc={name:"WebRTC player",mimes:["webrtc"],priority:MistUtil.object.keys(mistplayers).length+1,isMimeSupported:function(e){return this.mimes.indexOf(e)==-1?false:true},isBrowserSupported:function(e,t,n){if(!("WebSocket"in window)||(!("RTCPeerConnection"in window)||!("RTCRtpReceiver"in window))){return false}if(location.protocol.replace(/^http/,"ws")!=MistUtil.http.url.split(t.url.replace(/^http/,"ws")).protocol){n.log("HTTP/HTTPS mismatch for this source");return false}var i={};var r=false;for(var s in n.info.meta.tracks){if(n.info.meta.tracks[s].type=="meta"){if(n.info.meta.tracks[s].codec=="subtitle"){r=true}continue}if(!(n.info.meta.tracks[s].type in i)){i[n.info.meta.tracks[s].type]={}}i[n.info.meta.tracks[s].type][n.info.meta.tracks[s].codec]=1}var o=[];for(var a in i){var c=false;for(var l in i[a]){var f=RTCRtpReceiver.getCapabilities(a).codecs;for(var s in f){if(f[s].mimeType.toLowerCase()==(a+"/"+l).toLowerCase()){c=true;break}}}if(c){o.push(a)}}if(r){for(var s in n.info.source){if(n.info.source[s].type=="html5/text/vtt"){o.push("subtitle");break}}}return o.length?o:false},player:function(){}};var p=mistplayers.webrtc.player;p.prototype=new MistPlayer;p.prototype.build=function(e,t){var n=this;if(typeof WebRTCBrowserEqualizerLoaded=="undefined"||!WebRTCBrowserEqualizerLoaded){var i=document.createElement("script");i.src=e.urlappend(e.options.host+"/webrtc.js");e.log("Retrieving webRTC browser equalizer code from "+i.src);document.head.appendChild(i);i.onerror=function(){e.showError("Failed to load webrtc browser equalizer",{nextCombo:5})};i.onload=function(){n.build(e,t)};return}var r=document.createElement("video");r.setAttribute("playsinline","");var s=["autoplay","loop","poster"];for(var o in s){var a=s[o];if(e.options[a]){r.setAttribute(a,e.options[a]===true?"":e.options[a])}}if(e.options.muted){r.muted=true}if(e.info.type=="live"){r.loop=false}if(e.options.controls=="stock"){r.setAttribute("controls","")}r.setAttribute("crossorigin","anonymous");this.setSize=function(e){r.style.width=e.width+"px";r.style.height=e.height+"px"};MistUtil.event.addListener(r,"loadeddata",b);MistUtil.event.addListener(r,"seeked",b);if(!e.options.autoplay){MistUtil.event.addListener(r,"canplay",function(){var t=MistUtil.event.addListener(r,"play",function(){e.log("Pausing because autoplay is disabled");var i=MistUtil.event.addListener(r,"pause",function(){e.options.autoplay=false;MistUtil.event.removeListener(i)});n.api.pause();MistUtil.event.removeListener(t)})})}var c=0;var l=false;var f=[];this.listeners={on_connected:function(){c=0;l=false;this.webrtc.play();MistUtil.event.send("webrtc_connected",null,r)},on_disconnected:function(){MistUtil.event.send("webrtc_disconnected",null,r);e.log("Websocket sent on_disconnect");if(!l){r.pause()}},on_answer_sdp:function(t){if(!t.result){e.showError("Failed to open stream.");this.on_disconnected();return}e.log("SDP answer received")},on_time:function(t){var n=c;c=t.current*.001-r.currentTime;if(Math.abs(n-c)>1){b()}if((!("paused"in t)||!t.paused)&&r.paused){r.play()}var i=t.end==0?Infinity:t.end*.001;if(i!=p){p=i;MistUtil.event.send("durationchange",i,r)}e.info.meta.buffer_window=t.end-t.begin;if(t.tracks&&f!=t.tracks){var s=e.info?MistUtil.tracks.parse(e.info.meta.tracks):[];for(var o in t.tracks){if(f.indexOf(t.tracks[o])<0){var a;for(var l in s){if(t.tracks[o]in s[l]){a=l;break}}if(!a){continue}if(a=="subtitle"){continue}MistUtil.event.send("playerUpdate_trackChanged",{type:a,trackid:t.tracks[o]},e.video)}}f=t.tracks}if(e.reporting&&t.tracks){e.reporting.stats.d.tracks=t.tracks.join(",")}},seek:function(e){var t=this;MistUtil.event.send("seeked",c,r);if(e.live_point){t.webrtc.playbackrate("auto")}if("seekPromise"in this.webrtc.signaling){r.play().then(function(){if("seekPromise"in t.webrtc.signaling){t.webrtc.signaling.seekPromise.resolve("Play promise resolved")}}).catch(function(){if("seekPromise"in t.webrtc.signaling){t.webrtc.signaling.seekPromise.reject("Play promise rejected")}})}else{r.play()}},set_speed:function(e){this.webrtc.play_rate=e.play_rate_curr;MistUtil.event.send("ratechange",e,r)},on_stop:function(){e.log("Websocket sent on_stop");r.pause();MistUtil.event.send("ended",null,r);l=true}};function u(){this.peerConn=null;this.localOffer=null;this.isConnected=false;this.isConnecting=false;this.play_rate="auto";var t=this;this.on_event=function(i){switch(i.type){case"on_connected":{t.isConnected=true;t.isConnecting=false;break}case"on_answer_sdp":{t.peerConn.setRemoteDescription({type:"answer",sdp:i.answer_sdp}).then(function(){},function(e){console.error(e)});break}case"on_disconnected":{t.isConnected=false;break}case"on_error":{e.showError("WebRTC error: "+MistUtil.format.ucFirst(i.message));return;break}}if(i.type in n.listeners){return n.listeners[i.type].call(n,"data"in i?i.data:i)}e.log("Unhandled WebRTC event "+i.type+": "+JSON.stringify(i));return false};this.connect=function(n){t.isConnecting=true;e.container.setAttribute("data-loading","connecting");function i(e){var t=new Promise(function(t,n){function i(e){try{var r=RTCRtpReceiver.getCapabilities("video");for(var s=0;s0){setTimeout(function(){i(e-1)},100)}else{n("H264 not found :(")}}catch(e){t("Checker unavailable")}}i(e)});return t}i(5).catch(function(){e.log("Beware: this device does not seem to be able to play H264.")}).finally(function(){t.signaling=new d(t.on_event);var i={};if(e.options.RTCIceServers){i.iceServers=e.options.RTCIceServers}else if(e.source.RTCIceServers){i.iceServers=e.source.RTCIceServers}t.peerConn=new RTCPeerConnection(i);t.MetaDataTrack=t.peerConn.createDataChannel("*",{protocol:"JSON"});t.peerConn.ontrack=function(e){r.srcObject=e.streams[0];if(n){n()}};t.peerConn.ondatachannel=function(){console.warn("ondatachannel",arguments)};t.peerConn.onconnectionstatechange=function(t){if(e.destroyed){return}switch(this.connectionState){case"failed":{e.log("UDP connection failed, trying next combo.","error");e.nextCombo();break}case"connected":{e.container.removeAttribute("data-loading")}case"disconnected":case"closed":case"new":case"connecting":default:{e.log("WebRTC connection state changed to "+this.connectionState);break}}};t.peerConn.oniceconnectionstatechange=function(t){if(e.destroyed){return}switch(this.iceConnectionState){case"failed":{e.showError("ICE connection "+this.iceConnectionState);break}case"disconnected":case"closed":case"new":case"checking":case"connected":case"completed":default:{e.log("WebRTC ICE connection state changed to "+this.iceConnectionState);break}}};MistUtil.event.send("webrtc_ready",null,r)})};this.play=function(){if(!this.isConnected){throw"Not connected, cannot play"}this.peerConn.createOffer({offerToReceiveAudio:true,offerToReceiveVideo:true}).then(function(e){t.localOffer=e;t.peerConn.setLocalDescription(e).then(function(){t.signaling.sendOfferSDP(t.localOffer.sdp)},function(e){console.error(e)})},function(e){throw e})};this.stop=function(){if(!this.isConnected){throw"Not connected, cannot stop."}this.signaling.send({type:"stop"})};this.seek=function(n){var i=new Promise(function(i,r){if(!t.isConnected||!t.signaling){if(t.isConnecting){var s=MistUtil.event.addListener(e.video,"loadstart",function(){t.seek(n);MistUtil.event.removeListener(s)});return r("Not connected yet, will seek once connected")}else{return r("Failed seek: not connected")}}t.signaling.send({type:"seek",seek_time:n=="live"?"live":n*1e3});if("seekPromise"in t.signaling){t.signaling.seekPromise.reject("Doing new seek")}t.signaling.seekPromise={resolve:function(e){i("seeked");delete t.signaling.seekPromise},reject:function(e){r("Failed to seek: "+e);delete t.signaling.seekPromise}}});return i};this.pause=function(){if(!this.isConnected){throw"Not connected, cannot pause."}this.signaling.send({type:"hold"})};this.setTrack=function(e){if(!this.isConnected){throw"Not connected, cannot set track."}e.type="tracks";this.signaling.send(e)};this.playbackrate=function(e){if(typeof e=="undefined"){return n.webrtc.play_rate=="auto"?1:n.webrtc.play_rate}if(!this.isConnected){throw"Not connected, cannot change playback rate."}this.signaling.send({type:"set_speed",play_rate:e})};this.getStats=function(e){this.peerConn.getStats().then(function(t){var n={};var i=Array.from(t.entries());for(var r in i){var s=i[r];if(s[1].type=="inbound-rtp"){n[s[0]]=s[1]}}e(n)})};this.connect()}function d(t){this.ws=null;this.ws=new WebSocket(e.source.url.replace(/^http/,"ws"));var n=false;this.ws.onopen=function(){t({type:"on_connected"})};this.ws.timeOut=e.timers.start(function(){if(e.player.webrtc.signaling.ws.readyState==0){e.log("WebRTC: socket timeout - try next combo");e.nextCombo()}},5e3);this.ws.onmessage=function(e){try{var n=JSON.parse(e.data);t(n)}catch(t){console.error("Failed to parse a response from MistServer",t,e.data)}};this.ws.onclose=function(e){switch(e.code){case 1006:{}default:{t({type:"on_disconnected",code:e.code});break}}};this.sendOfferSDP=function(e){this.send({type:"offer_sdp",offer_sdp:e})};this.send=function(e){if(!this.ws){throw"Not initialized, cannot send "+JSON.stringify(e)}this.ws.send(JSON.stringify(e))}}this.webrtc=new u;this.api={};var p;Object.defineProperty(this.api,"duration",{get:function(){return p}});Object.defineProperty(this.api,"currentTime",{get:function(){return c+r.currentTime},set:function(e){c=e-r.currentTime;r.pause();var t=n.webrtc.seek(e);MistUtil.event.send("seeking",e,r);if(t){t.catch(function(e){})}}});Object.defineProperty(this.api,"playbackRate",{get:function(){return n.webrtc.playbackrate()},set:function(e){return n.webrtc.playbackrate(e)}});function h(e){Object.defineProperty(n.api,e,{get:function(){return r[e]},set:function(t){return r[e]=t}})}var v=["volume","muted","loop","paused",,"error","textTracks","webkitDroppedFrameCount","webkitDecodedFrameCount"];for(var o in v){h(v[o])}function g(e){if(e in r){n.api[e]=function(){return r[e].call(r,arguments)}}}var v=["load","getVideoPlaybackQuality"];for(var o in v){g(v[o])}n.api.play=function(){var t;if(n.api.currentTime){t=n.api.currentTime}if(e.info&&e.info.type=="live"){t="live"}if(t){var i=new Promise(function(i,r){if(!n.webrtc.isConnected&&n.webrtc.peerConn.iceConnectionState!="completed"){if(!n.webrtc.isConnecting){e.log("Received call to play while not connected, connecting "+n.webrtc.peerConn.iceConnectionState);n.webrtc.connect(function(){n.webrtc.seek(t).then(function(e){i("played "+e)}).catch(function(e){r(e)})})}else{r("Still connecting")}}else{n.webrtc.seek(t).then(function(e){i("played "+e)}).catch(function(e){r(e)})}});return i}else{return r.play()}};n.api.getStats=function(){if(n.webrtc&&n.webrtc.isConnected){return new Promise(function(e,t){n.webrtc.peerConn.getStats().then(function(t){var n={audio:null,video:null};var i=Object.fromEntries(t);for(var r in i){if(i[r].type=="track"){n[i[r].kind]=i[r]}}e(n)})})}};n.api.getLatency=function(){var t=e.player.api.getStats();if(t){return new Promise(function(e,i){t.then(function(t){setTimeout(function(){var r=n.api.getStats();if(!r){i();return}r.then(function(n){var i={};for(var r in t){i[r]=t[r]&&n[r]?(n[r].jitterBufferDelay-t[r].jitterBufferDelay)/(n[r].jitterBufferEmittedCount-t[r].jitterBufferEmittedCount):null}e(i)},i)},1e3)},i)})}};n.api.pause=function(){r.pause();try{n.webrtc.pause()}catch(e){}MistUtil.event.send("paused",null,r)};n.api.setTracks=function(e){if(n.webrtc.isConnected){n.webrtc.setTrack(e)}else{var t=function(){n.webrtc.setTrack(e);MistUtil.event.removeListener({type:"webrtc_connected",callback:t,element:r})};MistUtil.event.addListener(r,"webrtc_connected",t)}};function b(){if(!n.api.textTracks[0]){return}var e=n.api.textTracks[0].currentOffset||0;if(Math.abs(c-e)<1){return}var t=[];for(var i=n.api.textTracks[0].cues.length-1;i>=0;i--){var r=n.api.textTracks[0].cues[i];n.api.textTracks[0].removeCue(r);if(!("orig"in r)){r.orig={start:r.startTime,end:r.endTime}}r.startTime=r.orig.start-c;r.endTime=r.orig.end-c;t.push(r)}for(var i in t){n.api.textTracks[0].addCue(t[i])}n.api.textTracks[0].currentOffset=c}n.api.setSubtitle=function(e){var t=r.getElementsByTagName("track");for(var n=t.length-1;n>=0;n--){r.removeChild(t[n])}if(e){var i=document.createElement("track");r.appendChild(i);i.kind="subtitles";i.label=e.label;i.srclang=e.lang;i.src=e.src;i.setAttribute("default","");i.onload=b}};n.api.metaTrackSocket=function(){this.origin={};this.CONNECTING=0;this.OPEN=1;this.CLOSING=2;this.CLOSED=3;this.readyState=0;this.listeners=[];var t=this;MistUtil.event.addListener(e.video,"webrtc_ready",function(){t.init()});this.init=function(){this.origin=e.player.webrtc&&e.player.webrtc.MetaDataTrack?e.player.webrtc.MetaDataTrack:{};if("readyState"in this.origin){function n(){t.readyState=t.OPEN;t.onopen()}this.origin.addEventListener("open",n);this.origin.onmessage=function(e){};this.origin.addEventListener("close",function(){t.readyState=t.CLOSED;t.onclose()});if(this.origin.readyState=="open"){n()}return true}else{return false}};this.open=function(){if(this.readyState==this.OPEN)return;switch(this.origin.readyState){case"connecting":{this.readyState=this.CONNECTING;break}case"open":{this.readyState=this.OPEN;break}case"closing":{this.readyState=this.CLOSING;break}case"closed":{this.readyState=this.CLOSED;break}}for(var e in this.listeners){this.origin.addEventListener.apply(this.origin,this.listeners[e])}};this.close=function(){if(this.readyState>=this.CLOSING)return;this.readyState=this.CLOSED;for(var e in this.listeners){this.removeEventListener.apply(this,this.listeners[e])}};this.send=function(){if(this.origin.readyState=="open")return this.origin.send.apply(this,arguments);return false};this.onopen=function(){};this.onclose=function(){};this.addEventListener=function(){this.listeners.push(arguments);return this.origin.addEventListener.apply(this.origin,arguments)};this.removeEventListener=function(e,t){for(var n=this.listeners.length-1;n>=0;n--){if(e==this.listeners[n][0]&&t==this.listeners[n][1]){this.listeners.splice(n,1);break}}return this.origin.removeEventListener.apply(this.origin,arguments)};this.init();return this};MistUtil.event.addListener(r,"ended",function(){if(n.api.loop){if(e.state=="Stream is online"){n.webrtc.connect()}}});if("decodingIssues"in e.skin.blueprints){var y=["nackCount","pliCount","packetsLost","packetsReceived","bytesReceived"];for(var w in y){n.api[y[w]]=0}var k=function(){e.timers.start(function(){n.webrtc.getStats(function(e){for(var t in e){for(var i in y){if(y[i]in e[t]){n.api[y[i]]=e[t][y[i]]}}break}});k()},1e3)};k()}n.api.ABR_resize=function(t){e.log("Requesting the video track with the resolution that best matches the player size");n.api.setTracks({video:"~"+[t.width,t.height].join("x")})};n.api.unload=function(){try{n.webrtc.stop();n.webrtc.signaling.ws.close();n.webrtc.peerConn.close()}catch(e){}};t(r)}; \ No newline at end of file diff --git a/embed/skins/default.css b/embed/skins/default.css index 719c54a1..bcb6ef3c 100644 --- a/embed/skins/default.css +++ b/embed/skins/default.css @@ -93,7 +93,7 @@ } .mistvideo-main { align-items: center; } -svg.icon.timeout { +.mistvideo svg.icon.timeout { display: inline-block; height: 1em; width: 1em; @@ -232,14 +232,14 @@ svg.icon.timeout { .mistvideo-chromecast { display: flex; } -google-cast-launcher { +.mistvideo google-cast-launcher { width: 24px; height: 24px; --connected-color: $fill; --disconnected-color: $semiFill; } -google-cast-launcher.active { +.mistvideo google-cast-launcher.active { --connected-color: $accent; --disconnected-color: $fill; } diff --git a/embed/skins/dev.css b/embed/skins/dev.css index 555a4f25..42e082b9 100644 --- a/embed/skins/dev.css +++ b/embed/skins/dev.css @@ -74,17 +74,17 @@ .mistvideo-decodingIssues label .value { font-size: 0.8em; } -svg.icon.graph { +.mistvideo svg.icon.graph { position: absolute; right: 0; top: 0; bottom: 0; width: 6em; } -select { +.mistvideo select { border-radius: 0; } -input[type="checkbox"] { +.mistvideo input[type="checkbox"] { margin: 0; margin-right: 0.2em; border: 1px solid $semiFill; @@ -99,7 +99,7 @@ input[type="checkbox"] { position: relative; cursor: pointer; } -input[type="checkbox"]:checked:after { +.mistvideo input[type="checkbox"]:checked:after { content: "\2713"; position: absolute; bottom: -0.2em; diff --git a/embed/skins/general.css b/embed/skins/general.css index a677c950..c4b794c7 100644 --- a/embed/skins/general.css +++ b/embed/skins/general.css @@ -20,7 +20,7 @@ overflow: hidden; outline: none; } -svg.icon.loading { +.mistvideo svg.icon.loading { z-index: -1; /* don't use display: none because of transition for [data-loading=stalled] */ position: absolute; top: 0; @@ -30,24 +30,24 @@ svg.icon.loading { margin: auto; opacity: 0; } -[data-loading] { +.mistvideo [data-loading] { position: relative; } /*wait before showing icon when stalled*/ -[data-loading="stalled"] svg.icon.loading { +.mistvideo [data-loading="stalled"] svg.icon.loading { transition: opacity 0s 3s; } -[data-loading] svg.icon.loading { +.mistvideo [data-loading] svg.icon.loading { z-index: 2; opacity: 1; } -[data-loading-css] .mistvideo-controls { +.mistvideo [data-loading-css] .mistvideo-controls { display: none; } -[data-hidecursor], -[data-hidecursor] .mistvideo-pointer, -[data-hidecursor] * +.mistvideo [data-hidecursor], +.mistvideo [data-hidecursor] .mistvideo-pointer, +.mistvideo [data-hidecursor] * { cursor: none } .mistvideo-error { display: none; @@ -81,8 +81,8 @@ svg.icon.loading { opacity: 0.5; cursor: pointer; } -button:hover { opacity: 1; } -select { +.mistvideo button:hover { opacity: 1; } +.mistvideo select { background-color: transparent; color: $stroke; border: none; @@ -91,7 +91,7 @@ select { cursor: pointer; -ms-background-color: red; } -select > option { +.mistvideo select > option { background-color: $background; } @@ -115,15 +115,15 @@ select > option { background-color: #111 !important; z-index: 999; } -video { +.mistvideo video { display: block; flex-shrink: 0; } -table { color: inherit; font-size: inherit; font-style: inherit; } -audio:not([controls]) { display: block !important; } +.mistvideo table { color: inherit; font-size: inherit; font-style: inherit; } +.mistvideo audio:not([controls]) { display: block !important; } .mistvideo-padding { padding: 5px 10px; } .mistvideo-pointer { cursor: pointer; } -.description { +.msitvideo .description { color: $semiFill; font-size: 0.9em; } @@ -178,7 +178,7 @@ audio:not([controls]) { display: block !important; } margin-right: 1em; } -a { +.mistvideo a { color: $accent; } .mistvideo-log .logs { @@ -210,20 +210,20 @@ a { @keyframes mistvideo-appear { from { opacity: 0; } to { opacity: 1; } } -svg.icon { +.mistvideo svg.icon { display: block; stroke-width: $strokeWidth; fill: none; stroke: none; } -svg.icon.fill, svg.icon .fill { fill: $fill; } -svg.icon.semiFill, svg.icon .semiFill { fill: $semiFill; } -svg.icon.stroke, svg.icon .stroke { stroke: $stroke; vector-effect: non-scaling-stroke; } -svg.icon.off .toggle.fill, -svg.icon.off .toggle.semiFill, -svg.icon.off .toggle .fill, -svg.icon.off .toggle .semiFill { fill: none; } -svg.icon.spin, svg.icon .spin { +.mistvideo svg.icon.fill, svg.icon .fill { fill: $fill; } +.mistvideo svg.icon.semiFill, svg.icon .semiFill { fill: $semiFill; } +.mistvideo svg.icon.stroke, svg.icon .stroke { stroke: $stroke; vector-effect: non-scaling-stroke; } +.mistvideo svg.icon.off .toggle.fill, +.mistvideo svg.icon.off .toggle.semiFill, +.mistvideo svg.icon.off .toggle .fill, +.mistvideo svg.icon.off .toggle .semiFill { fill: none; } +.mistvideo svg.icon.spin, svg.icon .spin { animation: mistvideo-spin 1.5s infinite linear; transform-origin: 50% 50%; } diff --git a/generated/meson.build b/generated/meson.build index 7180c0d7..e3690758 100644 --- a/generated/meson.build +++ b/generated/meson.build @@ -32,8 +32,6 @@ embed_files = [ {'infile': '../embed/min/skins/default.css', 'variable': 'skin_default_css', 'outfile': 'skin_default.css.h'}, {'infile': '../embed/min/skins/dev.css', 'variable': 'skin_dev_css', 'outfile': 'skin_dev.css.h'}, {'infile': '../embed/skins/video-js.css', 'variable': 'skin_videojs_css', 'outfile': 'skin_videojs.css.h'}, - {'infile': '../src/output/noffmpeg.jpg', 'variable': 'noffmpeg', 'outfile': 'noffmpeg.h'}, - {'infile': '../src/output/noh264.jpg', 'variable': 'noh264', 'outfile': 'noh264.h'}, ] embed_tgts = [] diff --git a/lib/config.cpp b/lib/config.cpp index c1800a74..361e33c3 100644 --- a/lib/config.cpp +++ b/lib/config.cpp @@ -175,6 +175,27 @@ static bool checkSerial(const std::string &ser){ #endif #endif +void Util::Config::wipeShm(){ + DIR *d = opendir("/dev/shm"); + char fileName[300]; + struct dirent *dp; + uint64_t deleted = 0; + if (d){ + do{ + errno = 0; + if ((dp = readdir(d))){ + if (strstr(dp->d_name, "Mst")){ + snprintf(fileName, sizeof(fileName), "/dev/shm/%s", dp->d_name); + unlink(fileName); + ++deleted; + } + } + }while (dp != NULL); + closedir(d); + } + if (deleted){WARN_MSG("Wiped %" PRIu64 " shared memory file(s)", deleted);} +} + Util::Config::Config(){ // global options here vals["debug"]["long"] = "debug"; diff --git a/lib/config.h b/lib/config.h index 819f9e63..a22967b6 100644 --- a/lib/config.h +++ b/lib/config.h @@ -37,6 +37,7 @@ namespace Util{ public: static void setMutexAborter(void * mutex); + static void wipeShm(); // variables static bool is_active; ///< Set to true by activate(), set to false by the signal handler. static bool is_restarting; ///< Set to true when restarting, set to false on boot. diff --git a/lib/dtsc.cpp b/lib/dtsc.cpp index 98f2e606..1d468a64 100644 --- a/lib/dtsc.cpp +++ b/lib/dtsc.cpp @@ -1286,9 +1286,7 @@ namespace DTSC{ stream.setInt("vod", origStream.getInt("vod")); stream.setInt("live", origStream.getInt("live")); stream.setString("source", origStream.getPointer("source")); - stream.setString("uuid", origStream.getPointer("uuid")); stream.setInt("maxkeepaway", origStream.getInt("maxkeepaway")); - stream.setInt("resume", origStream.getInt("resume")); stream.setInt("bufferwindow", origStream.getInt("bufferwindow")); stream.setInt("bootmsoffset", origStream.getInt("bootmsoffset")); stream.setInt("utcoffset", origStream.getInt("utcoffset")); @@ -3036,6 +3034,7 @@ namespace DTSC{ trackJSON["init"] = getInit(*it); trackJSON["firstms"] = getFirstms(*it); trackJSON["lastms"] = getLastms(*it); + trackJSON["nowms"] = getNowms(*it); trackJSON["bps"] = getBps(*it); trackJSON["maxbps"] = getMaxBps(*it); if (!skipDynamic && getLive()){ diff --git a/lib/stream.cpp b/lib/stream.cpp index b470446b..01aed5e1 100644 --- a/lib/stream.cpp +++ b/lib/stream.cpp @@ -576,7 +576,7 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir // Only use configured source if not manually overridden. Abort if no config is available. if (!filename.size()){ - if (!stream_cfg){ + if (!stream_cfg || !stream_cfg.isMember("source") || !stream_cfg["source"].isString() || !stream_cfg["source"]){ MEDIUM_MSG("Stream %s not configured, no source manually given, cannot start", streamname.c_str()); return false; } diff --git a/lib/util.cpp b/lib/util.cpp index 304e6c2e..012ea106 100644 --- a/lib/util.cpp +++ b/lib/util.cpp @@ -316,6 +316,24 @@ namespace Util{ rndSrc.close(); } + /// Secure random alphanumeric string generator + /// Uses getRandomBytes internally + std::string getRandomAlphanumeric(size_t len){ + std::string ret(len, 'X'); + getRandomBytes((void*)ret.data(), len); + for (size_t i = 0; i < len; ++i){ + uint8_t v = (ret[i] % 62); + if (v < 10){ + ret[i] = v + '0'; + }else if (v < 36){ + ret[i] = v - 10 + 'A'; + }else{ + ret[i] = v - 10 - 26 + 'a'; + } + } + return ret; + } + /// 64-bits version of ftell uint64_t ftell(FILE *stream){ /// \TODO Windows implementation (e.g. _ftelli64 ?) diff --git a/lib/util.h b/lib/util.h index 12a1d567..c656edf2 100644 --- a/lib/util.h +++ b/lib/util.h @@ -21,6 +21,7 @@ namespace Util{ int64_t expBackoffMs(const size_t currIter, const size_t maxIter, const int64_t maxWait); void getRandomBytes(void * dest, size_t len); + std::string getRandomAlphanumeric(size_t len); uint64_t ftell(FILE *stream); uint64_t fseek(FILE *stream, uint64_t offset, int whence); diff --git a/lsp/CMakeLists.txt b/lsp/CMakeLists.txt deleted file mode 100644 index 8a1e8161..00000000 --- a/lsp/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -set(lspSOURCES plugins/md5.js plugins/cattablesort.js mist.js) -set(lspSOURCESmin plugins/jquery.js plugins/jquery.flot.min.js plugins/jquery.flot.time.min.js plugins/jquery.qrcode.min.js) -set(lspDATA header.html main.css footer.html) - -add_custom_target( lsp - ALL - ${CMAKE_CURRENT_SOURCE_DIR}/generateLSP.sh ${CMAKE_CURRENT_BINARY_DIR}/server.html - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generateLSP.sh ${lspSOURCES} ${lspSOURCESmin} ${lspDATA} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - VERBATIM -) diff --git a/lsp/main.css b/lsp/main.css index 52901e60..4534e4e8 100644 --- a/lsp/main.css +++ b/lsp/main.css @@ -146,6 +146,9 @@ nav .hiddenmenu .button { nav .hiddenmenu .button.active { display: block; } +nav .hiddenmenu:has(.button.active) .button { + display: block; +} nav .arrowdown > .plain::after, nav .arrowdown > .highlighted::after { content: ''; @@ -823,9 +826,7 @@ body:not(.helpme) .input_container .ih_balloon { .bigbuttons { display: flex; - flex-flow: row nowrap; - width: 40.25em; - justify-content: space-around; + flex-flow: row wrap; } .bigbuttons button { width: 10em; @@ -843,6 +844,14 @@ body:not(.helpme) .input_container .ih_balloon { background-position: center; background-repeat: no-repeat; } +.bigbuttons button[data-icon]:before { + content: attr(data-icon); + font-size: 5em; + line-height: 1.6em; + text-align: center; + filter: sepia(1) saturate(2) hue-rotate(173deg) grayscale(0.3) brightness(0.92); +} + button.settings:before { background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiIGlkPSJzdmczNDA1IiB2aWV3Qm94PSIwIDAgNjQgNjQiIGhlaWdodD0iNjQiIHdpZHRoPSI2NCI+IDxkZWZzIGlkPSJkZWZzMzQwNyIgLz4gPG1ldGFkYXRhIGlkPSJtZXRhZGF0YTM0MTAiPiA8cmRmOlJERj4gPGNjOldvcmsgcmRmOmFib3V0PSIiPiA8ZGM6Zm9ybWF0PmltYWdlL3N2Zyt4bWw8L2RjOmZvcm1hdD4gPGRjOnR5cGUgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz4gPGRjOnRpdGxlPjwvZGM6dGl0bGU+IDwvY2M6V29yaz4gPC9yZGY6UkRGPiA8L21ldGFkYXRhPiA8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMTg4Ljc0MjMxLC01MDcuNjY1MzgpIiBpZD0ibGF5ZXIxIj4gPGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTM1OS43Nzc5OCwtNTkuMjQ2OTM4KSIgaWQ9ImczMzc3Ij4gPHBhdGggc3R5bGU9ImZpbGw6IzhjYjNkMTtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgZD0ibSA1NTIuOTg4MjcsNTc5LjY0OTIzIGMgMi41MzkwNiwyLjQ5MDIzIDQuOTMxNjMsNC44NTM1MiA3LjMzODg3LDcuMjAyMTUgMS41NDc4NSwxLjUwMzkxIDMuMTY4OTQsMS41MDg3OSA0LjcxMTkxLDAuMDI5MyAwLjk4MTQ0LC0wLjk0NzI3IDEuOTY3NzgsLTEuODk5NDEgMi45MzQ1NywtMi44NjYyMSAxLjM2MjMxLC0xLjM2NzE5IDEuMzYyMzEsLTMuMDA3ODIgLTAuMDI0NCwtNC4zNzAxMiAtMi41NDM5NCwtMi41IC01LjExMjMsLTQuOTg1MzUgLTcuNzM0MzcsLTcuNTM5MDYgNS4zOTU1MSwtMS45MjM4NCAxMC4yNjM2NywtMS4xNzY3NiAxNC4zMjYxNywyLjUxOTUzIDMuMTk4MjQsMi45MDUyNyA0Ljg2MzI3LDYuNjMwODYgMy45Njk3MiwxMS4wNjQ0NSAtMC4xNjYwMSwwLjg0NDczIDAuNDEwMTcsMS4yMTA5MyAwLjg4Mzc5LDEuNjc0ODEgOS4wMzgwOSw4LjgxODM2IDE4LjA3MTI5LDE3LjYzNjcxIDI3LjExOTE0LDI2LjQ0NTMxIDIuMjIxNjgsMi4xNjMwOSAyLjk2Mzg3LDQuODA0NjkgMS45Mzg0OCw3LjYwNzQzIC0xLjAwMDk4LDIuNzE5NzIgLTIuOTU4OTgsNC42NDM1NSAtNi4xNTIzNSw1LjE4NTUzIC0yLjgwMjczLDAuNDczNjQgLTUuMDU4NTgsLTAuMzQ2NjcgLTYuOTc3NTMsLTIuMjExOTEgLTguOTA2MjUsLTguNjQ3NDYgLTE3LjgwNzYxLC0xNy4zMDk1NiAtMjYuNjUwMzksLTI2LjAyMDUgLTEuMDU0NjgsLTEuMDM1MTYgLTIuMDc1MiwtMS41MDg4IC0zLjU3NDIyLC0xLjQ0MDQ0IC01LjYwNTQ2LDAuMjYzNjggLTEwLjc3NjM2LC0zLjkwNjI1IC0xMi4yOTk4LC04LjY5NjI5IC0wLjg5ODQ0LC0yLjgxNzM4IC0wLjk3MTY5LC01LjYxNTIzIDAuMTkwNDIsLTguNTgzOTgiIGlkPSJwYXRoNDIwNyIgLz4gPHBhdGggc3R5bGU9ImZpbGw6IzhjYjNkMTtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgZD0ibSA1ODguOTA2MjQsNTkyLjkwNjA2IGMgLTIuMzkyNTksLTIuMzQzNzUgLTIuMzkyNTksLTIuMzQzNzUgLTAuMDQ4OSwtNC42Mjg5IDQuMTA2NDUsLTQuMDAzOTEgOC4yMTc3OCwtOC4wMDI5MyAxMi4zMDk1OCwtMTIuMDE2NTkgMC40ODM0LC0wLjQ3ODUzIDEuNTAzOTEsLTAuOTQ3MjggMC42MzQ3NiwtMS43ODcxMiAtMC45MTMwOSwtMC44ODg2NyAtMS40NDUzMSwwLjExNzEzIC0xLjk3NzU0LDAuNjI5ODggLTQuNTcwMzEsNC40MzM2IC05LjE3NDgsOC44Mzc5IC0xMy42NDc0NiwxMy4zNTkzNyAtMS4wNTQ2OSwxLjA2OTM0IC0xLjM4NjcxLDAuMzIyMjggLTIuMDcwMzEsLTAuMjA5OTUgLTAuODY0MjUsLTAuNjc4NzEgLTAuODQ5NiwtMS4xMTgxNyAtMC4wMjkzLC0xLjg5OTQyIDQuNjc3NzIsLTQuNDcyNjUgOS4yNzI0NSwtOS4wMjgzMiAxMy45MjU3NywtMTMuNTMwMjYgMi4xMzM3OSwtMi4wNjU0NCA0LjY4MjYxLC0yLjEzODY4IDcuMDQxMDEsLTEuMjMwNDggMi4zNTg0LDAuOTEzMDkgMy44NzY5NywzLjM5ODQ0IDMuODc2OTcsNS43MTc3OCAwLjAwNSwyLjA1NTY2IC0wLjc0NzA4LDMuNjY2OTggLTIuMTg3NSw1LjA2ODM2IC00LjQwOTE5LDQuMjkxOTggLTguODA4Niw4LjU5Mzc1IC0xMy4yMjc1NSwxMi44ODU3MyAtMC4zODA4NSwwLjM3MTExIC0wLjc0NzA2LDEuMTA4NDEgLTEuMzg2NzEsMC42ODg0OCAtMC42ODM2LC0wLjQ1NDEgLTEuMjg5MDcsLTEuMDk4NjIgLTEuNzM4MjksLTEuNzc3MzQgLTAuMjAwMTksLTAuMzA3NjIgMC40Mzk0NiwtMC42MzQ3NyAwLjcyNzU1LC0wLjkxMzA5IDQuNTUwNzcsLTQuNDUzMTIgOS4xMTEzMiwtOC44OTY0OCAxMy42NjY5OCwtMTMuMzM5ODQgMC4zMDI3NCwtMC4yOTc4NiAwLjY3ODcyLC0wLjU2MTUzIDAuODQ5NjIsLTAuOTE3OTcgMC4xMzY3MSwtMC4zMDI3NCAwLjI0OTAyLC0wLjcyMjY2IC0wLjE5NTMyLC0xLjA0OTgxIC0wLjM4MDg2LC0wLjI3ODMxIC0wLjcwMzEyLC0wLjI1ODc5IC0xLjAyNTQsLTAuMDI0NCAtMC4zNzU5NywwLjI3MzQzIC0wLjczMjQxLDAuNTgxMDYgLTEuMDY0NDUsMC45MDMzMiAtNC43OTAwMyw0LjY2MzA5IC05LjU3MDMxLDkuMzMxMDUgLTE0LjQzMzU4LDE0LjA3MjI2IiBpZD0icGF0aDQyMDkiIC8+IDxwYXRoIHN0eWxlPSJmaWxsOiM4Y2IzZDE7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiIGQ9Im0gNTcxLjE1MjMzLDYwNC45MTc3OSBjIDEuMDkzNzUsMC45NzY1NiAyLjE1MzMyLDEuOTE4OTQgMy4yMTI4OCwyLjg2NjIxIC0wLjk2MTkxLDAuOTEzMDggLTIuMDE2NiwxLjc1NzgyIC0yLjg2NjIsMi43NTg3OSAtMS4wOTM3NCwxLjI5Mzk0IC0yLjE5NzI3LDIuNTQ4ODMgLTMuNjI3OTMsMy40OTYwOSAtMS45MDkxOCwxLjI2OTUzIC0yLjQ4MDQ2LDMuMjEyODggLTIuNzU4NzksNS4yNzgzMiAtMC4wNDg5LDAuMzg1NzQgLTAuMDkyOCwwLjcyNzU0IC0wLjQxNTA0LDAuOTMyNjEgLTMuMzU5MzcsMi4xNDM1NyAtNi43MzgyOCw0LjI2MjcgLTEwLjA3ODEyLDYuNDM1NTYgLTAuMzk1NTEsMC4yNTM4OSAtMC40MjQ4LC0wLjAzNDEgLTAuNTc2MTgsLTAuMTUxMzcgLTIuNDAyMzMsLTEuNzgyMjQgLTIuMzgyODEsLTIuMDYwNTUgLTAuNzI3NTMsLTQuNTYwNTUgMS40OTQxMywtMi4yNTU4NiAzLjI1MTk1LC00LjM1MDU4IDQuNDQ4MjMsLTYuNzg3MTEgMC42NjQwNywtMS4zNDc2NSAxLjkzMzYsLTEuNjExMzMgMy4yNDcwOCwtMS42ODk0NSAxLjEwODQsLTAuMDY4NCAxLjkxODk1LC0wLjUyNzM1IDIuNjc1NzksLTEuMjc5MyAyLjQ5NTExLC0yLjQ4MDQ2IDUuMDM0MTcsLTQuOTI2NzYgNy40NjU4MSwtNy4yOTk4IiBpZD0icGF0aDQyMTEiIC8+IDxwYXRoIHN0eWxlPSJmaWxsOiM4Y2IzZDE7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiIGQ9Im0gNjA1LjM2NjIsNjE5LjUwMjc1IGMgLTAuMjgzMjEsMi4zNjMyOCAtMS44MTY0MSwzLjgyMzI0IC00LjA1NzYyLDMuOTIwODkgLTIuMDc1MTksMC4wODc5IC00LjQwOTE4LC0yLjE2Nzk2IC00LjIyMzYzLC00LjA2MjUgMC4yMzkyNSwtMi4zNzc5MyAxLjY0MDYzLC00LjAyMzQ0IDQuMjgyMjMsLTMuOTc0NiAyLjMxOTMzLDAuMDM5IDMuOTU1MDcsMS44Nzk4OCAzLjk5OTAyLDQuMTE2MjEiIGlkPSJwYXRoNDIxMyIgLz4gPC9nPiA8L2c+PC9zdmc+DQo='); } @@ -856,6 +865,510 @@ button.return:before { background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iNjQiIGhlaWdodD0iNjQiIGlkPSJzdmczOTM3IiB2ZXJzaW9uPSIxLjEiPiA8ZGVmcyBpZD0iZGVmczM5MzkiIC8+IDxtZXRhZGF0YSBpZD0ibWV0YWRhdGEzOTQyIj4gPHJkZjpSREY+IDxjYzpXb3JrIHJkZjphYm91dD0iIj4gPGRjOmZvcm1hdD5pbWFnZS9zdmcreG1sPC9kYzpmb3JtYXQ+IDxkYzp0eXBlIHJkZjpyZXNvdXJjZT0iaHR0cDovL3B1cmwub3JnL2RjL2RjbWl0eXBlL1N0aWxsSW1hZ2UiIC8+IDxkYzp0aXRsZT48L2RjOnRpdGxlPiA8L2NjOldvcms+IDwvcmRmOlJERj4gPC9tZXRhZGF0YT4gPHBhdGggaWQ9InBhdGg0NDk1IiBkPSJtIDMwLjQzNzQ5OSw4IGEgMjQsMjQgMCAwIDAgLTE2Ljk1ODMzMyw3LjA0MTY2NyBsIDYuMDI5MTY3LDYuMDI5MTY3IEEgMTUuNDY2NjY2LDE1LjQ2NjY2NiAwIDAgMSAzMC40Mzc0OTksMTYuNTMzMzM0IDE1LjQ2NjY2NiwxNS40NjY2NjYgMCAwIDEgNDUuOTA0MTY1LDMyIDE1LjQ2NjY2NiwxNS40NjY2NjYgMCAwIDEgMzAuNDM3NDk5LDQ3LjQ2NjY2NiAxNS40NjY2NjYsMTUuNDY2NjY2IDAgMCAxIDE5LjUwODMzMyw0Mi45MjkxNjYgbCAzLjkyMDgzMywtMy45MjA4MzMgLTEzLjg2NjY2NSwwIDAsMTMuODY2NjY1IDMuOTE2NjY1LC0zLjkxNjY2NSBBIDI0LDI0IDAgMCAwIDMwLjQzNzQ5OSw1NiBhIDI0LDI0IDAgMCAwIDI0LC0yNCAyNCwyNCAwIDAgMCAtMjQsLTI0IHoiIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDojOGRiM2QxO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpldmVub2RkO3N0cm9rZTpub25lO3N0cm9rZS13aWR0aDoxLjU7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLWRhc2hvZmZzZXQ6MDtzdHJva2Utb3BhY2l0eToxIiAvPjwvc3ZnPg=='); } +[onempty]:empty:before { + content: attr(onempty); +} +[afterifnotempty]:not(:empty):after { content: attr(afterifnotempty); } +[beforeifnotempty]:not(:empty):before { content: attr(beforeifnotempty); } + +main[data-tab="Status"] .dashboard, +main[data-tab="Preview"] .dashboard { + display: grid; + grid-template-columns: repeat(4,1fr); + grid-auto-rows: minmax(7em,max-content); + grid-gap: 1.5em; + grid-auto-flow: row dense; +} +main[data-tab="Status"] .dashboard > section, +main[data-tab="Preview"] .dashboard > section { + min-height: 0; + min-width: 0; +} +main[data-tab="Status"] .dashboard > section.actions, +main[data-tab="Status"] .dashboard > section.meta, +main[data-tab="Status"] .dashboard > section.pushes, +main[data-tab="Status"] .dashboard > section.triggers, +main[data-tab="Status"] .dashboard > section.processes, +main[data-tab="Preview"] .dashboard > section.meta, +main[data-tab="Preview"] .dashboard > section.pushes, +main[data-tab="Preview"] .dashboard > section.triggers, +main[data-tab="Preview"] .dashboard > section.processes, +.dashboard > section.preview { + grid-column: 1 / -1; +} +main[data-tab="Status"] .dashboard > section.activestream, +main[data-tab="Status"] .dashboard section.logs, +main[data-tab="Status"] .dashboard section.accesslogs, +main[data-tab="Preview"] .dashboard > section.activestream, +main[data-tab="Preview"] .dashboard section.logs, +main[data-tab="Preview"] .dashboard section.accesslogs, +.dashboard > section.controls { + grid-column: span 2; +} +main[data-tab="Status"] .dashboard > section.pushes, +main[data-tab="Preview"] .dashboard > section.pushes { + grid-row: span 2; +} +main[data-tab="Status"] .dashboard > section.logcont, +main[data-tab="Preview"] .dashboard > section.logcont { + display: grid; + grid-template-rows: subgrid; + grid-template-columns: subgrid; + grid-column: span 4; +} +main[data-tab="Status"] .dashboard > section.logcont *, +main[data-tab="Preview"] .dashboard > section.logs * { + min-width: 0; +} +main[data-tab="Status"] .dashboard > section.logs, +main[data-tab="Status"] .dashboard > section.accesslogs { + grid-row-end: -1; +} +main[data-tab="Status"] .dashboard > section.activestream { + order: -1; +} +main[data-tab="Preview"] .dashboard section.logs { + align-self: end; +} + +@media only screen and (max-width:1150px) { + main[data-tab="Status"] .dashboard, + main[data-tab="Preview"] .dashboard { + display: grid; + grid-template-columns: repeat(2,1fr); + } + main[data-tab="Status"] .dashboard > section.actions { + grid-column: span 1 / auto; + justify-content: initial; + } + main[data-tab="Status"] .dashboard > section.logcont { + grid-column: span 2; + grid-row: span 2; + } +} +/* +main[data-tab="Status"] .dashboard > section:has([onempty]):not(:has([onempty]:not(:empty))), +main[data-tab="Status"] .dashboard section.logcont > section:has([onempty]):not(:has([onempty]:not(:empty))) +{ + /*section has (at least one) onempty section, but it does not have an onempty section that is not empty*//* + grid-column: span 1; + grid-row: span 1; +} + +/*if logcont is empty, make it span 2 columns*//* +main[data-tab="Status"] .dashboard > section.logcont:has([onempty]):not(:has([onempty]:not(:empty))) { + grid-column: span 2; +} +*/ + +.dashboard section.meta .main { + display: flex; + flex-flow: column nowrap; +} +.dashboard > section.meta .main > label { + display: flex; + flex-flow: row wrap; + width: 15em; + justify-content: space-between; +} +.dashboard > section.meta .main > label input[type="checkbox"] { + width: 1.5em; + height: 1.5em; +} +.dashboard .tracktiming { + position: relative; + text-align: center; + padding: 2em 5em; + display: grid; + grid-gap: 0.5em 0; + grid-template-rows: 1fr; +} +.dashboard .tracktiming > * { + height: 1.5em; + line-height: 1.5em; + position: relative; +} +/*main[data-tab="Status"] .dashboard > section.meta .main .tracktiming * { outline: 1px solid blue; }*/ +.dashboard .tracktiming .boxcont { + --ntracks: 2; + min-width: 0; + white-space: nowrap; +} +.dashboard .tracktiming > div span { + font-size: 0.8em; + color: #777; +} +.dashboard .tracktiming .boxcont span.center { + margin-right: -100%; + margin-left: -100%; + /* centers text, even in case of overflow */ + display: inline-block; +} +.dashboard .tracktiming .boxcont.toosmall span.center { + transform: translateY(-100%); +} +.dashboard .tracktiming .boxcont .left { + position: absolute; + white-space: nowrap; + right: 100%; + border-right: 1px solid black; + transform: translateX(1px); +} +.dashboard .tracktiming .boxcont .right { + position: absolute; + white-space: nowrap; + left: 100%; + border-left: 1px solid black; + transform: translateX(-1px); +} +.dashboard [data-type="vod"] .tracktiming .boxcont .box { + display: none; +} +.dashboard .tracktiming .boxcont .box { + width: 100%; + height: calc(2em * var(--ntracks) + 0.25em); + top: 100%; +} +.dashboard .tracktiming .box { + position: absolute; + border: 1px solid black; + background-color: #060a; + top: 0; bottom: 0; + box-sizing: border-box; +} +.dashboard .tracktiming .gap .box { + background-color: #d006; +} +.dashboard .tracktiming .track[data-type="video"] .box { background-color: #8cb3cf; } +.dashboard .tracktiming .track[data-type="audio"] .box { background-color: #b5d3e2; } +.dashboard .tracktiming .track[data-type="meta"] .box { background-color: #dae9f1; } +.dashboard .tracktiming > * > label { + /*color: white;*/ + font-weight: bold; + /*mix-blend-mode: difference;*/ + position: relative; /*puts it on top*/ +} +.dashboard .tracktiming .left, +.dashboard .tracktiming .right, +.dashboard .tracktiming .jitter { + position: absolute; + right: 100%; + height: 100%; + padding: 0 0.25em; + box-sizing: border-box; + white-space: nowrap; +} +.dashboard .tracktiming .jitter { + padding: 0; +} +.dashboard .tracktiming .right { + left: 100%; right: auto; +} +.dashboard .tracktiming .jitter { + right: 0; + width: 0; + background: #fffa; +} + +.dashboard > section.meta .main .tracks { + display: flex; + flex-flow: wrap; + font-size: 0.9em; + align-items: flex-start; +} +.dashboard .meta table { + margin: 0.5em 0.5em 0 0; +} + +section.activestream [data-streamstatus]:before { + content: ''; + display: inline-block; + width: 1.2em; + aspect-ratio: 1 / 1; + margin-right: 0.25em; + margin-top: -0.25em; + border-radius: 100%; + vertical-align: middle; + --color: darkorange; + background: radial-gradient(circle 1em at 0 0, #fff3, var(--color)); + box-sizing: border-box; + border: 1.5px solid var(--color); +} +section.activestream [data-streamstatus="4"]:before { + --color: green; +} + +section.activestream [data-streamstatus="6"]:before { + --color: red; +} +section.activestream [data-streamstatus="0"]:before { + --color: gray; +} +section.activestream div.activestream .tag { + border: 1px solid #bbb; + margin: 0.1em; + padding: 0.2em; + display: inline-block; + font-size: 0.8em; + color: #777; +} +section.activestream div.activestream .tag button { + font-size: 1em; + color: darkred; + padding: 0; + margin: 0.2em 0.2em 0.2em 0.5em; + width: 1.2em; + height: 1.2em; + line-height: 1em; +} +section.activestream div.activestream .thumbnail { + max-width: 15em; + max-height: 15em; + position: relative; + overflow: hidden; + transition: max-width 0.5s; +} +section.activestream div.activestream .thumbnail:has(img[src]):after { + content: "Thumbnail"; + color: #fff; + background: #000a; + text-align: center; + padding: 0.5em; + position: absolute; + bottom: 0; right: 0; left: 0; + opacity: 1; + transition: opacity 0.5s 1s; + margin: 0.5em 0; +} +section.activestream div.activestream .thumbnail:hover { + max-width: 100%; + max-height: 100%; + transition: max-width 0.5s 1s; +} + +section.activestream div.activestream .thumbnail:has(img[src]):hover:after { + opacity: 0; + transition: opacity 0.5s; +} +section.activestream div.activestream .thumbnail img[src] { + min-width: 0; + max-width: 100%; + margin: 0.5em 0; + display: block; +} +section.activestream div.activestream > span:has(+ span:not(:empty)):after, +section.activestream div.accesslogs span:has(+ span:not(:empty)):after { + content: ', '; +} +section.activestream div.activestream .input_container span:after { + content: none !important; +} +section.activestream div.activestream .input_container label .label { + flex-basis: 9em; +} +section.activestream div.activestream .input_container label .field_container { + flex-basis: 20em; + width: auto; + min-width: 0; + flex-grow: 1 +} +section.activestream div.activestream .input_container .UIelement { + align-items: center; +} +section.activestream div.activestream .input_container label .help_container { display: none; } + +main[data-tab="Preview"] section.activestream { margin: 0.5em 0; } +main[data-tab="Preview"] section.activestream div.activestream > div:first-child { + display: inline-block; + margin-right: 1em; +} +main[data-tab="Preview"] section.activestream .livestreamhint { + max-width: 40em; +} + +main[data-tab="Status"] section.logs > div.logs, +main[data-tab="Status"] section.accesslogs > div.accesslogs, +main[data-tab="Preview"] section.logs > div.logs, +main[data-tab="Preview"] section.accesslogs > div.accesslogs, +section.processes table div.logs { + padding-left: 2em; + text-indent: -2em; + text-align: left; + max-height: 15em; + overflow: hidden auto; + font-size: 0.9em; +} +main[data-tab="Status"] section.logs > div.logs > * > *:not(:last-child):not(:empty), +main[data-tab="Preview"] section.logs > div.logs > * > *:not(:last-child):not(:empty), +main[data-tab="Status"] section.accesslogs > div.accesslogs > * > *:not(:last-child):not(:empty), +main[data-tab="Preview"] section.accesslogs > div.accesslogs > * > *:not(:last-child):not(:empty) { + padding-right: 0.5em; +} +main[data-tab="Status"] section.logs > div.logs > * > *:nth-child(2):not(:empty):before, +main[data-tab="Preview"] section.logs > div.logs > * > *:nth-child(2):not(:empty):before { + content: '['; + opacity: 0.5; +} +main[data-tab="Status"] section.logs > div.logs > * > *:nth-child(2):not(:empty):after, +main[data-tab="Preview"] section.logs > div.logs > * > *:nth-child(2):not(:empty):after { + content: ']'; + opacity: 0.5; +} +div.logs > [data-debuglevel="WARN"], +div.logs > [data-debuglevel="ERROR"], +div.logs > [data-debuglevel="FAIL"] { + font-weight: bold; + color: darkorange; +} +div.logs > [data-debuglevel="ERROR"] { + color: red; +} +div.logs > [data-debuglevel="FAIL"] > * { + color: white; + background: darkred; + outline: 2px solid darkred; +} +main[data-tab="Status"] div.accesslogs > * > *[title], +main[data-tab="Preview"] div.accesslogs > * > *[title] { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + display: inline-block; + min-width: 0; + vertical-align: bottom; + text-indent: initial; +} +main[data-tab="Status"] div.accesslogs > * > *:before { + opacity: 0.5; +} +.dashboard section.controls.mistvideo { + background: none; + color: inherit; + font-family: inherit; + font-size: inherit; +} +.dashboard section.controls .draggable-icon { display: none; } +.dashboard section.controls .mistvideo-log, +.dashboard section.controls .mistvideo-devcontrols .mistvideo-text, +.dashboard section.controls .mistvideo-decodingIssues:before { + color: #2584c4; + text-shadow: 0.1em 0.1em 0.1em #b5d3e2; +} +.dashboard section.controls .mistvideo-log { + font-size: 1.2em; + margin-bottom: 0; +} +.dashboard section.controls.mistvideo .mistvideo-log button { + font-size: 0.6667em; +} +.dashboard section.controls .mistvideo-log .logs { + max-height: 12.5em; + box-sizing: border-box; +} +.dashboard section.controls .mistvideo-log > * { + color: #000; + text-shadow: none; + text-transform: none; +} +.dashboard section.controls .mistvideo-log { + order: 100; +} +.dashboard section.controls .mistvideo-log { + text-transform: lowercase; +} +.dashboard section.controls .mistvideo-log:before { + content: "Player "; +} +.dashboard section.controls .mistvideo-log:first-letter{ + text-transform: uppercase; +} +.dashboard section.controls .mistvideo-log .entry { + font-size: 0.85em; +} +.dashboard section.controls .mistvideo-log .entry .timestamp { + color: #777; + font-size: 0.9em; +} +.dashboard section.controls .mistvideo-log .entry .timestamp:before, +.dashboard section.controls .mistvideo-log .entry .timestamp:after { + content: none; +} +.dashboard section.controls .mistvideo-log .entry .message { + padding-left: 0.5em; +} + +.dashboard section.controls .mistvideo-decodingIssues { + margin: 0.5em 0; + order: 99; +} +.dashboard section.controls .mistvideo-decodingIssues:before { + content: "Player statistics"; +} +.dashboard section.controls .mistvideo-decodingIssues .mistvideo-description { + font-size: inherit; +} +.dashboard section.controls.mistvideo button { + font-size: 0.9em; +} + +main[data-tab="Status"] div.pushes > div, +main[data-tab="Status"] div.triggers { + display: flex; + flex-flow: row wrap; + margin: 0.5em 0 0.25em; +} +main[data-tab="Status"] div.pushes > div:before, +main[data-tab="Status"] div.triggers:before, +main[data-tab="Status"] div.processes:before { + margin: -0.5em 0 0;*/ + display: block; +} +main[data-tab="Status"] div.pushes [data-column="Conditions"]:not(.header) { + opacity: 0.8; + display: flex; + flex-flow: column nowrap; +} +main[data-tab="Status"] div.pushes table.hideConditions [data-column="Conditions"] { + display: none; +} +main[data-tab="Status"] div.processes { + margin: 0.5em 0 0.25em; +} + +main[data-tab="Status"] div.processes table, +main[data-tab="Status"] div.triggers table, +main[data-tab="Status"] div.pushes table { + width: auto; + font-size: 0.9em; +} +main[data-tab="Status"] div.processes td, main[data-tab="Status"] div.processes th, +main[data-tab="Status"] div.triggers td, main[data-tab="Status"] div.triggers th, +main[data-tab="Status"] div.pushes td, main[data-tab="Status"] div.pushes th { + vertical-align: top; +} +main[data-tab="Status"] div.pushes tr:not(:has(td:not(:empty))) { + display: none; +} +main[data-tab="Status"] div.triggers .handler td, +main[data-tab="Status"] div.pushes .Target td { + word-break: break-all; + max-width: 25vh; +} +main[data-tab="Status"] div.pushes .Statistics td { + max-width: 25vh; +} +main[data-tab="Status"] div.pushes .Statistics .logs { + text-align: left; + text-indent: -2em; + padding-left: 2em; +} +.dashboard > section.meta [data-type="vod"] [data-liveonly], +.dashboard > section.meta [data-type="vod"] tr[data-label="Jitter"] { + display: none; +} + + + .preview_icons { display: flex; flex-flow: row wrap; @@ -936,13 +1449,13 @@ button.return:before { max-width: 28em; font-size: 0.5em; } -.mistvideo * { - min-width: initial; -} -.mistvideo h3 { +.mistvideo.mistvideo-placeholder h3 { color: inherit; text-shadow: none; } +.mistvideo * { + min-width: initial; +} .mistvideo table { color: inherit; box-shadow: none; @@ -955,7 +1468,7 @@ button.return:before { .mistvideo table td { padding: 0; } -.mistvideo button { +div.mistvideo button { background-image: none; } .mistvideo .text { diff --git a/lsp/minified.js b/lsp/minified.js index f84f71a1..d2b3d0ca 100644 --- a/lsp/minified.js +++ b/lsp/minified.js @@ -1,295 +1,362 @@ -var MD5=function(a){function b(a,b){var c,d,g,h,e;g=a&2147483648;h=b&2147483648;c=a&1073741824;d=b&1073741824;e=(a&1073741823)+(b&1073741823);return c&d?e^2147483648^g^h:c|d?e&1073741824?e^3221225472^g^h:e^1073741824^g^h:e^g^h}function c(a,c,d,g,h,e,f){a=b(a,b(b(c&d|~c&g,h),f));return b(a<>>32-e,c)}function d(a,c,d,g,h,e,f){a=b(a,b(b(c&g|d&~g,h),f));return b(a<>>32-e,c)}function e(a,c,d,g,h,e,f){a=b(a,b(b(c^d^g,h),f));return b(a<>>32-e,c)}function j(a,c,d,g,h,e,f){a=b(a,b(b(d^(c|~g), -h),f));return b(a<>>32-e,c)}function m(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var f=[],t,o,l,x,i,g,h,k,f=a.replace(/\r\n/g,"\n"),a="";for(t=0;to?a+=String.fromCharCode(o):(127o?a+=String.fromCharCode(o>>6|192):(a+=String.fromCharCode(o>>12|224),a+=String.fromCharCode(o>>6&63|128)),a+=String.fromCharCode(o&63|128));f=a;a=f.length;t=a+8;o=16*((t-t%64)/64+1);l=Array(o-1);for(i=x=0;i>>29;f=l;i=1732584193;g=4023233417;h=2562383102;k=271733878;for(a=0;ac?1*d:a .menu"),main:$("main"),header:$("header"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();try{if("mistLogin"in sessionStorage){var a=JSON.parse(sessionStorage.mistLogin);mist.user.name=a.name;mist.user.password=a.password;mist.user.host=a.host}}catch(b){}location.hash&&(a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&"),mist.user.name=a[0],a[1]&&(mist.user.host= -a[1]));mist.send(function(){$(window).trigger("hashchange")},{},{timeout:5,hide:!0});var c=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=c&&UI.elements.header.css("margin-right",-1*a+"px");c=a})});$(window).on("hashchange",function(){var a=decodeURIComponent(location.hash).substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])}); -var MistVideoObject={},otherhost={host:!1,https:!1},UI={debug:!1,elements:{},stored:{getOpts:function(){var a=localStorage.stored;a&&(a=JSON.parse(a));$.extend(!0,this.vars,a);return this.vars},saveOpt:function(a,b){this.vars[a]=b;localStorage.stored=JSON.stringify(this.vars);return this.vars},vars:{helpme:!0}},interval:{clear:function(){"undefined"!=typeof this.opts&&(clearInterval(this.opts.id),delete this.opts)},set:function(a,b){this.opts&&log("[interval]","Set called on interval, but an interval is already active."); -this.opts={delay:b,callback:a};this.opts.id=setInterval(a,b)}},returnTab:["Overview"],countrylist:{AF:"Afghanistan",AX:"Åland Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of", -BQ:"Bonaire, Sint Eustatius and Saba",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:"China",CX:"Christmas Island",CC:"Cocos (Keeling) Islands",CO:"Colombia",KM:"Comoros",CG:"Congo",CD:"Congo, the Democratic Republic of the",CK:"Cook Islands", -CR:"Costa Rica",CI:"Côte d'Ivoire",HR:"Croatia",CU:"Cuba",CW:"Curaçao",CY:"Cyprus",CZ:"Czech Republic",DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:"Gambia",GE:"Georgia",DE:"Germany",GH:"Ghana", -GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GG:"Guernsey",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and McDonald Islands",VA:"Holy See (Vatican City State)",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran, Islamic Republic of",IQ:"Iraq",IE:"Ireland",IM:"Isle of Man",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JE:"Jersey",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati", -KP:"Korea, Democratic People's Republic of",KR:"Korea, Republic of",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MK:"Macedonia, the former Yugoslav Republic of",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia, Federated States of", -MD:"Moldova, Republic of",MC:"Monaco",MN:"Mongolia",ME:"Montenegro",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:"Netherlands",NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:"Palestine, State of",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:"Pitcairn",PL:"Poland",PT:"Portugal",PR:"Puerto Rico", -QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russian Federation",RW:"Rwanda",BL:"Saint Barthélemy",SH:"Saint Helena, Ascension and Tristan da Cunha",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin (French part)",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten (Dutch part)",SK:"Slovakia",SI:"Slovenia", -SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:"Taiwan, Province of China",TJ:"Tajikistan",TZ:"Tanzania, United Republic of",TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands", -TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela, Bolivarian Republic of",VN:"Viet Nam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"},tooltip:{show:function(a,b){$tooltip=this.element;$.contains(document.body,$tooltip[0])||$("body").append($tooltip);$tooltip.html(b); -clearTimeout(this.hiding);delete this.hiding;var c=$(document).height()-$tooltip.outerHeight(),d=$(document).width()-$tooltip.outerWidth();$tooltip.css("left",Math.min(a.pageX+10,d-10));$tooltip.css("top",Math.min(a.pageY+25,c-10));$tooltip.show().addClass("show")},hide:function(){$tooltip=this.element;$tooltip.removeClass("show");this.hiding=setTimeout(function(){$tooltip.hide()},500)},element:$("
").attr("id","tooltip")},humanMime:function(a){var b=!1;switch(a){case "html5/application/vnd.apple.mpegurl":b= -"HLS (TS)";break;case "html5/application/vnd.apple.mpegurl;version=7":b="HLS (CMAF)";break;case "html5/video/webm":b="WebM";break;case "html5/video/mp4":b="MP4";break;case "dash/video/mp4":b="DASH";break;case "flash/11":b="HDS";break;case "flash/10":b="RTMP";break;case "flash/7":b="Progressive";break;case "html5/audio/mp3":b="MP3";break;case "html5/audio/wav":b="WAV";break;case "html5/video/mp2t":case "html5/video/mpeg":b="TS";break;case "html5/application/vnd.ms-sstr+xml":case "html5/application/vnd.ms-ss":b= -"Smooth Streaming";break;case "html5/text/vtt":b="VTT Subtitles";break;case "html5/text/plain":b="SRT Subtitles";break;case "html5/text/javascript":b="JSON Subtitles";break;case "rtsp":b="RTSP";break;case "webrtc":b="WebRTC"}return b},popup:{element:null,show:function(a){this.element=$("
").attr("id","popup").append($("