Skip to content

Commit

Permalink
added basic support for video.js players
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoappenzeller committed Oct 16, 2016
1 parent efb2c96 commit 365c03b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 8 deletions.
8 changes: 5 additions & 3 deletions PiPifier-Safari-Extension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>PiPifier-Safari-Extension</string>
<string>PiPifier Button</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand All @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<string>1.3</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>3</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSExtension</key>
Expand Down Expand Up @@ -48,6 +48,8 @@
</dict>
<key>SFSafariWebsiteAccess</key>
<dict>
<key>Allowed Domains</key>
<array/>
<key>Level</key>
<string>All</string>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>group.APPenzeller.PiPifier</string>
<string>$(TeamIdentifierPrefix)group.APPenzeller.PiPifier</string>
</array>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
Expand Down
24 changes: 24 additions & 0 deletions PiPifier-Safari-Extension/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ function checkForCustomPiPButtonSupport(){
if (isYoutube.map(function(obj){return location.hostname.match(obj) != null;}).indexOf(true) >= 0){
addYouTubeVideoButton();
}
//check for videoJS player on site
else if(document.getElementsByClassName('vjs-control-bar').length > 0){
addVideoJSPlayerButton();
}
//check for other players
//TODO: add other players here
}
Expand Down Expand Up @@ -91,3 +95,23 @@ function addYouTubeVideoButton() {
document.getElementsByClassName("ytp-right-controls")[0].appendChild(button);
}
}

function addVideoJSPlayerButton() {
var video = document.getElementsByTagName('video')[0];
if (video != null && document.getElementsByClassName('PiPifierButton').length == 0) {
var button = document.createElement("button");
button.className = "PiPifierButton vjs-control vjs-button";
button.title = "PiP (by PiPifier)";
button.onclick = function(){document.getElementsByTagName('video')[0].webkitSetPresentationMode('picture-in-picture');};


var buttonImage = document.createElement("img");
buttonImage.src = whiteSVG_Icon;
buttonImage.width = 16;
buttonImage.height = 30;
button.appendChild(buttonImage);

var fullscreenButton = document.getElementsByClassName("vjs-fullscreen-control")[0];
fullscreenButton.parentNode.insertBefore(button, fullscreenButton);
}
}
3 changes: 3 additions & 0 deletions PiPifier.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@
com.apple.ApplicationGroups.Mac = {
enabled = 1;
};
com.apple.Sandbox = {
enabled = 1;
};
};
};
11F1B5131D4EC1010041579B = {
Expand Down
6 changes: 4 additions & 2 deletions PiPifier/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<string>1.3</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>3</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
Expand Down
5 changes: 4 additions & 1 deletion PiPifier/PiPifier.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>group.APPenzeller.PiPifier</string>
<string></string>
<string>$(TeamIdentifierPrefix)group.APPenzeller.PiPifier</string>
</array>
</dict>
</plist>
2 changes: 1 addition & 1 deletion PiPifier/SettingsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SettingsManager {

//NOTE: replace with your own group identifier when developping for yourself
//Don't forget to change it in the entitlements as well otherwise it can cause crashes
let sharedUserDefaults = UserDefaults(suiteName: "group.APPenzeller.PiPifier")!
let sharedUserDefaults = UserDefaults(suiteName: "AW9CBV6SY7.group.APPenzeller.PiPifier")!

var isCustomPiPButtonsEnabled:Bool{
get{
Expand Down

0 comments on commit 365c03b

Please sign in to comment.