examples/QtQuick/qmlaudioplayer/qml/qmlaudioplayer/mainwindow.qml

00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation
00006 **
00007 **
00008 ** $QT_BEGIN_LICENSE:BSD$
00009 ** You may use this file under the terms of the BSD license as follows:
00010 **
00011 ** "Redistribution and use in source and binary forms, with or without
00012 ** modification, are permitted provided that the following conditions are
00013 ** met:
00014 **   * Redistributions of source code must retain the above copyright
00015 **     notice, this list of conditions and the following disclaimer.
00016 **   * Redistributions in binary form must reproduce the above copyright
00017 **     notice, this list of conditions and the following disclaimer in
00018 **     the documentation and/or other materials provided with the
00019 **     distribution.
00020 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
00021 **     the names of its contributors may be used to endorse or promote
00022 **     products derived from this software without specific prior written
00023 **     permission.
00024 **
00025 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00028 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00029 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00030 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00031 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00032 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00033 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00034 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00035 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
00036 ** $QT_END_LICENSE$
00037 **
00038 ****************************************************************************/
00039 
00040 import QtQuick 1.0
00041 import com.nokia.symbian 1.0
00042 import SampleFileBrowser 1.0
00043 
00044 ApplicationWindow{
00045     id:main
00046 
00047     // Audio player component.
00048     Player{ id: player }
00049 
00050     ToolBarLayout {
00051         id: commonTools
00052         ToolButton {
00053             flat: true
00054             iconSource: "toolbar_back.svg"
00055             onClicked: Qt.quit()
00056         }
00057         ToolButton {
00058             flat: true
00059             iconSource: "toolbar_options.svg"
00060             onClicked: browseFile.openDialog()
00061         }
00062     }
00063 
00064 
00065     Page{
00066         id: simpleAudioPlayerPage
00067         tools: commonTools
00068 
00069 
00070         MyFileBrowser{ id: browseFile }
00071 
00072         PageHeading{
00073             id: heading
00074             anchors.top: parent.top
00075             width: parent.width
00076             text: qsTr("Simple Audio player")
00077         }
00078 
00079         Row{
00080             id: audioControls
00081             width: parent.width
00082             height: 80
00083             anchors.bottom: parent.bottom
00084 
00085             Button{
00086                 width: parent.width/2
00087                 iconSource: player.playing ? "toolbar_pause.svg" : "toolbar_play.svg"
00088                 onClicked: player.playing ? player.pause() : player.play()
00089             }
00090 
00091             Button{
00092                 width: parent.width/2
00093                 iconSource: "toolbar_stop.svg"
00094                 onClicked: player.stop()
00095             }
00096         }
00097 
00098         Item {
00099             id: seekSlider
00100 
00101             anchors { bottom: audioControls.top; bottomMargin: 25 }
00102             width: parent.width
00103             height: slider.height + positionTime.height
00104 
00105             Slider {
00106                 id: slider
00107 
00108                 anchors.top: parent.top
00109                 width: parent.width
00110                 maximumValue: player.duration
00111                 stepSize: 1000
00112 
00113                 onPressedChanged: {
00114                     if (!pressed)
00115                         player.position = value
00116                 }
00117 
00118                 Binding {
00119                     target: slider
00120                     property: "value"
00121                     value: player.position
00122                     when: !slider.pressed
00123                 }
00124             }
00125 
00126             Text {
00127                 id: positionTime
00128 
00129                 anchors { left: parent.left; top: slider.bottom; leftMargin: 15; topMargin: 4 }
00130                 color: "white"
00131                 font.pixelSize: 18
00132                 text: player.positionTime
00133             }
00134 
00135             Text {
00136                 id: durationTime
00137 
00138                 anchors { right: parent.right; top: slider.bottom; rightMargin: 15; topMargin: 4 }
00139                 color: "white"
00140                 font.pixelSize: 18
00141                 text: player.durationTime
00142             }
00143         }
00144 
00145         Item {
00146             id: infoText
00147 
00148             anchors { bottom: seekSlider.top; bottomMargin: 36 }
00149             width: parent.width
00150             height: title.height + artist.height + 15
00151             clip: true
00152 
00153             Text {
00154                 id: artist
00155 
00156                 width: parent.width
00157                 anchors { bottom: title.top; bottomMargin: 18 }
00158                 horizontalAlignment: Text.AlignHCenter
00159                 //audio.metaData.albumArtist
00160                 text: player.artist
00161                 color: "white"
00162                 font.pixelSize: 28
00163                 wrapMode: Text.WordWrap
00164                 visible: player.artist != "" ? true : false
00165 
00166                 Behavior on text {
00167                     NumberAnimation {
00168                         target: artist
00169                         property: "opacity"
00170                         from: 0
00171                         to: 1
00172                         duration: 1000
00173                     }
00174                 }
00175             }
00176 
00177             Text {
00178                 id: title
00179 
00180                 width: parent.width
00181                 anchors.bottom: parent.bottom
00182                 horizontalAlignment: Text.AlignHCenter
00183                 text: player.title
00184                 color: "white"
00185                 font.pixelSize: 20
00186                 wrapMode: Text.WordWrap
00187 
00188                 Behavior on text {
00189                     NumberAnimation {
00190                         target: title
00191                         property: "opacity"
00192                         from: 0
00193                         to: 1
00194                         duration: 1000
00195                     }
00196                 }
00197             }
00198 
00199         }
00200 
00201         Connections{
00202             target: browseFile
00203             onFileSelected: player.source = newSourceFile
00204         }
00205 
00206     }
00207 
00208 
00209     Component.onCompleted: pageStack.push(simpleAudioPlayerPage)
00210 }
00211 

Generated by  doxygen 1.6.2