MCPcopy
hub / github.com/serversideup/amplitudejs / play

Function play

src/core/core.js:73–116  ·  view source on GitHub ↗

* Plays the active song. If the current song is live, it reconnects * the stream before playing. * * Public Accessor: Amplitude.play() * * @access public

()

Source from the content-addressed store, hash-verified

71 * @access public
72 */
73 function play() {
74 Visualizations.stop();
75 Visualizations.run();
76
77 /*
78 If the audio is live we re-conenct the stream.
79 */
80 if (config.active_metadata.live) {
81 reconnectStream();
82 }
83
84 /*
85 Mobile remote sources need to be reconnected on play. I think this is
86 because mobile browsers are optimized not to load all resources
87 for speed reasons. We only do this if mobile and the paused button
88 is not clicked. If the pause button was clicked then we don't reconnect
89 or the user will lose their place in the stream.
90 */
91 if (
92 /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
93 navigator.userAgent
94 ) &&
95 !config.paused
96 ) {
97 reconnectStream();
98 }
99
100 /*
101 Play the song and set the playback rate to the playback
102 speed.
103 */
104 let playPromise = config.audio.play();
105
106 if (playPromise !== undefined) {
107 playPromise.then(_ => {}).catch(error => {});
108 }
109 config.audio.play();
110 config.audio.playbackRate = config.playback_speed;
111
112 /*
113 Sets the state of the player.
114 */
115 ConfigState.setPlayerState();
116 }
117
118 /**
119 * Pauses the active song. If it's live, it disconnects the stream.

Callers

nothing calls this directly

Calls 1

reconnectStreamFunction · 0.85

Tested by

no test coverage detected