Customize Embed with Angular Directive

I'm currently attempting to customize an embedded object using Angular Directive, but I am running into difficulties getting the directive to function correctly.

Here is the code for the object:

<object width="250" height="40">
    <param name="movie" value="http://grooveshark.com/songWidget.swf">
    <param name="wmode" value="window">
    <param name="allowScriptAccess" value="always">
    <param name="flashvars" value="hostname=cowbell.grooveshark.com&amp;songIDs=26593443&amp;style=metal&amp;p=0">
    <embed src="http://grooveshark.com/songWidget.swf" type="application/x-shockwave-flash" width="250" height="40" flashvars="hostname=cowbell.grooveshark.com&amp;songIDs=26593443&amp;style=metal&amp;p=0" allowscriptaccess="always" wmode="window"/>
</object>

My goal is to dynamically define the song IDs. I have attempted the following:

<object width="250" height="40">
    <param name="movie" value="http://grooveshark.com/songWidget.swf">
    <param name="wmode" value="window">
    <param name="allowScriptAccess" value="always">
    <param name="flashvars" value="hostname=cowbell.grooveshark.com&amp;songIDs=" + {{bpmSong[0].$id}} + "&amp;style=metal&amp;p=0">
    <embed src="http://grooveshark.com/songWidget.swf" type="application/x-shockwave-flash" width="250" height="40" flashvars="hostname=cowbell.grooveshark.com&amp;songIDs=" + {{bpmSong[0].$id}} + "&amp;style=metal&amp;p=0" allowscriptaccess="always" wmode="window"/>
</object>

In essence, I have a number represented by {{bpmSong[0].$id}}, which I am trying to use as the SongID.

I believe utilizing a directive is the solution I need, but I have been unsuccessful in implementing one successfully.

Any assistance would be greatly appreciated.

UPDATE following @JayMc's suggestion attempt. I also adjusted the src to avoid syntax errors. However, it still doesn't produce the desired outcome.

index.html

<body ng-app="GrooveApp">
    <div ng-controller="MainCtrl">
        <div class="col-md-12" id="radio">
            <button class="btn-lg btn-danger" ng-click="count = count - 1" ng-init="count=0">Previous</button>
            <flash-widget songID='{{bpmSong[0].$id}}' ></flash-widget>
            <button class="btn-lg btn-danger" ng-click="count = count + 1">Next</button>
        </div>
        <div class="col-md-12">
            {{bpmSong[count].$id}}
        </div>
    </div>

app.js

angular.module("GrooveApp", ["firebase"])
    .controller("MainCtrl", function($scope, $firebase) {
        var ref = new Firebase("/bpm_playlist");
        var sync = $firebase(ref);
        
        // create a synchronized array for use in our HTML code
        $scope.bpmSong = sync.$asArray();
    })
    .directive('flashWidget', function(){

        return {
            restrict: 'E',
            scope: {
                width:'=',
                height:'=',
                src: '=',
                songID: '='
            },
            template: '<object width="250" height="40">' +
':background真<br>
友達申請承認待ちゴミ。:  &:smiley:" />'+':blob-cute: シドラ' +
'バッチャン、Love勝ったキャーイェイ!! :wow:'+':corn ~~サイトア内<em>' +
'<i rel=>:P S}{wi自己RSS</i>RenArubaitoe-mail.jpmail登録メル欄でま';      '<param name="movie" value="http://grooveshark.com/songWidget.swf">'+
                '<param name="wmode" value="window">'+
            '<param name="allowScriptAccess" value="always">'+
                '<param name="flashvars"value="hostname=cowbell.grooveshark.com&amp;songIDs="{{songId}}"&amp;style=metal&amp;p=0">'+
            '<embed src="http://grooveshark.com/songWidget.swf" type="application/x-shockwave-flash"width="250"height="40"flashvars="hostname=cowbell.grooveshark.com&amp;songIDs="{{songId}}"&amp;style=metal&amp;p=0" allowscriptaccess="always" wmode="window"/>'+
                '</object>'
        }
    });

Answer №1

Consider implementing a directive like the one provided below, which has not been tested yet.

.directive('musicPlayer', function(){

return {
    restrict: 'E',
    scope: {
        size:'=',
        length:'=',
        source: '=',
        trackID: '='
    },
    template: '<object width="{{size}}" height="{{length}}">'+
                '<param name="movie" value="{{source}}">'+
                '<param name="wmode" value="window">'+
                '<param name="allowScriptAccess" value="always">'+
                '<param name="flashvars"value="hostname=tambourine.spotify.com&amp;trackIDs="{{trackID}}"&amp;theme=rock&amp;q=1">'+
                '<embed src="{{source}}" type="application/x-shockwave-flash"width="{{size}}"height="{{length}}"flashvars="hostname=tambourine.spotify.com&amp;trackIDs="{{trackID}}"&amp;theme=rock&amp;q=1" allowscriptaccess="always" wmode="window"/>'+
            '</object>'
    }
})

Then insert your relevant data into the directive within your view:

<music-player size='200' length='30' source='http://spotify.com/trackWidget.swf' trackID='{{playlist[0].$id}}' ></music>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps should I take to show the content on different menu selections?

