Skip to content

Add audio support and single playback in attributes. Readme update.#23

Open
RobTranquillo wants to merge 3 commits intorodrigocam:masterfrom
RobTranquillo:master
Open

Add audio support and single playback in attributes. Readme update.#23
RobTranquillo wants to merge 3 commits intorodrigocam:masterfrom
RobTranquillo:master

Conversation

@RobTranquillo
Copy link
Copy Markdown

I played arround a little bit and like to have audio and looping controls on the html tag, so throw it in.

Copy link
Copy Markdown
Owner

@rodrigocam rodrigocam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for your contribution @RobTranquillo! A few changes can be made so I can merge your contribution!

```html
<ar-scene>
<ar-marker patt="hiro.patt" content="hiro.gif" scale="1 1" position="0 0 0" rotation="0 0 0"></ar-marker>
<ar-marker patt="cat.patt" content="cat.mp4" audio="1" loop="0"></ar-marker>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a more semantic style, I think "0" or "1" could be changed to "true" or "false".

position: {x: 0, y: 0, z: 0},
rotation: {x: 0, y: 0, z: 0}
rotation: {x: 0, y: 0, z: 0},
loop: 0,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change these integers (0 or 1) to really booleans (true or false).

position: this.stringToVec3(arContent.getAttribute('position')),
rotation: this.stringToVec3(arContent.getAttribute('rotation'))
rotation: this.stringToVec3(arContent.getAttribute('rotation')),
loop: arContent.getAttribute('loop'),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can use something inline if:

Suggested change
loop: arContent.getAttribute('loop'),
loop: arContent.getAttribute('loop'),
loop: (arContent.getAttribute('loop') == "true" ? true : false),

this.video = document.createElement("video");
this.video.src = this.contentProps.src;

this.video.loop = true;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the previous changes here you can do:

Suggested change
this.video.loop = true;
this.video.loop = this.contentProps.loop;

this.video.loop = false;
}

this.video.muted = true;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.video.muted = true;
this.video.muted = !this.contentProps.audio;

rotation: this.stringToVec3(arContent.getAttribute('rotation'))
rotation: this.stringToVec3(arContent.getAttribute('rotation')),
loop: arContent.getAttribute('loop'),
audio: arContent.getAttribute('audio')
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
audio: arContent.getAttribute('audio')
audio: (arContent.getAttribute('audio') == "true" ? true : false)

}

this.video.muted = true;
if(this.contentProps.audio == 1)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the previous changes, these lines can be removed

this.video.src = this.contentProps.src;

this.video.loop = true;
if(this.contentProps.loop == 0)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the previous changes, these lines can be removed


} else if(ev.data.marker.id == markerId) {
if(self.video.ended != 0 && self.contentProps.loop == 0)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with this line is when the video ended if I have to update the page to play again. When the marker goes out of the camera vision and then returns, the video doesn't play again. This is the expected behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants