From e59dd47c55cb99d54fc2ef23fee854222f819f1c Mon Sep 17 00:00:00 2001 From: karkinge Date: Wed, 21 Sep 2016 12:55:23 +0200 Subject: [PATCH 1/5] Add swf2js to bower components --- bower.json | 3 ++- gulpfile.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 18451ac..d3709d5 100644 --- a/bower.json +++ b/bower.json @@ -33,7 +33,8 @@ "angular-piwik": "ThoughtWorksInc/angular-piwik#duplicate-calls", "jplayer": "~2.9.2", "angular-translate-loader-static-files": "~2.7.2", - "angular-translate": "~2.7.2" + "angular-translate": "~2.7.2", + "swf2js": "https://github.com/ienaga/swf2js.git" }, "resolutions": { "angular": "1.3.11" diff --git a/gulpfile.js b/gulpfile.js index 26c3b41..caac2c2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -103,6 +103,7 @@ var vendors = { 'bower_components/json-formatter/dist/json-formatter.js', 'bower_components/angular-toastr/dist/angular-toastr.tpls.js', 'bower_components/jplayer/dist/jplayer/jquery.jplayer.js', + 'bower_components/swf2js/swf2js.js', ], 'styles': [ 'bower_components/skeleton/css/normalize.css', From 392ad505beed99029cb67b3e44d5190f8632bc51 Mon Sep 17 00:00:00 2001 From: karkinge Date: Wed, 21 Sep 2016 14:10:37 +0200 Subject: [PATCH 2/5] Auto play swf artworks in legacy HS themes --- app_sources/Theme/service.js | 22 ++++++++++++++++++++++ app_sources/Theme/template.html | 2 ++ 2 files changed, 24 insertions(+) diff --git a/app_sources/Theme/service.js b/app_sources/Theme/service.js index 80a3f50..a2ee851 100644 --- a/app_sources/Theme/service.js +++ b/app_sources/Theme/service.js @@ -133,6 +133,28 @@ app.factory('themes', ['$q', 'fs', 'settings', 'zip', 'xml', 'dataServer', } }); } + + //Look for swf files to play + var i = 1, script = []; + for(var filename in ownFiles){ + if(ownFiles[filename].split('.').pop().toLowerCase() === 'swf'){ + + console.log(obj); + console.log(ownFiles); + + //TODO: use real swf2js code from php converter + script.push('var _root' + i + ' = swf2js.createRootMovieClip(1024, 768, 120);' + + 'var stage' + i + ' = _root' + i + '.getStage();' + + 'stage' + i + '.backgroundColor = "transparent";' + + 'var mc' + i + ' = _root' + i + '.createMovieClip("BG' + i + '");' + + 'mc' + i + '.loadMovie("' + filename + '");'); + } + i++; + } + if(script.length > 0){ + obj.script = obj.path + '/theme.js'; + fs.writeFile(obj.script,script.join()); + } }); service.curType = 'hs'; diff --git a/app_sources/Theme/template.html b/app_sources/Theme/template.html index 7efcc0a..9a4e944 100644 --- a/app_sources/Theme/template.html +++ b/app_sources/Theme/template.html @@ -17,4 +17,6 @@ + + From 588391a2b82489c4f585ba89c9ec23bfa6bffebf Mon Sep 17 00:00:00 2001 From: karkinge Date: Thu, 22 Sep 2016 12:08:27 +0200 Subject: [PATCH 3/5] Real swf2js swf files handling. Yet to improve for multi swf themes. --- app_sources/Artwork/service.js | 2 +- app_sources/Artwork/template.html | 6 ------ app_sources/Theme/service.js | 23 +---------------------- app_sources/Theme/template.html | 2 -- 4 files changed, 2 insertions(+), 31 deletions(-) diff --git a/app_sources/Artwork/service.js b/app_sources/Artwork/service.js index 31a542a..7067f27 100644 --- a/app_sources/Artwork/service.js +++ b/app_sources/Artwork/service.js @@ -41,7 +41,7 @@ app.factory('artworks', ['$q', 'qbind', 'fs', if (obj.type === 'png' || obj.type === 'jpg') { getSize = getImageNaturalSize(obj.src); } else if (obj.type === 'swf') { - getSize = getFlashNaturalSize(obj.src); + swf2js.load(obj.src, { bgcolor: "transparent" }); } else if (obj.type === 'flv') { getSize = $q.when({width: 200, height: 200}); } else if (obj.type === 'mp4') { diff --git a/app_sources/Artwork/template.html b/app_sources/Artwork/template.html index b531167..a6a021e 100644 --- a/app_sources/Artwork/template.html +++ b/app_sources/Artwork/template.html @@ -1,12 +1,6 @@
- - - - - -
diff --git a/app_sources/Theme/service.js b/app_sources/Theme/service.js index a2ee851..5c69cf2 100644 --- a/app_sources/Theme/service.js +++ b/app_sources/Theme/service.js @@ -28,6 +28,7 @@ app.factory('themes', ['$q', 'fs', 'settings', 'zip', 'xml', 'dataServer', background: null, html: false, video: null, + script: null }; // Check if this is a Html theme @@ -133,28 +134,6 @@ app.factory('themes', ['$q', 'fs', 'settings', 'zip', 'xml', 'dataServer', } }); } - - //Look for swf files to play - var i = 1, script = []; - for(var filename in ownFiles){ - if(ownFiles[filename].split('.').pop().toLowerCase() === 'swf'){ - - console.log(obj); - console.log(ownFiles); - - //TODO: use real swf2js code from php converter - script.push('var _root' + i + ' = swf2js.createRootMovieClip(1024, 768, 120);' + - 'var stage' + i + ' = _root' + i + '.getStage();' + - 'stage' + i + '.backgroundColor = "transparent";' + - 'var mc' + i + ' = _root' + i + '.createMovieClip("BG' + i + '");' + - 'mc' + i + '.loadMovie("' + filename + '");'); - } - i++; - } - if(script.length > 0){ - obj.script = obj.path + '/theme.js'; - fs.writeFile(obj.script,script.join()); - } }); service.curType = 'hs'; diff --git a/app_sources/Theme/template.html b/app_sources/Theme/template.html index 9a4e944..7efcc0a 100644 --- a/app_sources/Theme/template.html +++ b/app_sources/Theme/template.html @@ -17,6 +17,4 @@ - - From adc8baa40eab3d091d837c246504af512b4a7a6b Mon Sep 17 00:00:00 2001 From: karkinge Date: Thu, 22 Sep 2016 14:20:06 +0200 Subject: [PATCH 4/5] Separate swf players in each theme frame --- app_sources/Artwork/service.js | 6 ++++-- app_sources/Theme/template.html | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app_sources/Artwork/service.js b/app_sources/Artwork/service.js index 7067f27..6cd3c71 100644 --- a/app_sources/Artwork/service.js +++ b/app_sources/Artwork/service.js @@ -33,15 +33,17 @@ app.factory('artworks', ['$q', 'qbind', 'fs', filename: null, }; - // Extract type from extname + // Extract type from extname & filename obj.type = fs.extname(obj.src || ''); + obj.filename = fs.basename(obj.src); // Natural size method differ base on the type var getSize = $q.when(null); if (obj.type === 'png' || obj.type === 'jpg') { getSize = getImageNaturalSize(obj.src); } else if (obj.type === 'swf') { - swf2js.load(obj.src, { bgcolor: "transparent" }); + swf2js.load( obj.src,{ bgcolor: "transparent", tagId: obj.filename.toLowerCase() }); + getSize = $q.when({width: 1024, height: 768}); } else if (obj.type === 'flv') { getSize = $q.when({width: 200, height: 200}); } else if (obj.type === 'mp4') { diff --git a/app_sources/Theme/template.html b/app_sources/Theme/template.html index 7efcc0a..4f656f8 100644 --- a/app_sources/Theme/template.html +++ b/app_sources/Theme/template.html @@ -3,7 +3,7 @@
-
+
From 733716a269ab5e1161c7bcfba17d97ba72351737 Mon Sep 17 00:00:00 2001 From: karkinge Date: Thu, 22 Sep 2016 17:50:27 +0200 Subject: [PATCH 5/5] strange swf placement hack. Pure guessing. --- app_sources/Artwork/service.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/app_sources/Artwork/service.js b/app_sources/Artwork/service.js index 6cd3c71..3fb30e7 100644 --- a/app_sources/Artwork/service.js +++ b/app_sources/Artwork/service.js @@ -42,25 +42,35 @@ app.factory('artworks', ['$q', 'qbind', 'fs', if (obj.type === 'png' || obj.type === 'jpg') { getSize = getImageNaturalSize(obj.src); } else if (obj.type === 'swf') { - swf2js.load( obj.src,{ bgcolor: "transparent", tagId: obj.filename.toLowerCase() }); - getSize = $q.when({width: 1024, height: 768}); + getSize = getFlashNaturalSize(obj.src); } else if (obj.type === 'flv') { getSize = $q.when({width: 200, height: 200}); } else if (obj.type === 'mp4') { getSize = getVideoNaturalSize(obj.src); } - getSize.then(function(size) { obj.size = size; - }); - obj.computeBox = service.computeBox.bind(null, obj); + if(obj.type =='swf'){ + var swfOptions = { + bgcolor: "transparent", + tagId: obj.filename.toLowerCase(), + optionHeight: obj.size.height, + optionWidth:obj.size.width + }; + swf2js.load( + obj.src, + swfOptions); + }; + obj.computeBox = service.computeBox.bind(null, obj); + }); return obj; }; // Compute item bounding box base one config service.computeBox = function(obj, conf, isOverlay) { + // If we miss both config or size, abort if (!conf && !obj.size) return {}; @@ -73,12 +83,17 @@ app.factory('artworks', ['$q', 'qbind', 'fs', box.width = (conf.w || obj.size.width || 0); box.height = (conf.h || obj.size.height || 0); - // Position (x,y) is defined as the position of the center + // Position (x,y) is defined as the position of the center // of the resized artwork relative to window (top,left) // posX = x - (width / 2) box.left = (conf.x - (box.width / 2)) || 0; box.top = (conf.y - (box.height / 2)) || 0; + //SWF placement... please don't ask + if((obj.type == 'swf') && (conf.x <= 0)){ + box.left = box.top = 0; + } + // If the item is an overlay, the previously parsed config // is its artorwk's and the actual size and position can be // deduced from it.