Check out my full code snippet. <html> <head> <meta charset="utf-8"> <title>Title</title> <link rel="stylesheet" href="https://code.jquery.com/mobile/1.5.0-rc1/jquery.mobile ...

What steps should I take when dealing with two dynamic variables in a mediator script within the WSO2 ESB?

I'm facing an issue with my if condition - it doesn't work properly when the value is static. However, when I make `annee2` and `annee1` static (for example =2019), it works fine. Here's the code snippet: <script language="js"&g ...

Filter data in AngularJS checkboxes based on true and false values

When I check a checkbox <input type="checkbox" ng-model="search.isWorking" />, my list is filtered to show only true values, which works fine. However, when I uncheck the box, I want the list to show all values (both true and false), but Angular on ...

Deselect all checkboxes other than the daily selection

I recently designed an E-commerce website that includes a package customization feature where users can modify their packages. The initial question presents three radio button options: 1. Daily 2. Weekly 3. Monthly If the user selects 'daily&apos ...

How to adjust the "skipNatural" boolean in AngularJS Smart-Table without altering the smart-table.js script

Looking to customize the "skipNatural" boolean in the smart-table.js file, but concerned about it being overwritten when using Bower for updates. The current setting in the Smart-Table file is as follows: ng.module('smart-table') .constant(&ap ...

JavaScript random number functionality experiencing an unexpected problem

function generateRandomNumbers(){ var max = document.getElementById('max').value; var min = document.getElementById('min').value; var reps = document.getElementById('reps').value; var i; for (i=0; i<reps ...

Techniques for triggering JavaScript on elements that have been dynamically loaded via Ajax

When it comes to ensuring that a certain functionality works both when the document is ready and after an Ajax call, there are some considerations to keep in mind for optimal performance. An approach I found effective involves defining the desired code wi ...

StopPropagation() method in Ng-class not functioning properly in Angular for parent element

I am facing an issue with 2 nested ng-repeats. The parent one is supposed to add a class based on ng-click, but even when I click the child, it still triggers when I don't want it to. <div class="add-filter-tags" data-filter="{{f1}}" ng-class="{&a ...

Emphasize specific letters in a word by making them bold, according to the user

In my app, there is a search feature that filters data based on user input and displays a list of matching results. I am trying to make the text that was searched by the user appear bold in the filtered data. For example, if the user searches 'Jo&apos ...

Sync Data Automatically from SQL Database

For the past two months, I've been researching how to achieve an effect similar to the auto-updating sales on the page. So far, I haven't had any luck. I do have a PHP file that counts the number of results in a database and displays them as a n ...

Creating a unique styleset in styled-jsx using custom ruleset generation

TL;DR What's the best way to insert a variable containing CSS rules into styled-jsx (using styled-jsx-plugin-sass)? In my JSX style, I have the following: // src/pages/index.tsx ... <style jsx> {` .test { height: 100vh; width ...

Achieving Center Alignment for Material-UI's <Table> within a <div> using ReactJS

Currently, I am working with a Material-UI's <Table> embedded within a <div>. My goal is to center the <Table> while maintaining a fixed width. I want the table to remain centered in the browser, but if the browser window is minimize ...

Checking an angular directive - using angular.element.css

I am working on writing a test for an angular directive method in Jasmine. How can I test the toHaveBeenCalled method for the .css method in the code snippet below? I have attempted to create a spy for the method, but I keep receiving the error message Exp ...

Utilizing requirejs or grunt for concatenation and minification greatly enhances the performance of AngularJS implementations

I'm facing a dilemma with my Angular app. I have several JS files included in the index.html file, and when the app loads, all these files are downloaded before the app is ready. <html> ... <script src="scripts/controllers/loginController.js ...

How the web api response might contain a null value

I currently have a Web Api controller set up to access data from the server: public class ServicesController : ApiController { [AcceptVerbs("POST")] public IList<TreeMenuItem> LoadMetadata() { List<TreeMenuItem> itemsMenu = ...

The next/font feature functions perfectly in all areas except for a single specific component

New Experience with Next.js and Tailwind CSS Exploring the next/font Package Delving into the realm of the new next/font package has been quite interesting. Following the tutorial provided by Next.js made the setup process smooth sailing. I've incorp ...

Removing a key from an index signature in Typescript - a step-by-step guide

In my web application built with Angular, we encountered a need for a data type to store translations of strings in different languages. To address this requirement, a team member defined the following type: export class TranslatedString { [language: str ...

Issue with CKEditor5 Link popup not displaying in both Bootstrap 5 modal and RSuite library modal in React

React: How to troubleshoot CKEditor5 Link popup not appearing in a modal using either Bootstrap 5 or rsuite library? Seeking advice on resolving this issue. Your help is appreciated! ...

The ins and outs of function returns and callback mechanisms

I'm encountering an issue related to the order of my functions and I can't figure out the reason behind it. When I hover over the call for function_2 inside the first function, VSCode shows me the result as Promise<void>, and the console p ...

When copying text from React-PDF Display, the values may appear altered or varied

This snippet of text was excerpted from a brief SHA provided at the git summit. Generated using React-pdf, this is a PDF document with some interesting quirks. Although the displayed text reads as 4903677, it changes to •G07THH when copied. The font ...