-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added custom action to vg-analytics #437
Open
ohjimijimijimi
wants to merge
1
commit into
videogular:master
Choose a base branch
from
ohjimijimijimi:master
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,12 +28,12 @@ | |
* "category": "Videogular", | ||
* "label": "Main", | ||
* "events": { | ||
* "ready": true, // Triggered when player is ready | ||
* "play": true|'time'|'percent', // Triggered each time player has been played. 'time' and 'percent' will attach the progress to the event value | ||
* "pause": true|'time'|'percent', // Triggered each time player has been paused. 'time' and 'percent' will attach the progress to the event value | ||
* "stop": true|'time'|'percent', // Triggered each time player has been stopped. 'time' and 'percent' will attach the progress to the event value | ||
* "complete": true, // Triggered each time player has been completed | ||
* "progress": 10 // Triggered each 10% of the progress video | ||
* "ready": true|{"action": 'ready'}, // Triggered when player is ready | ||
* "play": true|'time'|'percent'|{"value": true|'time'|'percent', "action": 'play'}, // Triggered each time player has been played. 'time' and 'percent' will attach the progress to the event value | ||
* "pause": true|'time'|'percent'|{"value": true|'time'|'percent', "action": 'pause'}, // Triggered each time player has been paused. 'time' and 'percent' will attach the progress to the event value | ||
* "stop": true|'time'|'percent'|{"value": true|'time'|'percent', "action": 'stop'}, // Triggered each time player has been stopped. 'time' and 'percent' will attach the progress to the event value | ||
* "complete": true|{"action": 'complete'}, // Triggered each time player has been completed | ||
* "progress": 10|{"value": 10', "action": 'progress'} // Triggered each 10% of the progress video | ||
* } | ||
* } | ||
* </pre> | ||
|
@@ -45,12 +45,12 @@ | |
* "category": "Videogular", | ||
* "label": "Main", | ||
* "events": { | ||
* "ready": true, | ||
* "play": true|'time'|'percent', | ||
* "pause": true|'time'|'percent', | ||
* "stop": true|'time'|'percent', | ||
* "complete": true, | ||
* "progress": 10 | ||
* "ready": true|{"action": 'ready'}, | ||
* "play": true|'time'|'percent'|{"value": true|'time'|'percent', "action": 'play'}, | ||
* "pause": true|'time'|'percent'|{"value": true|'time'|'percent', "action": 'pause'}, | ||
* "stop": true|'time'|'percent'|{"value": true|'time'|'percent', "action": 'stop'}, | ||
* "complete": true|{"action": 'complete'}, | ||
* "progress": 10|{"value": 10', "action": 'progress'} | ||
* } | ||
* } | ||
* </pre> | ||
|
@@ -81,7 +81,7 @@ angular.module("com.2fdevs.videogular.plugins.analytics", ["angulartics"]) | |
|
||
scope.onPlayerReady = function onPlayerReady(isReady) { | ||
if (isReady) { | ||
scope.trackEvent("ready"); | ||
scope.trackEvent(scope.vgTrackInfo.events.ready.action || "ready"); | ||
} | ||
}; | ||
|
||
|
@@ -92,35 +92,37 @@ angular.module("com.2fdevs.videogular.plugins.analytics", ["angulartics"]) | |
case VG_STATES.PLAY: | ||
if (scope.vgTrackInfo.events.play) { | ||
scope.setValue(scope.vgTrackInfo.events.play); | ||
scope.trackEvent("play"); | ||
scope.trackEvent(scope.vgTrackInfo.events.play.action || "play"); | ||
} | ||
break; | ||
|
||
case VG_STATES.PAUSE: | ||
if (scope.vgTrackInfo.events.pause) { | ||
scope.setValue(scope.vgTrackInfo.events.pause); | ||
scope.trackEvent("pause"); | ||
scope.trackEvent(scope.vgTrackInfo.events.pause.action || "pause"); | ||
} | ||
break; | ||
|
||
case VG_STATES.STOP: | ||
if (scope.vgTrackInfo.events.stop) { | ||
scope.setValue(scope.vgTrackInfo.events.stop); | ||
scope.trackEvent("stop"); | ||
scope.trackEvent(scope.vgTrackInfo.events.stop.action || "stop"); | ||
} | ||
break; | ||
} | ||
}; | ||
|
||
scope.onCompleteVideo = function onCompleteVideo(isCompleted) { | ||
if (isCompleted) { | ||
scope.trackEvent("complete"); | ||
scope.trackEvent(scope.vgTrackInfo.events.complete.action || "complete"); | ||
} | ||
}; | ||
|
||
scope.onUpdateTime = function onUpdateTime(newCurrentTime) { | ||
if (progressTracks.length > 0 && newCurrentTime >= progressTracks[0].jump) { | ||
scope.trackEvent("progress " + progressTracks[0].percent + "%"); | ||
scope.trackEvent((scope.vgTrackInfo.events.progress.action || "progress") | ||
+ " " | ||
+ progressTracks[0].percent + "%"); | ||
progressTracks.shift(); | ||
} | ||
}; | ||
|
@@ -140,6 +142,8 @@ angular.module("com.2fdevs.videogular.plugins.analytics", ["angulartics"]) | |
} | ||
} else if (eventType === 'time') { | ||
info.value = Math.floor(API.currentTime / 1000); | ||
} else if (typeof(eventType) === 'object' && eventType.value) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. angular.isObject() |
||
scope.setType(eventType.value); | ||
} | ||
} | ||
}; | ||
|
@@ -208,12 +212,13 @@ angular.module("com.2fdevs.videogular.plugins.analytics", ["angulartics"]) | |
totalMiliseconds = newVal / 1000; | ||
|
||
if (totalMiliseconds > 0) { | ||
var totalTracks = scope.vgTrackInfo.events.progress - 1; | ||
var progressJump = Math.floor(totalMiliseconds * scope.vgTrackInfo.events.progress / 100); | ||
var progress = scope.vgTrackInfo.events.progress.value || scope.vgTrackInfo.events.progress; | ||
var totalTracks = progress - 1; | ||
var progressJump = Math.floor(totalMiliseconds * progress / 100); | ||
|
||
for (var i = 0; i < totalTracks; i++) { | ||
progressTracks.push({ | ||
percent: (i + 1) * scope.vgTrackInfo.events.progress, | ||
percent: (i + 1) * progress, | ||
jump: (i + 1) * progressJump | ||
}); | ||
} | ||
|
@@ -241,4 +246,4 @@ angular.module("com.2fdevs.videogular.plugins.analytics", ["angulartics"]) | |
} | ||
} | ||
} | ||
]); | ||
]); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplication could be reduced with a function.