Commit eccee385 authored by yu's avatar yu

背景音乐

parent cb5f2d9f
......@@ -7,10 +7,11 @@
* @FilePath: \ls_gramophone\assets\ls_gramophone\scene\ls_gramophone.ts
*/
import { threadId } from 'worker_threads';
import Item from '../script/Item';
import { MyCocosSceneComponent } from '../script/MyCocosSceneComponent';
import { onHomeworkFinish } from '../script/util';
// import { threadId } from _ls_gramophone'worker_threads';
import Item from '../script/Item_ls_gramophone';
import { MyCocosSceneComponent } from '../script/MyCocosSceneComponent_ls_gramophone';
import { onHomeworkFinish } from '../script/util_ls_gramophone';
import pg from './pg_ls_gramophone';
const { ccclass, property } = cc._decorator;
......@@ -33,6 +34,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
@property(cc.Node)
btn_last: cc.Node = null;
@property(cc.Node)
btn_audio_off: cc.Node = null;
@property(cc.Node)
btn_audio_on: cc.Node = null;
// 录音中
_recording = false;
......@@ -47,6 +52,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
_results = [];
private _curData = null;
private isPlayBgAudio: boolean;
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
this._imageResList.push({ url: this.data.pageImage });
......@@ -88,6 +94,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
}
private stopQuestionAudio() {
if (this.questionAudioId > -1) pg.audio.stopAudio(this.questionAudioId);
}
private questionAudioId = -1;
initView() {
let self = this;
const bgNode = cc.find('Canvas/bg');
......@@ -102,7 +113,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
play.off('click');
stop.off('click');
play.on('click', () => {
cc.audioEngine.stopAll();
this.stopQuestionAudio();
play.active = false;
stop.active = true;
......@@ -110,15 +121,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
stop.on('click', () => {
this.resetText();
this.resetRecord();
cc.audioEngine.stopAll();
this.stopQuestionAudio();
play.active = true;
stop.active = false;
this.playAudioByUrl(this.data.questions[this.roundIdx].audio, () => {
pg.audio.playAudioByUrl(this.data.questions[this.roundIdx].audio, (() => {
play.active = false;
stop.active = true;
});
})).then((audioId: number) => {
this.questionAudioId = audioId;
})
});
let pag = cc.find("PageView", this.node);
pag.on('page-turning', this.pageTurning, this);
......@@ -143,7 +155,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
element.on('click', () => {
this.resetText();
this.resetRecord();
cc.audioEngine.stopAll();
// cc.audioEngine.stopAll();
this.stopQuestionAudio();
play.active = false;
stop.active = true;
......@@ -162,7 +175,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.resetText();
this.resetRecord();
cc.audioEngine.stopAll();
// cc.audioEngine.stopAll();
this.stopQuestionAudio();
play.active = false;
stop.active = true;
......@@ -186,7 +200,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
myrecord.on('click', () => {
this.resetText();
this.resetRecord();
cc.audioEngine.stopAll();
// cc.audioEngine.stopAll();
this.stopQuestionAudio();
element.getComponent(Item).playRecord();
//
if (this._records[this.roundIdx][index] != null) {
......@@ -196,7 +211,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
});
myrecord_play.on('click', () => {
cc.audioEngine.stopAll();
// cc.audioEngine.stopAll();
this.stopQuestionAudio();
element.getComponent(Item).stopRecord();
});
}
......@@ -383,6 +399,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.btn_last.on(cc.Node.EventType.TOUCH_END, this.onLast, this);
this.setPagBg();
this.refreshArrow();
if (this.data.bgAudio && this.data.bgAudio != "") {
this.btn_audio_on.active = true;
}
}
private onAudioOn() {
this.btn_audio_off.active = true;
this.btn_audio_on.active = false;
this.isPlayBgAudio = false;
this.stopBgAudio();
}
private onAudioOff() {
this.btn_audio_on.active = true;
this.btn_audio_off.active = false;
this.isPlayBgAudio = true;
this.playBgAudio();
}
private playBgAudio() {
if (!this.isPlayBgAudio) return;
cc.audioEngine.resumeMusic();
}
private stopBgAudio() {
cc.audioEngine.pauseMusic();
}
private roundIdx;
private setPagBg() {
......@@ -390,14 +428,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
let stop = cc.find('Canvas/btn_stop');
play.active = false;
stop.active = true;
cc.audioEngine.stopAll();
// cc.audioEngine.stopAll();
this.stopQuestionAudio();
this.resetText();
this.resetRecord();
let pag = cc.find("PageView", this.node);
let idx = pag.getComponent(cc.PageView).getCurrentPageIndex();
let data = this.data.questions[this.roundIdx].pageImage;
this.getSpriteFrimeByUrl(data , (sp) => {//+ '?x-oss-process=image/resize,m_fill,h_520,w_560'
this.getSpriteFrimeByUrl(data, (sp) => {//+ '?x-oss-process=image/resize,m_fill,h_520,w_560'
// this.getSpriteFrimeByUrl(this.data.pageImage, (sp) => {
cc.find('Canvas/bg_img/img').getComponent(cc.Sprite).spriteFrame = sp;
cc.find('Canvas/bg_img/img').width = 435;
......@@ -528,6 +567,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (str === 'start' || str === 'restart') {
cc.audioEngine.stopAll();
this.playLocalAudio('btn');
pg.audio.playBgAudioByUrl(this.data.bgAudio);
this.hideTip();
} else if (str === 'record_start') {
} else if (str === 'record_stop') {
......@@ -544,3 +584,4 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
}
}
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "6488649d-5145-4050-85f1-c408de89e931",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@
* @FilePath: \ls_gramophone\assets\ls_gramophone\script\Item.ts
*/
import simpleLabel from './simpleLabel';
import simpleLabel from './simpleLabel_ls_gramophone';
const { ccclass, property } = cc._decorator;
......@@ -201,3 +201,4 @@ export default class Item extends cc.Component {
});
}
}
import { defaultData } from '../script/defaultData';
import { defaultData } from '../script/defaultData_ls_gramophone';
export class MyCocosSceneComponent extends cc.Component {
// 生命周期 onLoad
......@@ -154,3 +154,4 @@ export class MyCocosSceneComponent extends cc.Component {
}
}
}
......@@ -13,6 +13,7 @@ export const defaultData = {
"questionTextAudio": "http://staging-teach.cdn.ireadabc.com/92ddbc65e9af775f7a8450a5bef1a732.mp3",
"questionTextAudioName": "热气球大战 游戏说明.mp3",
"pageAudio": 'http://staging-teach.cdn.ireadabc.com/c0e467e1950cb24b1e581737a1344cb4.mp3', // 整体音频
"bgAudio": "https://staging-teach.cdn.ireadabc.com/ed84c18cc5f696ceaaf488ff98c228fe_l.mp3",
"questions": [{
"options": [{
"duration": 7,
......@@ -70,3 +71,4 @@ export const defaultData = {
}
]
}
......@@ -184,3 +184,4 @@ export default class simpleLabel extends cc.Component {
return poss;
}
}
......@@ -412,3 +412,4 @@ export function onHomeworkFinish(data: any = null) {
console.log('onHomeworkFinish');
}
}
......@@ -11,7 +11,7 @@
"height": 750,
"platformSettings": {},
"subMetas": {
"bg_bg": {
"bg_bg_ls_gramophone": {
"ver": "1.0.4",
"uuid": "5b8fa8f8-69f7-4cd7-8461-4a98c525f3fa",
"rawTextureUuid": "b6c84980-825c-4220-b49b-920d9d5ac752",
......
......@@ -11,7 +11,7 @@
"height": 111,
"platformSettings": {},
"subMetas": {
"bg_title": {
"bg_title_ls_gramophone": {
"ver": "1.0.4",
"uuid": "915feae7-7c90-4232-a713-aa69e40fa05d",
"rawTextureUuid": "d23fbff9-6c53-40e8-aecb-21885c6d3263",
......
......@@ -11,7 +11,7 @@
"height": 650,
"platformSettings": {},
"subMetas": {
"bg_pic": {
"bg_pic_ls_gramophone": {
"ver": "1.0.4",
"uuid": "a8f6ec27-c56d-48fd-b029-55fd426be8bf",
"rawTextureUuid": "0f5af10f-a566-4d98-9dd1-0015373af532",
......
......@@ -11,7 +11,7 @@
"height": 83,
"platformSettings": {},
"subMetas": {
"btn_play": {
"btn_play_ls_gramophone": {
"ver": "1.0.4",
"uuid": "7e839787-bfe9-4d1e-8192-f7d4a52bfd4b",
"rawTextureUuid": "044d2236-d281-4dba-b956-88c4e6205966",
......
......@@ -11,7 +11,7 @@
"height": 83,
"platformSettings": {},
"subMetas": {
"btn_stop": {
"btn_stop_ls_gramophone": {
"ver": "1.0.4",
"uuid": "97a0cdc6-8615-4377-b784-d0f7786bf562",
"rawTextureUuid": "3776685d-8e08-4b72-b511-66e511975da8",
......
......@@ -11,7 +11,7 @@
"height": 709,
"platformSettings": {},
"subMetas": {
"bg_word": {
"bg_word_ls_gramophone": {
"ver": "1.0.4",
"uuid": "ee8f8646-6541-4821-802a-9dd1226bb6a0",
"rawTextureUuid": "88d5ece8-5b48-4e8a-ad59-9dbb615eed3c",
......
......@@ -11,7 +11,7 @@
"height": 47,
"platformSettings": {},
"subMetas": {
"btn_myrecord": {
"btn_myrecord_ls_gramophone": {
"ver": "1.0.4",
"uuid": "07a5995e-da34-4901-b2ef-5a27aa2a51a9",
"rawTextureUuid": "e86902af-2ceb-4d1d-99b8-3272911cbf47",
......
......@@ -11,7 +11,7 @@
"height": 47,
"platformSettings": {},
"subMetas": {
"btn_myrecord_play": {
"btn_myrecord_play_ls_gramophone": {
"ver": "1.0.4",
"uuid": "83dfc0af-38c5-4a56-9f73-6134e381c9a0",
"rawTextureUuid": "2496c569-e161-4efb-bfea-552d09d7ddb9",
......
......@@ -11,7 +11,7 @@
"height": 51,
"platformSettings": {},
"subMetas": {
"btn_record_click": {
"btn_record_click_ls_gramophone": {
"ver": "1.0.4",
"uuid": "9291d0e3-7df4-49d8-b234-186ee3c26d71",
"rawTextureUuid": "1547ca2f-0ee1-4628-964c-955f837e7806",
......
......@@ -11,7 +11,7 @@
"height": 51,
"platformSettings": {},
"subMetas": {
"btn_record": {
"btn_record_ls_gramophone": {
"ver": "1.0.4",
"uuid": "4cfe1f8a-a4b4-48cc-8bcd-8866448462d0",
"rawTextureUuid": "6dd0b075-08d6-4f3d-9067-9f74a242679b",
......
......@@ -11,7 +11,7 @@
"height": 47,
"platformSettings": {},
"subMetas": {
"icon_myrecord1": {
"icon_myrecord1_ls_gramophone": {
"ver": "1.0.4",
"uuid": "49ba3b54-d5a3-4011-ad1e-70edff5ed3d1",
"rawTextureUuid": "9e032bab-64f8-4496-a7f7-d9b1a1178511",
......
......@@ -11,7 +11,7 @@
"height": 47,
"platformSettings": {},
"subMetas": {
"icon_myrecord2": {
"icon_myrecord2_ls_gramophone": {
"ver": "1.0.4",
"uuid": "2ade5076-4bc6-4526-b12f-04afe606920d",
"rawTextureUuid": "7e1e3da1-0c5b-4e35-ab3c-b2e5e74bdb0a",
......
......@@ -11,7 +11,7 @@
"height": 47,
"platformSettings": {},
"subMetas": {
"icon_myrecord3": {
"icon_myrecord3_ls_gramophone": {
"ver": "1.0.4",
"uuid": "6293f1a4-dcbd-4418-8b28-fea36246172a",
"rawTextureUuid": "2e7f987a-7d6b-4117-bb87-98ce51cb561e",
......
......@@ -11,7 +11,7 @@
"height": 24,
"platformSettings": {},
"subMetas": {
"icon_tip": {
"icon_tip_ls_gramophone": {
"ver": "1.0.4",
"uuid": "1aae5979-bee8-4b8f-a281-b80cd70241c4",
"rawTextureUuid": "dad1d295-5c60-47bd-9359-2977376b08e4",
......
......@@ -11,7 +11,7 @@
"height": 370,
"platformSettings": {},
"subMetas": {
"bg": {
"bg_ls_gramophone": {
"ver": "1.0.4",
"uuid": "b2b4f91f-9686-4ec3-87c2-c899cf81af32",
"rawTextureUuid": "a39b73de-86c0-428c-9f02-e89c0d18c2d9",
......
......@@ -11,7 +11,7 @@
"height": 112,
"platformSettings": {},
"subMetas": {
"btn_restart": {
"btn_restart_ls_gramophone": {
"ver": "1.0.4",
"uuid": "dcaec617-c484-4947-9e1f-2a8aa0db47b0",
"rawTextureUuid": "694a8ab6-0cc0-43ac-b106-2cf16779c7aa",
......
......@@ -11,7 +11,7 @@
"height": 112,
"platformSettings": {},
"subMetas": {
"btn_start": {
"btn_start_ls_gramophone": {
"ver": "1.0.4",
"uuid": "7323747f-f4ca-4ad2-b83b-7bf4754af17e",
"rawTextureUuid": "6b75c36e-5db0-4500-be2a-0d3ef573bb20",
......
......@@ -11,7 +11,7 @@
"height": 88,
"platformSettings": {},
"subMetas": {
"bg_countdown": {
"bg_countdown_ls_gramophone": {
"ver": "1.0.4",
"uuid": "6bd4223d-195a-4f70-be53-168346c39c99",
"rawTextureUuid": "224882b8-db5c-46e7-bc79-08387be3a2b3",
......
......@@ -11,7 +11,7 @@
"height": 54,
"platformSettings": {},
"subMetas": {
"btn_arrow": {
"btn_arrow_ls_gramophone": {
"ver": "1.0.4",
"uuid": "d516539c-34b9-4ea5-9ad6-e9b755dcdd08",
"rawTextureUuid": "9082c14f-ac84-4269-a26d-ca137636e51b",
......
......@@ -11,7 +11,7 @@
"height": 54,
"platformSettings": {},
"subMetas": {
"btn_last": {
"btn_last_ls_gramophone": {
"ver": "1.0.4",
"uuid": "3aeb6cd9-61ed-4228-90b6-f0d92d7b0fe4",
"rawTextureUuid": "d2f08bde-6a56-48ba-9917-4000f6c17424",
......
......@@ -11,7 +11,7 @@
"height": 101,
"platformSettings": {},
"subMetas": {
"btn_record_start": {
"btn_record_start_ls_gramophone": {
"ver": "1.0.4",
"uuid": "eb50d182-5552-4842-b101-2b258fbe5598",
"rawTextureUuid": "660adc39-d4c0-4926-8b04-335537b93b65",
......
......@@ -11,7 +11,7 @@
"height": 101,
"platformSettings": {},
"subMetas": {
"btn_record_stop": {
"btn_record_stop_ls_gramophone": {
"ver": "1.0.4",
"uuid": "72c17ac2-d0ee-4b4d-bb3f-06db48ae962e",
"rawTextureUuid": "deef01da-ab08-46bb-8a40-c768458983a8",
......
......@@ -11,7 +11,7 @@
"height": 2,
"platformSettings": {},
"subMetas": {
"default_sprite_splash": {
"default_sprite_splash_ls_gramophone": {
"ver": "1.0.4",
"uuid": "6dbe7207-203b-481b-aaca-7cf179c77e26",
"rawTextureUuid": "6d121f1d-9e09-49a4-9afe-6c959d9e6253",
......
......@@ -11,7 +11,7 @@
"height": 83,
"platformSettings": {},
"subMetas": {
"icon_record": {
"icon_record_ls_gramophone": {
"ver": "1.0.4",
"uuid": "60136ca7-0fff-46dc-bc51-b9dca51cdc7b",
"rawTextureUuid": "96c1ac51-e7ba-481a-931c-dbf577c505ed",
......
{
"ver": "2.3.5",
"uuid": "e52b3ad4-d6e6-424d-a80e-e3e7dc09c46b",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 90,
"height": 83,
"platformSettings": {},
"subMetas": {
"ls_bg_audio_off_ls_gramophone": {
"ver": "1.0.4",
"uuid": "f35ca32b-5204-4d64-a1f9-4e0679571494",
"rawTextureUuid": "e52b3ad4-d6e6-424d-a80e-e3e7dc09c46b",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 90,
"height": 83,
"rawWidth": 90,
"rawHeight": 83,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "5a25b1e6-5c39-41c0-859e-9454901156b8",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 90,
"height": 83,
"platformSettings": {},
"subMetas": {
"ls_bg_audio_on_ls_gramophone": {
"ver": "1.0.4",
"uuid": "1532fa8c-7462-4f06-834e-5cb2cbb663f5",
"rawTextureUuid": "5a25b1e6-5c39-41c0-859e-9454901156b8",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 90,
"height": 83,
"rawWidth": 90,
"rawHeight": 83,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "ebe09a20-b069-42b6-86e8-55222f82afbc",
"uuid": "4fb2dce4-3afb-45e2-a9e7-f49989dc6271",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"name": "录音动画",
"SubTexture": [
{
"name": "提示/椭圆_11",
"x": 1,
"height": 208,
"y": 1,
"width": 205
},
{
"name": "提示/椭圆_11_拷贝",
"x": 208,
"height": 156,
"y": 1,
"width": 156
},
{
"name": "提示/组_1",
"x": 366,
"height": 130,
"y": 1,
"width": 90
}
],
"height": 256,
"imagePath": "ly_tex.png",
"width": 512
}
\ No newline at end of file
......@@ -11,7 +11,7 @@
"height": 256,
"platformSettings": {},
"subMetas": {
"录音动画_tex": {
"ly_tex_ls_gramophone": {
"ver": "1.0.4",
"uuid": "05c3f6c4-4249-4082-adec-15804c2598bc",
"rawTextureUuid": "30ec20dc-46c1-4856-9367-eca6abae46f4",
......
{"name":"录音动画","SubTexture":[{"name":"提示/椭圆_11","x":1,"height":208,"y":1,"width":205},{"name":"提示/椭圆_11_拷贝","x":208,"height":156,"y":1,"width":156},{"name":"提示/组_1","x":366,"height":130,"y":1,"width":90}],"height":256,"imagePath":"录音动画_tex.png","width":512}
\ No newline at end of file
......@@ -74,7 +74,7 @@
</style>
<div class="model-content">
<div nz-row style="margin: 20px;width: 1000px;">
<div nz-row style="margin: 20px;width: 1000px;">
<div nz-col [nzSpan]="18" [nzOffset]="1">
<nz-card nzTitle="标题信息">
<nz-form-item>
......@@ -102,9 +102,33 @@
</div>
<br />
<div class="border-dashed" style="margin-left: 60px;width: 750px;">
<div class="word-input-title">
<div>
<span>游戏背景音乐: </span>
</div>
<div>
<span style="color:rgb(201, 200, 200);margin-left:5px;font-size: 10px;"> *可不传,不传既无背景音乐</span>
</div>
</div>
<div style="display:flex ;margin-top: 10px;">
<div>
<app-audio-recorder [audioUrl]="item.bgAudio" [_audioName]="item.bgAudioName"
(audioUploaded)="onAudioUploadSuccess($event, item, 'bgAudio')"
(audioName)="onAudioName($event, item, 'bgAudioName')"></app-audio-recorder>
</div>
<!-- <div style="margin: 5px">
<span>{{ item.bgAudioName}}</span>
</div> -->
<div style="margin: 5px">
<span style="color: #169BD5;text-decoration: underline;" type="button" nzDanger
(click)="deleteBgAudio()">删除背景音</span>
</div>
</div>
</div>
<!--页面区域-->
<div nz-row style="margin: 20px;width: 1000px;">
<div nz-row style="margin: 20px;width: 1000px;">
<div nz-col [nzSpan]="18" [nzOffset]="1">
<div *ngFor="let page of item.questions; let j=index" style="margin-bottom: 5mm;" nz-col [nzXs]='24' [nzSm]='24'
[nzMd]='24' [nzLg]='24'>
......
......@@ -67,6 +67,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.save();
}
this.item.bgAudio = "";
this.item.bgAudioName = "";
if (!this.item.questions) {
this.item.questions = [];
this.addPage()
......@@ -166,6 +168,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
deleteBgAudio() {
this.item.bgAudio = "";
this.item.bgAudioName = "";
this.save();
}
isVisible = false;
deleteTitle = "是否删除题目";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment